|
| 1 | +import unittest |
| 2 | + |
| 3 | +from click.testing import CliRunner |
| 4 | + |
| 5 | +from mapswipe_workers import auth, mapswipe_workers |
| 6 | +from mapswipe_workers.utils.create_directories import create_directories |
| 7 | +from tests.integration import set_up, tear_down |
| 8 | + |
| 9 | + |
| 10 | +class TestCreateConflationProject(unittest.TestCase): |
| 11 | + def setUp(self): |
| 12 | + self.project_id = set_up.create_test_project_draft("conflation", "conflation") |
| 13 | + |
| 14 | + create_directories() |
| 15 | + |
| 16 | + def tearDown(self): |
| 17 | + tear_down.delete_test_data(self.project_id) |
| 18 | + |
| 19 | + def test_create_footprint_project(self): |
| 20 | + runner = CliRunner() |
| 21 | + result = runner.invoke( |
| 22 | + mapswipe_workers.run_create_projects, catch_exceptions=False |
| 23 | + ) |
| 24 | + if result.exit_code != 0: |
| 25 | + raise result.exception |
| 26 | + pg_db = auth.postgresDB() |
| 27 | + |
| 28 | + query = """ |
| 29 | + SELECT project_id, project_type_specifics |
| 30 | + FROM projects |
| 31 | + WHERE project_id = %s |
| 32 | + """ |
| 33 | + result = pg_db.retr_query(query, [self.project_id])[0] |
| 34 | + self.assertEqual(result[0], self.project_id) |
| 35 | + |
| 36 | + fb_db = auth.firebaseDB() |
| 37 | + ref = fb_db.reference(f"/v2/projects/{self.project_id}") |
| 38 | + result = ref.get(shallow=True) |
| 39 | + self.assertIsNotNone(result) |
| 40 | + |
| 41 | + ref = fb_db.reference(f"/v2/groups/{self.project_id}") |
| 42 | + result = ref.get(shallow=True) |
| 43 | + self.assertIsNotNone(result) |
| 44 | + |
| 45 | + # Footprint projects have tasks in Firebase |
| 46 | + ref = fb_db.reference(f"/v2/tasks/{self.project_id}") |
| 47 | + result = ref.get(shallow=True) |
| 48 | + self.assertIsNotNone(result) |
| 49 | + |
| 50 | + |
| 51 | +if __name__ == "__main__": |
| 52 | + unittest.main() |
0 commit comments