|
10 | 10 | class TestCreateTileClassificationProject(unittest.TestCase): |
11 | 11 | def setUp(self): |
12 | 12 | self.tutorial_id = set_up.create_test_tutorial_draft( |
13 | | - "tile_classification", |
14 | | - "tile_classification", |
| 13 | + "street", |
| 14 | + "street", |
15 | 15 | "test_tile_classification_tutorial", |
16 | 16 | ) |
17 | 17 |
|
18 | 18 | self.project_id = set_up.create_test_project_draft( |
19 | | - "tile_classification", |
20 | | - "tile_classification", |
| 19 | + "street", |
| 20 | + "street", |
21 | 21 | "test_tile_classification_tutorial", |
22 | 22 | tutorial_id=self.tutorial_id, |
23 | 23 | ) |
24 | 24 | create_directories() |
25 | 25 |
|
26 | 26 | def tearDown(self): |
27 | | - tear_down.delete_test_data(self.project_id) |
| 27 | + tear_down.delete_test_data(self.project_id, self.tutorial_id) |
28 | 28 |
|
29 | 29 | def test_create_tile_classification_project(self): |
30 | 30 | runner = CliRunner() |
| 31 | + runner.invoke(mapswipe_workers.run_create_tutorials, catch_exceptions=False) |
31 | 32 | runner.invoke(mapswipe_workers.run_create_projects, catch_exceptions=False) |
32 | 33 |
|
33 | | - pg_db = auth.postgresDB() |
34 | | - query = "SELECT project_id FROM projects WHERE project_id = %s" |
35 | | - result = pg_db.retr_query(query, [self.project_id])[0][0] |
36 | | - self.assertEqual(result, self.project_id) |
37 | | - |
38 | | - query = """ |
39 | | - SELECT project_id |
40 | | - FROM projects |
41 | | - WHERE project_id = %s |
42 | | - and project_type_specifics::jsonb ? 'customOptions' |
43 | | - """ |
44 | | - result = pg_db.retr_query(query, [self.project_id])[0][0] |
45 | | - self.assertEqual(result, self.project_id) |
46 | | - |
47 | | - query = "SELECT count(*) FROM groups WHERE project_id = %s" |
48 | | - result = pg_db.retr_query(query, [self.project_id])[0][0] |
49 | | - self.assertEqual(result, 20) |
50 | | - |
51 | | - query = "SELECT count(*) FROM tasks WHERE project_id = %s" |
52 | | - result = pg_db.retr_query(query, [self.project_id])[0][0] |
53 | | - self.assertEqual(result, 5040) |
54 | | - |
55 | 34 | fb_db = auth.firebaseDB() |
56 | 35 | ref = fb_db.reference(f"/v2/projects/{self.project_id}") |
57 | | - result = ref.get(shallow=True) |
58 | | - self.assertIsNotNone(result) |
| 36 | + result = ref.get() |
| 37 | + self.assertEqual(result["tutorialId"], self.tutorial_id) |
59 | 38 |
|
60 | | - ref = fb_db.reference(f"/v2/groups/{self.project_id}") |
| 39 | + ref = fb_db.reference(f"/v2/projects/{self.tutorial_id}") |
61 | 40 | result = ref.get(shallow=True) |
62 | | - self.assertEqual(len(result), 20) |
63 | | - |
64 | | - # Tile classification projects do not have tasks in Firebase |
65 | | - ref = fb_db.reference(f"/v2/tasks/{self.project_id}") |
66 | | - result = ref.get(shallow=True) |
67 | | - self.assertIsNone(result) |
68 | | - |
69 | | - ref = fb_db.reference(f"/v2/projects/{self.project_id}/tutorialId") |
70 | | - result = ref.get(shallow=True) |
71 | | - self.assertEqual(self.tutorial_id, result) |
| 41 | + self.assertIsNotNone(result) |
72 | 42 |
|
73 | 43 |
|
74 | 44 | if __name__ == "__main__": |
|
0 commit comments