From b5b33aafba6958445dd120135fbc413f6f08d4cd Mon Sep 17 00:00:00 2001 From: Alessio Izzo Date: Tue, 23 Jul 2024 11:18:58 +0200 Subject: [PATCH] fix bad refactor of test_projects (#460) * fix bad refactor of test_projects * fix integration tests --- integration/test_expressions.py | 8 ++++++-- integration/test_projects.py | 31 +++++++++++++++---------------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/integration/test_expressions.py b/integration/test_expressions.py index 6ca7614..f5e6971 100644 --- a/integration/test_expressions.py +++ b/integration/test_expressions.py @@ -80,7 +80,9 @@ def test_multiple_response_any_add_filter_single_subvar(self): data = ds.follow("table", "limit=20&filter={}".format(resp.resource.self))['data'] ds_variables = ds.variables.by("alias") mr_variable_id = ds_variables["mr_variable"].id - assert data[mr_variable_id] == [] + assert data[mr_variable_id] == [ + [1, 2, 2] + ] finally: # cleanup ds.delete() @@ -269,7 +271,9 @@ def test_categorical_array_any_w_bracket_subvar(self): data = ds.follow("table", "limit=20&filter={}".format(resp.resource.self))['data'] ds_variables = ds.variables.by("alias") cat_var_variable_id = ds_variables["categorical_var"].id - assert data[cat_var_variable_id] == [1, 3, {"?": -1}] + assert data[cat_var_variable_id] == [ + [1, 3, {"?": -1}] + ] assert resp.resource.body.entity.body.definition == { "function": "in", "args": [ diff --git a/integration/test_projects.py b/integration/test_projects.py index 6fe033a..7c24716 100644 --- a/integration/test_projects.py +++ b/integration/test_projects.py @@ -12,13 +12,6 @@ FEATURE_FLAG = 'old_projects_order' -def new_project(name): - res = self.site.projects.create(shoji_entity_wrapper({ - "name": name + UNIQUE_PREFIX - })).refresh() - return Project(res) - - class TestProjects(BaseIntegrationTestCase): def setUp(self): """ @@ -28,8 +21,14 @@ def setUp(self): super(TestProjects, self).setUp() self.site.session.feature_flags[FEATURE_FLAG] = False + def new_project(self, name): + res = self.site.projects.create(shoji_entity_wrapper({ + "name": name + UNIQUE_PREFIX + })).refresh() + return Project(res) + def test_create_subprojects(self): - pa = new_project('A') + pa = self.new_project('A') pb = pa.create_project("B") pa.resource.refresh() self.assertTrue(pb.url in pa.resource.index) @@ -38,9 +37,9 @@ def test_create_subprojects(self): def test_move_project(self): # Both top level projects - pa = new_project("test_move_project_A") - pb = new_project("test_move_project_B") - pc = new_project("test_move_project_C") + pa = self.new_project("test_move_project_A") + pb = self.new_project("test_move_project_B") + pc = self.new_project("test_move_project_C") pa.resource.refresh() self.assertFalse(pb.url in pa.resource.index) pa.place(pb, "|") @@ -51,14 +50,14 @@ def test_move_project(self): self.assertTrue(pc.url in pb.resource.index) def test_rename(self): - project = new_project("test_rename") + project = self.new_project("test_rename") new_name = "renamed" + UNIQUE_PREFIX project.rename(new_name) _project = get_project(new_name) self.assertEqual(_project.url, project.url) def test_reorder(self): - pa = new_project('test_reorder') + pa = self.new_project('test_reorder') p1 = pa.create_project("1") p2 = pa.create_project("2") pa.resource.refresh() @@ -71,7 +70,7 @@ def test_move_dataset(self): username_2 = os.environ['SCRUNCH_USER2'] password_2 = os.environ['SCRUNCH_PASS2'] fo = get_user(username_2) - fo_site = connect(fo.email, password_2, self.HOST) + fo_site = connect(fo.email, password_2, self.host) # These two datasets are created by the default logged user _ds1 = self.site.datasets.create(shoji_entity_wrapper({ @@ -94,7 +93,7 @@ def test_move_dataset(self): ds2.add_user(fo, edit=True) # Create a hierarchy A -> B - pa = new_project("test_move_dataset_A") + pa = self.new_project("test_move_dataset_A") pa.move_here([ds1]) # Put ds1 in A pb = pa.create_project("test_move_dataset_B") @@ -119,6 +118,6 @@ def test_move_dataset(self): self.assertEqual(ds2.resource.project.self, pb.url) def test_execute_script(self): - pa = new_project("test_run_script") + pa = self.new_project("test_run_script") # Successful server execution does not raise. Method returns None on OK assert pa.execute("NOOP;") is None