@@ -2545,28 +2545,7 @@ def test_editor(mc: MerginClient):
2545
2545
"removed" : [{"path" : "/folder/project.removed.qgs" }],
2546
2546
}
2547
2547
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
2570
2549
2571
2550
2572
2551
def test_editor_push (mc : MerginClient , mc2 : MerginClient ):
@@ -2591,24 +2570,21 @@ def test_editor_push(mc: MerginClient, mc2: MerginClient):
2591
2570
qgs_file_name = "test.qgs"
2592
2571
txt_file_name = "test.txt"
2593
2572
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 ]
2595
2574
for file in files_to_push :
2596
2575
shutil .copy (os .path .join (TEST_DATA_DIR , file ), project_dir )
2597
2576
# it's possible to push allowed files if editor
2598
2577
mc2 .push_project (project_dir )
2599
2578
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
2601
2580
# find pushed files in server
2602
- assert any (file ["path" ] == qgs_file_name for file in project_info .get ("files" )) is False
2603
2581
assert any (file ["path" ] == txt_file_name for file in project_info .get ("files" )) is True
2604
2582
assert any (file ["path" ] == gpkg_file_name for file in project_info .get ("files" )) is True
2605
2583
pull_changes , push_changes , push_changes_summary = mc .project_status (project_dir )
2606
2584
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 ())
2610
2586
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
2612
2588
shutil .copy (
2613
2589
os .path .join (TEST_DATA_DIR , "inserted_1_A.gpkg" ),
2614
2590
os .path .join (project_dir , gpkg_file_name ),
@@ -2619,19 +2595,20 @@ def test_editor_push(mc: MerginClient, mc2: MerginClient):
2619
2595
assert any (file ["path" ] == gpkg_file_name for file in project_info .get ("files" )) is True
2620
2596
assert any (file ["path" ] == gpkg_file_name for file in push_changes .get ("updated" )) is False
2621
2597
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 )
2628
2608
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
+
2635
2612
# push as owner do cleanup local changes and preparation to conflicited copy simulate
2636
2613
mc .push_project (project_dir )
2637
2614
0 commit comments