Skip to content

Commit

Permalink
[refactor] update testing code
Browse files Browse the repository at this point in the history
  • Loading branch information
erik1110 committed Oct 6, 2023
1 parent a136a0e commit 55e38d8
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions src/ccip/tests/api/test_ccip.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,7 @@ def assert_data_structure(data, key):
assert 'bio' in item['zh']
assert 'bio' in item['en']


@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')


@pytest.mark.django_db
def test_session(client):
response = client.get(endpoint, follow=True)
data = response.json()
def assert_data_structure_session(data):
assert 'sessions' in data
sessions = data.get('sessions', [])
# 檢查每個 session 是否包含所需的字段
Expand All @@ -48,3 +32,15 @@ def test_session(client):
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)

0 comments on commit 55e38d8

Please sign in to comment.