Skip to content

Commit

Permalink
feat(tests): added new cli arg to tests;
Browse files Browse the repository at this point in the history
- Added new `include-users` arg to dump and load tests.
  • Loading branch information
JVickery-TBS committed Aug 22, 2023
1 parent 15f8dda commit bae24c0
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 29 deletions.
28 changes: 18 additions & 10 deletions ckanapi/tests/test_cli_dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ def test_parent_dump_all(self):
'--get-request': False,
'--datastore-fields': False,
'--resource-views': False,
'--insecure': False
'--insecure': False,
'--include-users': False,
},
worker_pool=self._mock_worker_pool,
stdout=self.stdout,
Expand Down Expand Up @@ -177,7 +178,8 @@ def test_parent_parallel_limit(self):
'--get-request': False,
'--datastore-fields': False,
'--resource-views': False,
'--insecure': False
'--insecure': False,
'--include-users': False,
},
worker_pool=self._mock_worker_pool,
stdout=self.stdout,
Expand Down Expand Up @@ -205,7 +207,8 @@ def test_parent_id_argument(self):
'--get-request': False,
'--datastore-fields': False,
'--resource-views': False,
'--insecure': False
'--insecure': False,
'--include-users': False,
},

worker_pool=self._mock_worker_pool,
Expand Down Expand Up @@ -235,7 +238,8 @@ def test_parent_maintain_order(self):
'--get-request': False,
'--datastore-fields': False,
'--resource-views': False,
'--insecure': False
'--insecure': False,
'--include-users': False,
},
worker_pool=self._mock_worker_pool_reversed,
stdout=self.stdout,
Expand Down Expand Up @@ -269,7 +273,8 @@ def test_parent_datapackages(self):
'--get-request': False,
'--datastore-fields': False,
'--resource-views': False,
'--insecure': False
'--insecure': False,
'--include-users': False,
},
worker_pool=self._worker_pool_with_data,
stdout=self.stdout,
Expand Down Expand Up @@ -301,7 +306,7 @@ def test_parent_datapackages(self):
finally:
shutil.rmtree(target)


def test_resource_views(self):
target = tempfile.mkdtemp()
try:
Expand All @@ -322,7 +327,8 @@ def test_resource_views(self):
'--get-request': False,
'--datastore-fields': False,
'--resource-views': True,
'--insecure': False
'--insecure': False,
'--include-users': False,
},
worker_pool=self._worker_pool_with_resource_views,
stdout=self.stdout,
Expand Down Expand Up @@ -374,20 +380,22 @@ def _worker_pool_with_data(self, cmd, processes, job_iter):
dump_things_worker(self.ckan, 'datasets', {
'--datastore-fields': True,
'--resource-views': False,
'--insecure': False},
'--insecure': False,
'--include-users': False,},
stdin=worker_stdin,
stdout=worker_stdout)
for i, v in enumerate(worker_stdout.getvalue().strip().split(b'\n')):
yield [[], i, v]


def _worker_pool_with_resource_views(self, cmd, proccesses, job_iter):
worker_stdin = BytesIO(b''.join(v for i, v in job_iter))
worker_stdout = BytesIO()
dump_things_worker(self.ckan, 'datasets', {
'--datastore-fields': False,
'--resource-views': True,
'--insecure': False},
'--insecure': False,
'--include-users': False,},
stdin=worker_stdin,
stdout=worker_stdout)
for i, v in enumerate(worker_stdout.getvalue().strip().split(b'\n')):
Expand Down
57 changes: 38 additions & 19 deletions ckanapi/tests/test_cli_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ def test_create_with_no_resources(self):
'--create-only': False,
'--update-only': False,
'--upload-resources': False,
'--insecure': False
'--insecure': False,
'--include-users': False,
},
stdin=BytesIO(b'{"name": "45","title":"Forty-five"}\n'),
stdout=self.stdout)
Expand All @@ -84,7 +85,8 @@ def test_create_with_corrupted_resources(self):
'--create-only': False,
'--update-only': False,
'--upload-resources': False,
'--insecure': False
'--insecure': False,
'--include-users': False,
},
stdin=BytesIO(b'{"name": "45","title":"Forty-five","resources":[{"id":"123"}]}\n'),
stdout=self.stdout)
Expand All @@ -100,7 +102,8 @@ def test_create_with_complete_resources(self):
'--create-only': False,
'--update-only': False,
'--upload-resources': False,
'--insecure': False
'--insecure': False,
'--include-users': False,
},
stdin=BytesIO(
b'{"name": "45","title":"Forty-five",'
Expand All @@ -118,7 +121,8 @@ def test_create_only(self):
'--create-only': True,
'--update-only': False,
'--upload-resources': False,
'--insecure': False
'--insecure': False,
'--include-users': False,
},
stdin=BytesIO(b'{"name": "45","title":"Forty-five"}\n'),
stdout=self.stdout)
Expand All @@ -134,7 +138,8 @@ def test_create_empty_dict(self):
'--create-only': False,
'--update-only': False,
'--upload-resources': False,
'--insecure': False
'--insecure': False,
'--include-users': False,
},
stdin=BytesIO(b'{}\n'),
stdout=self.stdout)
Expand All @@ -149,7 +154,8 @@ def test_create_bad_option(self):
load_things_worker(self.ckan, 'datasets', {
'--create-only': False,
'--update-only': True,
'--insecure': False
'--insecure': False,
'--include-users': False,
},
stdin=BytesIO(b'{"name": "45","title":"Forty-five"}\n'),
stdout=self.stdout)
Expand All @@ -164,7 +170,8 @@ def test_update_with_no_resources(self):
load_things_worker(self.ckan, 'datasets', {
'--create-only': False,
'--update-only': False,
'--insecure': False
'--insecure': False,
'--include-users': False,
},
stdin=BytesIO(b'{"name": "30ish","title":"3.4 times ten"}\n'),
stdout=self.stdout)
Expand All @@ -180,7 +187,8 @@ def test_update_with_corrupted_resources(self):
'--create-only': False,
'--update-only': False,
'--upload-resources': False,
'--insecure': False
'--insecure': False,
'--include-users': False,
},
stdin=BytesIO(b'{"name": "30ish","title":"3.4 times ten","resources":[{"id":"123"}]}\n'),
stdout=self.stdout)
Expand All @@ -196,7 +204,8 @@ def test_update_with_complete_resources(self):
'--create-only': False,
'--update-only': False,
'--upload-resources': False,
'--insecure': False
'--insecure': False,
'--include-users': False,
},
stdin=BytesIO(
b'{"name": "30ish","title":"3.4 times ten",'
Expand All @@ -214,7 +223,8 @@ def test_update_only(self):
'--create-only': False,
'--update-only': True,
'--upload-resources': False,
'--insecure': False
'--insecure': False,
'--include-users': False,
},
stdin=BytesIO(b'{"name": "34","title":"3.4 times ten"}\n'),
stdout=self.stdout)
Expand All @@ -230,7 +240,8 @@ def test_update_bad_option(self):
'--create-only': True,
'--update-only': False,
'--upload-resources': False,
'--insecure': False
'--insecure': False,
'--include-users': False,
},
stdin=BytesIO(b'{"name": "34","title":"3.4 times ten"}\n'),
stdout=self.stdout)
Expand All @@ -246,7 +257,8 @@ def test_update_unauthorized(self):
'--create-only': False,
'--update-only': False,
'--upload-resources': False,
'--insecure': False
'--insecure': False,
'--include-users': False,
},
stdin=BytesIO(b'{"name": "seekrit", "title": "Things"}\n'),
stdout=self.stdout)
Expand All @@ -262,7 +274,8 @@ def test_update_group(self):
'--create-only': False,
'--update-only': False,
'--upload-resources': False,
'--insecure': False
'--insecure': False,
'--include-users': False,
},
stdin=BytesIO(b'{"id": "ab","title":"a balloon"}\n'),
stdout=self.stdout)
Expand All @@ -278,7 +291,8 @@ def test_update_organization_two(self):
'--create-only': False,
'--update-only': False,
'--upload-resources': False,
'--insecure': False
'--insecure': False,
'--include-users': False,
},
stdin=BytesIO(
b'{"name": "cd", "title": "Go"}\n'
Expand All @@ -302,7 +316,8 @@ def test_update_organization_with_users_unchanged(self):
'--create-only': False,
'--update-only': False,
'--upload-resources': False,
'--insecure': False
'--insecure': False,
'--include-users': False,
},
stdin=BytesIO(b'{"id": "used", "title": "here"}\n'),
stdout=self.stdout)
Expand All @@ -318,7 +333,8 @@ def test_update_organization_with_users_cleared(self):
'--create-only': False,
'--update-only': False,
'--upload-resources': False,
'--insecure': False
'--insecure': False,
'--include-users': False,
},
stdin=BytesIO(b'{"id": "unused", "users": []}\n'),
stdout=self.stdout)
Expand Down Expand Up @@ -347,7 +363,8 @@ def test_parent_load_two(self):
'--max-records': None,
'--upload-resources': False,
'--upload-logo': False,
'--insecure': False
'--insecure': False,
'--include-users': False,
},
worker_pool=self._mock_worker_pool,
stdin=BytesIO(
Expand Down Expand Up @@ -382,7 +399,8 @@ def test_parent_load_start_max(self):
'--max-records': '2',
'--upload-resources': False,
'--upload-logo': False,
'--insecure': False
'--insecure': False,
'--include-users': False,
},
worker_pool=self._mock_worker_pool,
stdin=BytesIO(
Expand Down Expand Up @@ -420,7 +438,8 @@ def test_parent_parallel_limit(self):
'--max-records': None,
'--upload-resources': False,
'--upload-logo': False,
'--insecure': False
'--insecure': False,
'--include-users': False,
},
worker_pool=self._mock_worker_pool,
stdin=BytesIO(
Expand Down

0 comments on commit bae24c0

Please sign in to comment.