@@ -2545,28 +2545,7 @@ def test_editor(mc: MerginClient):
25452545 "removed" : [{"path" : "/folder/project.removed.qgs" }],
25462546 }
25472547 qgs_changeset = filter_changes (mc , project_info , qgs_changeset )
2548- assert sum (len (v ) for v in qgs_changeset .values ()) == 0
2549-
2550- mergin_config_changeset = {
2551- "added" : [{"path" : "/.mergin/mergin-config.json" }],
2552- "updated" : [{"path" : "/.mergin/mergin-config.json" }],
2553- "removed" : [{"path" : "/.mergin/mergin-config.json" }],
2554- }
2555- mergin_config_changeset = filter_changes (mc , project_info , mergin_config_changeset )
2556- assert sum (len (v ) for v in mergin_config_changeset .values ()) == 0
2557-
2558- gpkg_changeset = {
2559- "added" : [{"path" : "/.mergin/data.gpkg" }],
2560- "updated" : [
2561- {"path" : "/.mergin/conflict-data.gpkg" },
2562- {"path" : "/.mergin/data.gpkg" , "diff" : {}},
2563- ],
2564- "removed" : [{"path" : "/.mergin/data.gpkg" }],
2565- }
2566- gpkg_changeset = filter_changes (mc , project_info , gpkg_changeset )
2567- assert sum (len (v ) for v in gpkg_changeset .values ()) == 2
2568- assert gpkg_changeset ["added" ][0 ]["path" ] == "/.mergin/data.gpkg"
2569- assert gpkg_changeset ["updated" ][0 ]["path" ] == "/.mergin/data.gpkg"
2548+ assert sum (len (v ) for v in qgs_changeset .values ()) == 2
25702549
25712550
25722551def test_editor_push (mc : MerginClient , mc2 : MerginClient ):
@@ -2591,24 +2570,21 @@ def test_editor_push(mc: MerginClient, mc2: MerginClient):
25912570 qgs_file_name = "test.qgs"
25922571 txt_file_name = "test.txt"
25932572 gpkg_file_name = "base.gpkg"
2594- files_to_push = [qgs_file_name , txt_file_name , gpkg_file_name ]
2573+ files_to_push = [txt_file_name , gpkg_file_name ]
25952574 for file in files_to_push :
25962575 shutil .copy (os .path .join (TEST_DATA_DIR , file ), project_dir )
25972576 # it's possible to push allowed files if editor
25982577 mc2 .push_project (project_dir )
25992578 project_info = mc2 .project_info (test_project_fullname )
2600- assert len (project_info .get ("files" )) == len (files_to_push ) - 1 # ggs is not pushed
2579+ assert len (project_info .get ("files" )) == len (files_to_push ) # ggs is not pushed
26012580 # find pushed files in server
2602- assert any (file ["path" ] == qgs_file_name for file in project_info .get ("files" )) is False
26032581 assert any (file ["path" ] == txt_file_name for file in project_info .get ("files" )) is True
26042582 assert any (file ["path" ] == gpkg_file_name for file in project_info .get ("files" )) is True
26052583 pull_changes , push_changes , push_changes_summary = mc .project_status (project_dir )
26062584 assert not sum (len (v ) for v in pull_changes .values ())
2607- assert sum (len (v ) for v in push_changes .values ()) == 1
2608- # ggs is still waiting to push
2609- assert any (file ["path" ] == qgs_file_name for file in push_changes .get ("added" )) is True
2585+ assert not sum (len (v ) for v in push_changes .values ())
26102586
2611- # editor is trying to psuh row to gpkg file -> it's possible
2587+ # editor is trying to push row to gpkg file -> it's possible
26122588 shutil .copy (
26132589 os .path .join (TEST_DATA_DIR , "inserted_1_A.gpkg" ),
26142590 os .path .join (project_dir , gpkg_file_name ),
@@ -2619,19 +2595,20 @@ def test_editor_push(mc: MerginClient, mc2: MerginClient):
26192595 assert any (file ["path" ] == gpkg_file_name for file in project_info .get ("files" )) is True
26202596 assert any (file ["path" ] == gpkg_file_name for file in push_changes .get ("updated" )) is False
26212597
2622- # editor is trying to insert tables to gpkg file
2623- shutil .copy (
2624- os .path .join (TEST_DATA_DIR , "two_tables.gpkg" ),
2625- os .path .join (project_dir , gpkg_file_name ),
2626- )
2627- mc2 .push_project (project_dir )
2598+ # add qgis file as editor
2599+ shutil .copy (os .path .join (TEST_DATA_DIR , qgs_file_name ), project_dir )
2600+ with pytest .raises (ClientError , match = f"You do not have permissions for this project" ):
2601+ mc2 .push_project (project_dir )
2602+ mc .push_project (project_dir )
2603+
2604+ # editor is trying to update qgis file
2605+ with open (os .path .join (project_dir , qgs_file_name ), "a" ) as f :
2606+ f .write ("Editor is here!" )
2607+ project_info = mc2 .project_info (test_project_fullname )
26282608 pull_changes , push_changes , push_changes_summary = mc .project_status (project_dir )
2629- assert not sum (len (v ) for v in pull_changes .values ())
2630- # gpkg was filter by editor_handler in push_project, because new tables added
2631- assert sum (len (v ) for v in push_changes .values ()) == 2
2632- # ggs and gpkg are still waiting to push
2633- assert any (file ["path" ] == qgs_file_name for file in push_changes .get ("added" )) is True
2634- assert any (file ["path" ] == gpkg_file_name for file in push_changes .get ("updated" )) is True
2609+ # ggs is still waiting to push
2610+ assert any (file ["path" ] == qgs_file_name for file in push_changes .get ("updated" )) is True
2611+
26352612 # push as owner do cleanup local changes and preparation to conflicited copy simulate
26362613 mc .push_project (project_dir )
26372614
0 commit comments