diff --git a/mapswipe_workers/mapswipe_workers/project_types/base/project.py b/mapswipe_workers/mapswipe_workers/project_types/base/project.py index f48489c4d..fc736b043 100644 --- a/mapswipe_workers/mapswipe_workers/project_types/base/project.py +++ b/mapswipe_workers/mapswipe_workers/project_types/base/project.py @@ -386,7 +386,15 @@ def save_to_postgres(self, project, groups, groupsOfTasks): """ query_insert_raw_groups = """ - INSERT INTO groups + INSERT INTO groups ( + project_id, + group_id, + number_of_tasks, + finished_count, + required_count, + progress, + project_type_specifics + ) SELECT project_id, group_id, diff --git a/mapswipe_workers/tests/integration/set_up.py b/mapswipe_workers/tests/integration/set_up.py index 379fb7408..3a7a88435 100644 --- a/mapswipe_workers/tests/integration/set_up.py +++ b/mapswipe_workers/tests/integration/set_up.py @@ -10,6 +10,7 @@ import json import os import time +from typing import List, Union from mapswipe_workers import auth @@ -32,7 +33,7 @@ def set_firebase_test_data( def set_postgres_test_data( - project_type: str, data_type: str, fixture_name: str + project_type: str, data_type: str, fixture_name: str, columns: Union[None, List[str]] = None ) -> None: test_dir = os.path.dirname(__file__) fixture_name = fixture_name + ".csv" @@ -41,7 +42,7 @@ def set_postgres_test_data( ) pg_db = auth.postgresDB() with open(file_path) as test_file: - pg_db.copy_from(test_file, data_type) + pg_db.copy_from(test_file, data_type, columns=columns) def create_test_project( @@ -50,9 +51,21 @@ def create_test_project( """Create a test data in Firebase and Posgres.""" project_id = "test_{0}".format(fixture_name) - for data_type in ["projects", "groups", "tasks"]: + for data_type, columns in [ + ("projects", None), + ("groups", [ + "project_id", + "group_id", + "number_of_tasks", + "finished_count", + "required_count", + "progress", + "project_type_specifics", + ]), + ("tasks", None), + ]: set_firebase_test_data(project_type, data_type, fixture_name, project_id) - set_postgres_test_data(project_type, data_type, fixture_name) + set_postgres_test_data(project_type, data_type, fixture_name, columns=columns) if results: set_firebase_test_data(project_type, "users", "user", project_id) diff --git a/mapswipe_workers/tests/integration/test_get_results_real_project.py b/mapswipe_workers/tests/integration/test_get_results_real_project.py index 7da01675d..486696d10 100644 --- a/mapswipe_workers/tests/integration/test_get_results_real_project.py +++ b/mapswipe_workers/tests/integration/test_get_results_real_project.py @@ -16,15 +16,23 @@ def setUp(self): fixture_name = "build_area_sandoa" self.project_id = "-NFNr55R_LYJvxP7wmte" - for data_type in [ - "projects", - "groups", - "tasks", - "users", - "mapping_sessions", - "mapping_sessions_results", + for data_type, columns in [ + ("projects", None), + ("groups", [ + "project_id", + "group_id", + "number_of_tasks", + "finished_count", + "required_count", + "progress", + "project_type_specifics", + ]), + ("tasks", None), + ("users", None), + ("mapping_sessions", None), + ("mapping_sessions_results", None), ]: - set_up.set_postgres_test_data(project_type, data_type, fixture_name) + set_up.set_postgres_test_data(project_type, data_type, fixture_name, columns=columns) self.results_filename = os.path.join( tempfile._get_default_tempdir(), f"results_{self.project_id}.csv.gz" diff --git a/mapswipe_workers/tests/integration/test_user_stats.py b/mapswipe_workers/tests/integration/test_user_stats.py index 8c336a20e..dcb0a2f40 100644 --- a/mapswipe_workers/tests/integration/test_user_stats.py +++ b/mapswipe_workers/tests/integration/test_user_stats.py @@ -21,15 +21,23 @@ def setUp(self): fixture_name = "osm_validation_malawi" self.project_id = "-NEaU7GXxWRqKaFUYp_2" - for data_type in [ - "projects", - "groups", - "tasks", - "users", - "mapping_sessions", - "mapping_sessions_results", + for data_type, columns in [ + ("projects", None), + ("groups", [ + "project_id", + "group_id", + "number_of_tasks", + "finished_count", + "required_count", + "progress", + "project_type_specifics", + ]), + ("tasks", None), + ("users", None), + ("mapping_sessions", None), + ("mapping_sessions_results", None), ]: - set_up.set_postgres_test_data(project_type, data_type, fixture_name) + set_up.set_postgres_test_data(project_type, data_type, fixture_name, columns=columns) self.results_filename = os.path.join( tempfile._get_default_tempdir(), f"results_{self.project_id}.csv.gz"