Skip to content

Commit

Permalink
fix bad refactor of test_projects (#460)
Browse files Browse the repository at this point in the history
* fix bad refactor of test_projects

* fix integration tests
  • Loading branch information
aless10 authored Jul 23, 2024
1 parent cf203d8 commit b5b33aa
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
8 changes: 6 additions & 2 deletions integration/test_expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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": [
Expand Down
31 changes: 15 additions & 16 deletions integration/test_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand All @@ -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)
Expand All @@ -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, "|")
Expand All @@ -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()
Expand All @@ -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({
Expand All @@ -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")
Expand All @@ -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

0 comments on commit b5b33aa

Please sign in to comment.