From 83fb7f2a6d6ba886b46e6c4d1269f6c0b0867a2b Mon Sep 17 00:00:00 2001 From: Jochen Klar Date: Mon, 3 Jun 2024 17:39:19 +0200 Subject: [PATCH] Add test_detail_export_full test --- rdmo/questions/tests/test_viewset_catalog.py | 17 +++++++++++++++++ rdmo/questions/tests/test_viewset_page.py | 17 +++++++++++++++++ rdmo/questions/tests/test_viewset_question.py | 15 +++++++++++++++ .../questions/tests/test_viewset_questionset.py | 16 ++++++++++++++++ rdmo/questions/tests/test_viewset_section.py | 17 +++++++++++++++++ 5 files changed, 82 insertions(+) diff --git a/rdmo/questions/tests/test_viewset_catalog.py b/rdmo/questions/tests/test_viewset_catalog.py index f6e0d1fc74..e1a4e2cbb7 100644 --- a/rdmo/questions/tests/test_viewset_catalog.py +++ b/rdmo/questions/tests/test_viewset_catalog.py @@ -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 diff --git a/rdmo/questions/tests/test_viewset_page.py b/rdmo/questions/tests/test_viewset_page.py index afac8f91ef..e0147bb0b5 100644 --- a/rdmo/questions/tests/test_viewset_page.py +++ b/rdmo/questions/tests/test_viewset_page.py @@ -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 diff --git a/rdmo/questions/tests/test_viewset_question.py b/rdmo/questions/tests/test_viewset_question.py index 8456621494..baee8839b5 100644 --- a/rdmo/questions/tests/test_viewset_question.py +++ b/rdmo/questions/tests/test_viewset_question.py @@ -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 diff --git a/rdmo/questions/tests/test_viewset_questionset.py b/rdmo/questions/tests/test_viewset_questionset.py index e3781b7e6d..314e874255 100644 --- a/rdmo/questions/tests/test_viewset_questionset.py +++ b/rdmo/questions/tests/test_viewset_questionset.py @@ -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 diff --git a/rdmo/questions/tests/test_viewset_section.py b/rdmo/questions/tests/test_viewset_section.py index 3176ef391b..efd64e07da 100644 --- a/rdmo/questions/tests/test_viewset_section.py +++ b/rdmo/questions/tests/test_viewset_section.py @@ -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