From e72d2ee8c94e48d2a9fa2b8547702d2aa72ecf07 Mon Sep 17 00:00:00 2001 From: "pooya.oa" Date: Mon, 16 Dec 2024 10:46:19 +0100 Subject: [PATCH] create test data --- .../tests/test_controller.py | 33 +++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/ckanext/dataset_reference/tests/test_controller.py b/ckanext/dataset_reference/tests/test_controller.py index ad75bd3..7de4e2c 100644 --- a/ckanext/dataset_reference/tests/test_controller.py +++ b/ckanext/dataset_reference/tests/test_controller.py @@ -20,8 +20,37 @@ class TestControllers(object): @pytest.fixture(autouse=True) def intial(self): - pass - + ctd.CreateTestData.create() + sysadmin_user = model.User.get("testsysadmin") + self.auth = {u"Authorization": str(sysadmin_user.apikey)} + + + + # @pytest.mark.usefixtures('clean_db', 'with_plugins', 'with_request_context') + # def test_add_reference_with_doi_when_doi_is_valid(self, app, migrate_db_for): + # ''' + # A user has to be able to add a reference + # with a doi url + # ''' + # # ctd.CreateTestData.create() + # migrate_db_for("dataset_reference") + # sysadmin_user = model.User.get("testsysadmin") + # owner_org = factories.Organization(users=[{ + # 'name': sysadmin_user.id, + # 'capacity': 'member' + # }]) + # dataset = factories.Dataset(owner_org=owner_org['id']) + # auth = {u"Authorization": str(sysadmin_user.apikey)} + # data = { + # 'package_id': dataset['id'], + # 'doi_or_bibtex': 'doi', + # 'doi': 'https://doi.org/10.1007/978-3-030-57717-9_36' + # } + # dest_url = h.url_for('dataset_reference.save_doi') + # response = app.post(dest_url, data=data, extra_environ=auth) + # assert response.status_code == 200 + # assert True == True + def test_doi_is_valid_call(self, app):