Skip to content

Commit

Permalink
[qa] fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanBldy committed Nov 29, 2024
1 parent 71e99e2 commit b16bf86
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 33 deletions.
4 changes: 2 additions & 2 deletions tests/projects/test_route_open_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def test_add_team_member(self):
"data/projects/%s/team" % self.project_id,
{"person_id": self.person_id},
)
project = projects_service.get_project_with_relations(self.project_id)
project = projects_service.get_project(self.project_id, relations=True)
self.assertEqual(project["team"], [str(self.person_id)])

def test_remove_team_member(self):
Expand All @@ -33,5 +33,5 @@ def test_remove_team_member(self):
self.delete(
"data/projects/%s/team/%s" % (self.project_id, self.person_id)
)
project = projects_service.get_project_with_relations(self.project_id)
project = projects_service.get_project(self.project_id, relations=True)
self.assertEqual(project["team"], [])
10 changes: 8 additions & 2 deletions tests/services/test_assets_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,10 @@ def test_add_asset_link(self):
self.generate_fixture_asset_types()
self.generate_fixture_asset_character()
assets_service.add_asset_link(self.asset.id, self.asset_character.id)
asset = assets_service.get_asset_with_relations(self.asset.id)
asset = assets_service.get_asset(
self.asset.id,
relations=True,
)
self.assertEqual(
asset["entities_out"][0], str(self.asset_character.id)
)
Expand All @@ -198,5 +201,8 @@ def test_remove_asset_link(self):
assets_service.remove_asset_link(
self.asset.id, self.asset_character.id
)
asset = assets_service.get_asset_with_relations(self.asset.id)
asset = assets_service.get_asset(
self.asset.id,
relations=True,
)
self.assertEqual(len(asset["entities_out"]), 0)
16 changes: 8 additions & 8 deletions tests/services/test_projects_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,22 +92,22 @@ def test_update_project(self):
def test_add_team_member(self):
self.generate_fixture_person()
projects_service.add_team_member(self.project.id, self.person.id)
project = projects_service.get_project_with_relations(self.project.id)
project = projects_service.get_project(self.project.id, relations=True)
self.assertEqual(project["team"], [str(self.person.id)])

def test_remove_team_member(self):
self.generate_fixture_person()
projects_service.add_team_member(self.project.id, self.person.id)
projects_service.remove_team_member(self.project.id, self.person.id)
project = projects_service.get_project_with_relations(self.project.id)
project = projects_service.get_project(self.project.id, relations=True)
self.assertEqual(project["team"], [])

def test_add_asset_type_setting(self):
self.generate_fixture_asset_type()
projects_service.add_asset_type_setting(
self.project.id, self.asset_type.id
)
project = projects_service.get_project_with_relations(self.project.id)
project = projects_service.get_project(self.project.id, relations=True)
self.assertEqual(project["asset_types"], [str(self.asset_type.id)])

def test_remove_asset_type(self):
Expand All @@ -118,7 +118,7 @@ def test_remove_asset_type(self):
projects_service.remove_asset_type_setting(
self.project.id, self.asset_type.id
)
project = projects_service.get_project_with_relations(self.project.id)
project = projects_service.get_project(self.project.id, relations=True)
self.assertEqual(project["asset_types"], [])

def test_add_task_type_setting(self):
Expand All @@ -127,7 +127,7 @@ def test_add_task_type_setting(self):
projects_service.add_task_type_setting(
self.project.id, self.task_type.id
)
project = projects_service.get_project_with_relations(self.project.id)
project = projects_service.get_project(self.project.id, relations=True)
self.assertEqual(project["task_types"], [str(self.task_type.id)])

def test_remove_task_type(self):
Expand All @@ -139,15 +139,15 @@ def test_remove_task_type(self):
projects_service.remove_task_type_setting(
self.project.id, self.task_type.id
)
project = projects_service.get_project_with_relations(self.project.id)
project = projects_service.get_project(self.project.id, relations=True)
self.assertEqual(project["task_types"], [])

def test_add_task_status_setting(self):
self.generate_fixture_task_status()
projects_service.add_task_status_setting(
self.project.id, self.task_status.id
)
project = projects_service.get_project_with_relations(self.project.id)
project = projects_service.get_project(self.project.id, relations=True)
self.assertEqual(project["task_statuses"], [str(self.task_status.id)])

def test_remove_task_status(self):
Expand All @@ -158,7 +158,7 @@ def test_remove_task_status(self):
projects_service.remove_task_status_setting(
self.project.id, self.task_status.id
)
project = projects_service.get_project_with_relations(self.project.id)
project = projects_service.get_project(self.project.id, relations=True)
self.assertEqual(project["task_statuses"], [])

def test_add_asset_metadata_descriptor(self):
Expand Down
2 changes: 1 addition & 1 deletion tests/services/test_tasks_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ def test_clear_assignation(self):
task_id = self.task.id
tasks_service.assign_task(self.task.id, self.person.id)
tasks_service.clear_assignation(task_id)
task = tasks_service.get_task_with_relations(task_id)
task = tasks_service.get_task(task_id, relations=True)
self.assertEqual(len(task["assignees"]), 0)

def test_get_tasks_for_person(self):
Expand Down
2 changes: 1 addition & 1 deletion tests/services/test_user_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def test_check_project_access(self):
projects_service.add_team_member(
str(self.project.id), str(self.get_current_user_raw().id)
)
projects_service.get_project_with_relations(self.project_id)
projects_service.get_project(self.project_id, relations=True)
self.assertTrue(
user_service.check_project_access(str(self.project_id))
)
Expand Down
5 changes: 4 additions & 1 deletion tests/source/shotgun/test_shotgun_import_assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ def test_import_asset(self):

assets = sorted(self.assets, key=lambda x: x["name"])
asset = assets[0]
asset = assets_service.get_asset_with_relations(asset["id"])
asset = assets_service.get_asset(
asset["id"],
relations=True,
)
project = Project.get_by(shotgun_id=sg_asset["project"]["id"])
self.assertEqual(asset["description"], sg_asset["description"])
self.assertEqual(asset["shotgun_id"], sg_asset["id"])
Expand Down
5 changes: 4 additions & 1 deletion tests/source/shotgun/test_shotgun_import_shot.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ def test_import_shot(self):
self.assertEqual(len(self.shots), 1)

shot = self.shots[0]
shot = shots_service.get_shot_with_relations(shot["id"])
shot = shots_service.get_shot(
shot["id"],
relations=True,
)
sequence = Entity.get_by(
shotgun_id=self.sg_shot["sg_sequence"]["id"],
entity_type_id=shots_service.get_sequence_type()["id"],
Expand Down
5 changes: 4 additions & 1 deletion tests/source/shotgun/test_shotgun_import_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ def test_import_task(self):
self.assertEqual(len(self.tasks), 1)

task = self.tasks[0]
task = tasks_service.get_task_with_relations(task["id"])
task = tasks_service.get_task(
task["id"],
relations=True,
)
project = Project.get_by(name=self.sg_task["project"]["name"])
task_type = TaskType.get_by(name=self.sg_task["step"]["name"])
task_status = TaskStatus.get_by(
Expand Down
20 changes: 12 additions & 8 deletions tests/source/shotgun/test_shotgun_import_teams.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ def test_import_project_connections(self):
self.load_fixture("projects")
self.load_fixture("projectconnections")
projects = self.get("data/projects")
project = projects_service.get_project_with_relations(
projects[0]["id"]
project = projects_service.get_project(
projects[0]["id"],
relations=True,
)
self.assertEqual(len(project["team"]), 1)
project = projects_service.get_project_with_relations(
projects[1]["id"]
project = projects_service.get_project(
projects[1]["id"],
relations=True,
)
self.assertEqual(len(project["team"]), 2)

Expand All @@ -26,8 +28,9 @@ def test_import_projects_twice(self):
self.load_fixture("projectconnections")
self.load_fixture("projectconnections")
projects = self.get("data/projects")
project = projects_service.get_project_with_relations(
projects[0]["id"]
project = projects_service.get_project(
projects[0]["id"],
relations=True,
)
self.assertEqual(len(project["team"]), 2)

Expand All @@ -46,7 +49,8 @@ def test_import_project_connection(self):
self.assertEqual(len(self.projects), 1)

projects = self.get("data/projects")
project = projects_service.get_project_with_relations(
projects[1]["id"]
project = projects_service.get_project(
projects[1]["id"],
relations=True,
)
self.assertEqual(len(project["team"]), 1)
16 changes: 8 additions & 8 deletions tests/tasks/test_route_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ def test_multiple_task_assign(self):
data = {"task_ids": [task_id, shot_task_id]}
self.put("/actions/persons/%s/assign" % person_id, data)

task = tasks_service.get_task_with_relations(task_id)
task = tasks_service.get_task(task_id, relations=True)
self.assertEqual(len(task["assignees"]), 1)
task = tasks_service.get_task_with_relations(shot_task_id)
task = tasks_service.get_task(shot_task_id, relations=True)
self.assertEqual(len(task["assignees"]), 1)
notifications = notifications_service.get_last_notifications()
self.assertEqual(len(notifications), 2)
Expand All @@ -143,15 +143,15 @@ def test_multiple_task_assign_artist(self):
self.put("/actions/tasks/clear-assignation", data)
self.log_in_cg_artist()
self.put("/actions/persons/%s/assign" % person_id, data)
task = tasks_service.get_task_with_relations(task_id)
task = tasks_service.get_task(task_id, relations=True)
self.assertEqual(len(task["assignees"]), 0)
task = tasks_service.get_task_with_relations(shot_task_id)
task = tasks_service.get_task(shot_task_id, relations=True)
self.assertEqual(len(task["assignees"]), 0)
persons_service.add_to_department(department_id, person_id)
self.put("/actions/persons/%s/assign" % person_id, data)
task = tasks_service.get_task_with_relations(task_id)
task = tasks_service.get_task(task_id, relations=True)
self.assertEqual(len(task["assignees"]), 0)
task = tasks_service.get_task_with_relations(shot_task_id)
task = tasks_service.get_task(shot_task_id, relations=True)
self.assertEqual(len(task["assignees"]), 0)

def test_clear_assignation(self):
Expand All @@ -164,9 +164,9 @@ def test_clear_assignation(self):
data = {"task_ids": [task_id, shot_task_id]}
self.put("/actions/tasks/clear-assignation", data)

task = tasks_service.get_task_with_relations(task_id)
task = tasks_service.get_task(task_id, relations=True)
self.assertEqual(len(task["assignees"]), 0)
task = tasks_service.get_task_with_relations(shot_task_id)
task = tasks_service.get_task(shot_task_id, relations=True)
self.assertEqual(len(task["assignees"]), 0)

def test_comment_task(self):
Expand Down

0 comments on commit b16bf86

Please sign in to comment.