|
12 | 12 | TEST_DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'test_data')
|
13 | 13 |
|
14 | 14 |
|
| 15 | +def toggle_geodiff(enabled): |
| 16 | + os.environ['GEODIFF_ENABLED'] = str(enabled) |
| 17 | + |
| 18 | + |
15 | 19 | @pytest.fixture(scope='function')
|
16 | 20 | def mc():
|
17 | 21 | assert SERVER_URL and SERVER_URL.rstrip('/') != 'https://public.cloudmergin.com' and API_USER and USER_PWD
|
@@ -130,7 +134,7 @@ def test_push_pull_changes(mc, parallel):
|
130 | 134 | f.write('Modified')
|
131 | 135 |
|
132 | 136 | # check changes before applied
|
133 |
| - pull_changes, push_changes = mc.project_status(project_dir) |
| 137 | + pull_changes, push_changes, _ = mc.project_status(project_dir) |
134 | 138 | assert not sum(len(v) for v in pull_changes.values())
|
135 | 139 | assert next((f for f in push_changes['added'] if f['path'] == f_added), None)
|
136 | 140 | assert next((f for f in push_changes['removed'] if f['path'] == f_removed), None)
|
@@ -163,7 +167,7 @@ def test_push_pull_changes(mc, parallel):
|
163 | 167 | mc.push_project(project_dir_2)
|
164 | 168 |
|
165 | 169 | # check changes in project_dir_2 before applied
|
166 |
| - pull_changes, push_changes = mc.project_status(project_dir_2) |
| 170 | + pull_changes, push_changes, _ = mc.project_status(project_dir_2) |
167 | 171 | assert next((f for f in pull_changes['added'] if f['path'] == f_added), None)
|
168 | 172 | assert next((f for f in pull_changes['removed'] if f['path'] == f_removed), None)
|
169 | 173 | assert next((f for f in pull_changes['updated'] if f['path'] == f_updated), None)
|
@@ -211,8 +215,6 @@ def test_ignore_files(mc):
|
211 | 215 |
|
212 | 216 | @pytest.mark.parametrize("diffs_limit, push_geodiff_enabled, pull_geodiff_enabled", diff_test_scenarios)
|
213 | 217 | def test_sync_diff(mc, diffs_limit, push_geodiff_enabled, pull_geodiff_enabled):
|
214 |
| - def toggle_geodiff(enabled): |
215 |
| - os.environ['GEODIFF_ENABLED'] = str(enabled) |
216 | 218 |
|
217 | 219 | test_project = f'test_sync_diff_{diffs_limit}_{int(push_geodiff_enabled)}_{int(pull_geodiff_enabled)}'
|
218 | 220 | project = API_USER + '/' + test_project
|
@@ -303,3 +305,26 @@ def toggle_geodiff(enabled):
|
303 | 305 | assert not mp3.geodiff.has_changes(mp.fpath_meta('diff'))
|
304 | 306 | else:
|
305 | 307 | assert os.path.exists(mp.fpath('base.gpkg_conflict_copy'))
|
| 308 | + |
| 309 | + |
| 310 | +def test_list_of_push_changes(mc): |
| 311 | + PUSH_CHANGES_SUMMARY = "{'base.gpkg': {'geodiff_summary': [{'table': 'gpkg_contents', 'insert': 0, 'update': 1, 'delete': 0}, {'table': 'simple', 'insert': 1, 'update': 0, 'delete': 0}]}}" |
| 312 | + |
| 313 | + test_project = 'test_list_of_push_changes' |
| 314 | + project = API_USER + '/' + test_project |
| 315 | + project_dir = os.path.join(TMP_DIR, test_project) # primary project dir for updates |
| 316 | + |
| 317 | + cleanup(mc, project, [project_dir]) |
| 318 | + shutil.copytree(TEST_DATA_DIR, project_dir) |
| 319 | + toggle_geodiff(True) |
| 320 | + mc.create_project(test_project, project_dir) |
| 321 | + |
| 322 | + f_updated = 'base.gpkg' |
| 323 | + mp = MerginProject(project_dir) |
| 324 | + |
| 325 | + shutil.copy(mp.fpath('inserted_1_A.gpkg'), mp.fpath(f_updated)) |
| 326 | + |
| 327 | + pull_changes, push_changes, push_changes_summary = mc.project_status(project_dir) |
| 328 | + assert str(push_changes_summary) == PUSH_CHANGES_SUMMARY |
| 329 | + |
| 330 | + |
0 commit comments