Skip to content

Commit

Permalink
Add test_detail_export_full test
Browse files Browse the repository at this point in the history
  • Loading branch information
jochenklar authored and MyPyDavid committed Jun 19, 2024
1 parent deb4d41 commit f0a3969
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 0 deletions.
17 changes: 17 additions & 0 deletions rdmo/questions/tests/test_viewset_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,3 +251,20 @@ def test_detail_export(db, client, username, password, export_format):
assert root.tag == 'rdmo'
for child in root:
assert child.tag in ['catalog', 'section', 'page', 'questionset', 'question']


def test_detail_export_full(db, client):
client.login(username='editor', password='editor')

url = reverse(urlnames['detail_export'], args=[1]) + 'xml/?full=true'
response = client.get(url)
assert response.status_code == status_map['detail']['editor'], response.content

root = et.fromstring(response.content)
assert root.tag == 'rdmo'

uris = [child.attrib[r'{http://purl.org/dc/elements/1.1/}uri'] for child in root]
assert 'http://example.com/terms/conditions/options_empty' in uris
assert 'http://example.com/terms/domain/conditions' in uris
assert 'http://example.com/terms/options/one_two_three' in uris
assert 'http://example.com/terms/options/one_two_three/one' in uris
17 changes: 17 additions & 0 deletions rdmo/questions/tests/test_viewset_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,3 +330,20 @@ def test_detail_export(db, client, username, password, export_format):
assert root.tag == 'rdmo'
for child in root:
assert child.tag in ['page', 'questionset', 'question']


def test_detail_export_full(db, client):
client.login(username='editor', password='editor')

url = reverse(urlnames['detail_export'], args=[71]) + 'xml/?full=true'
response = client.get(url)
assert response.status_code == status_map['detail']['editor'], response.content

root = et.fromstring(response.content)
assert root.tag == 'rdmo'

uris = [child.attrib[r'{http://purl.org/dc/elements/1.1/}uri'] for child in root]
assert 'http://example.com/terms/conditions/options_empty' in uris
assert 'http://example.com/terms/domain/conditions' in uris
assert 'http://example.com/terms/options/one_two_three' in uris
assert 'http://example.com/terms/options/one_two_three/one' in uris
15 changes: 15 additions & 0 deletions rdmo/questions/tests/test_viewset_question.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,3 +365,18 @@ def test_detail_export(db, client, username, password, export_format):
assert root.tag == 'rdmo'
for child in root:
assert child.tag in ['question']


def test_detail_export_full(db, client):
client.login(username='editor', password='editor')

url = reverse(urlnames['detail_export'], args=[104]) + 'xml/?full=true'
response = client.get(url)
assert response.status_code == status_map['detail']['editor'], response.content

root = et.fromstring(response.content)
assert root.tag == 'rdmo'

uris = [child.attrib[r'{http://purl.org/dc/elements/1.1/}uri'] for child in root]
assert 'http://example.com/terms/conditions/set_bool_is_true' in uris
assert 'http://example.com/terms/domain/conditions' in uris
16 changes: 16 additions & 0 deletions rdmo/questions/tests/test_viewset_questionset.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,3 +370,19 @@ def test_detail_export(db, client, username, password, export_format):
assert root.tag == 'rdmo'
for child in root:
assert child.tag in ['questionset', 'question']


def test_detail_export_full(db, client):
client.login(username='editor', password='editor')

url = reverse(urlnames['detail_export'], args=[90]) + 'xml/?full=true'
response = client.get(url)
assert response.status_code == status_map['detail']['editor'], response.content

root = et.fromstring(response.content)
assert root.tag == 'rdmo'

uris = [child.attrib[r'{http://purl.org/dc/elements/1.1/}uri'] for child in root]
assert 'http://example.com/terms/domain/blocks' in uris
assert 'http://example.com/terms/options/one_two_three' in uris
assert 'http://example.com/terms/options/one_two_three/one' in uris
17 changes: 17 additions & 0 deletions rdmo/questions/tests/test_viewset_section.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,20 @@ def test_detail_export(db, client, username, password, export_format):
assert root.tag == 'rdmo'
for child in root:
assert child.tag in ['section', 'page', 'questionset', 'question']


def test_detail_export_full(db, client):
client.login(username='editor', password='editor')

url = reverse(urlnames['detail_export'], args=[5]) + 'xml/?full=true'
response = client.get(url)
assert response.status_code == status_map['detail']['editor'], response.content

root = et.fromstring(response.content)
assert root.tag == 'rdmo'

uris = [child.attrib[r'{http://purl.org/dc/elements/1.1/}uri'] for child in root]
assert 'http://example.com/terms/conditions/options_empty' in uris
assert 'http://example.com/terms/domain/conditions' in uris
assert 'http://example.com/terms/options/one_two_three' in uris
assert 'http://example.com/terms/options/one_two_three/one' in uris

0 comments on commit f0a3969

Please sign in to comment.