-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
232 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,41 @@ | ||
FROM python:3.6-slim-buster | ||
# [Node Stage to get node_modolues and node dependencies] | ||
FROM node:8.16.0-buster-slim as node_stage | ||
|
||
ENV PYTHONUNBUFFERED 1 | ||
WORKDIR /app | ||
COPY ./yarn.lock yarn.lock | ||
COPY ./package.json package.json | ||
|
||
ENV BASE_DIR /usr/local | ||
RUN apt-get update | ||
RUN apt-get install python-pip -y | ||
|
||
ENV NVM_INSTALLER_URL https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | ||
ENV NVM_DIR $BASE_DIR/nvm | ||
ENV YARN_VERSION 1.15.2-1 | ||
ENV NODE_VERSION 8.16.0 | ||
RUN npm install -g yarn | ||
RUN yarn install --dev --frozen-lockfile | ||
|
||
# [Python Stage for Django web server] | ||
FROM python:3.6-slim-buster as python_stage | ||
|
||
WORKDIR /app | ||
|
||
# make nodejs and yarn accessible and executable globally | ||
ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH | ||
COPY --from=node_stage /node_modules ./node_modules | ||
COPY --from=node_stage /usr/local/bin/node /usr/local/bin/node | ||
|
||
ENV PYTHONUNBUFFERED 1 | ||
ENV BASE_DIR /usr/local | ||
|
||
# Infrastructure tools | ||
# gettext is used for django to compile .po to .mo files. | ||
RUN apt-get update | ||
RUN apt-get install apt-utils -y | ||
RUN apt-get update | ||
RUN apt-get install gettext python3-pip -y | ||
|
||
# Install Node and Yarn from upstream | ||
RUN curl -o- $NVM_INSTALLER_URL | bash \ | ||
&& . $NVM_DIR/nvm.sh \ | ||
&& nvm install $NODE_VERSION \ | ||
&& nvm alias default $NODE_VERSION \ | ||
&& nvm use default \ | ||
&& nvm --version \ | ||
&& npm install -g yarn \ | ||
&& yarn --version | ||
|
||
RUN apt-get install -y \ | ||
libpq-dev \ | ||
gcc \ | ||
zlib1g-dev \ | ||
libjpeg62-turbo-dev \ | ||
gettext | ||
|
||
# Only copy and install requirements to improve caching between builds | ||
# Install Python dependencies | ||
COPY ./requirements ./requirements | ||
RUN pip3 install -r ./requirements/dev.txt | ||
|
||
# # Install Javascript dependencies | ||
COPY ./package.json ./package.json | ||
COPY ./yarn.lock ./yarn.lock | ||
RUN yarn install --dev --frozen-lockfile | ||
|
||
# for entry point | ||
COPY ./docker-entrypoint.sh /docker-entrypoint.sh | ||
RUN chmod +x /docker-entrypoint.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import pytest | ||
from django.conf import settings | ||
from registry.helper import reg | ||
from attendee.models import Attendee | ||
from core.models import Token | ||
|
||
|
||
@pytest.mark.parametrize('attendee_token,status,num_channel', [ | ||
('123', 400, 0), | ||
('1234', 200, 0), | ||
('1234', 200, 1), | ||
('1234', 200, 2), | ||
]) | ||
@pytest.mark.django_db | ||
def test_attendee(drf_api_client, bare_user, attendee_token, status, num_channel): | ||
token = Token.objects.get_or_create(user=bare_user) | ||
drf_api_client.credentials(HTTP_AUTHORIZATION="Token " + str(token[0])) | ||
attendee = Attendee(token="1234") | ||
attendee.save() # insert to database | ||
# add slug | ||
key_prefix = f"{settings.CONFERENCE_DEFAULT_SLUG}.live." | ||
reg["pycontw-1999.live.r1"] = "video_old_id" # unrelated | ||
for i in range(num_channel): | ||
reg[f"{key_prefix}r{i}"] = f"video_id_{i}" | ||
|
||
# test | ||
response = drf_api_client.post('/api/attendee/verify/', data={"token": attendee_token}) | ||
assert response.status_code == status | ||
if status == 200: | ||
assert len(response.json()["youtube_infos"]) == num_channel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import pytest | ||
|
||
endpoint = "/ccip/" | ||
|
||
|
||
def assert_data_structure(data, key): | ||
assert key in data | ||
items = data.get(key, []) | ||
for item in items: | ||
assert 'id' in item | ||
assert 'zh' in item | ||
assert 'en' in item | ||
assert 'name' in item['zh'] | ||
assert 'name' in item['en'] | ||
if key == "speakers": | ||
assert 'avatar' in item | ||
assert 'bio' in item['zh'] | ||
assert 'bio' in item['en'] | ||
|
||
|
||
def assert_data_structure_session(data): | ||
assert 'sessions' in data | ||
sessions = data.get('sessions', []) | ||
# 檢查每個 session 是否包含所需的字段 | ||
required_fields = [ | ||
"id", "type", "start", "end", "slide", "speakers", "tags", | ||
"en", "zh", "room", "broadcast", "qa", "live", "record" | ||
] | ||
for session in sessions: | ||
for field in required_fields: | ||
assert field in session | ||
assert 'title' in session['en'] | ||
assert 'description' in session['en'] | ||
assert 'title' in session['zh'] | ||
assert 'description' in session['zh'] | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_data_structure(client): | ||
response = client.get(endpoint, follow=True) | ||
assert response.status_code == 200 | ||
data = response.json() | ||
|
||
assert_data_structure(data, 'session_types') | ||
assert_data_structure(data, 'tags') | ||
assert_data_structure(data, 'rooms') | ||
assert_data_structure(data, 'speakers') | ||
assert_data_structure_session(data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.