22import pytest
33from unittest .mock import patch
44
5- from ..local_changes import ChangesValidationError , FileChange , LocalPojectChanges , MAX_UPLOAD_CHANGES
5+ from ..local_changes import ChangesValidationError , FileChange , LocalProjectChanges , MAX_UPLOAD_CHANGES
66
77
88def test_local_changes_from_dict ():
9- """Test generating LocalChanges from a dictionary."""
9+ """Test generating LocalProjectChanges from a dictionary."""
1010 changes_dict = {
1111 "added" : [{"path" : "file1.txt" , "checksum" : "abc123" , "size" : 1024 , "mtime" : datetime .now ()}],
1212 "updated" : [{"path" : "file2.txt" , "checksum" : "xyz789" , "size" : 2048 , "mtime" : datetime .now ()}],
@@ -37,7 +37,7 @@ def test_local_changes_from_dict():
3737 updated = [FileChange (** file ) for file in changes_dict ["updated" ]]
3838 removed = [FileChange (** file ) for file in changes_dict ["removed" ]]
3939
40- local_changes = LocalPojectChanges (added = added , updated = updated , removed = removed )
40+ local_changes = LocalProjectChanges (added = added , updated = updated , removed = removed )
4141
4242 # Assertions
4343 assert len (local_changes .added ) == 1
@@ -74,7 +74,7 @@ def test_local_changes_to_server_payload():
7474 updated = [FileChange (path = "file2.txt" , checksum = "xyz789" , size = 2048 , mtime = datetime .now ())]
7575 removed = [FileChange (path = "file3.txt" , checksum = "lmn456" , size = 512 , mtime = datetime .now ())]
7676
77- local_changes = LocalPojectChanges (added = added , updated = updated , removed = removed )
77+ local_changes = LocalProjectChanges (added = added , updated = updated , removed = removed )
7878 server_request = local_changes .to_server_payload ()
7979
8080 assert "added" in server_request
@@ -85,33 +85,33 @@ def test_local_changes_to_server_payload():
8585 assert server_request ["removed" ][0 ]["path" ] == "file3.txt"
8686
8787
88- def test_local_changes_update_chunks ():
88+ def test_local_changes_update_chunk_ids ():
8989 """Test the update_chunks method of LocalChanges."""
9090 added = [
9191 FileChange (path = "file1.txt" , checksum = "abc123" , size = 1024 , mtime = datetime .now (), chunks = ["abc123" ]),
9292 FileChange (path = "file2.txt" , checksum = "abc123" , size = 1024 , mtime = datetime .now (), chunks = ["abc123" ]),
9393 ]
9494 updated = [FileChange (path = "file2.txt" , checksum = "xyz789" , size = 2048 , mtime = datetime .now (), chunks = ["xyz789" ])]
9595
96- local_changes = LocalPojectChanges (added = added , updated = updated )
96+ local_changes = LocalProjectChanges (added = added , updated = updated )
9797 chunks = [("abc123" , "chunk1" ), ("abc123" , "chunk1" ), ("xyz789" , "chunk2" )]
9898
99- local_changes .update_chunks (chunks )
99+ local_changes .update_chunk_ids (chunks )
100100
101101 assert local_changes .added [0 ].chunks == ["chunk1" ]
102102 assert local_changes .added [1 ].chunks == ["chunk1" ]
103103 assert local_changes .updated [0 ].chunks == ["chunk2" ]
104104
105105
106106def test_local_changes_get_upload_changes ():
107- """Test the get_upload_changes method of LocalChanges ."""
107+ """Test the get_upload_changes method of LocalProjectChanges ."""
108108 # Create sample LocalChange instances
109109 added = [FileChange (path = "file1.txt" , checksum = "abc123" , size = 1024 , mtime = datetime .now ())]
110110 updated = [FileChange (path = "file2.txt" , checksum = "xyz789" , size = 2048 , mtime = datetime .now ())]
111111 removed = [FileChange (path = "file3.txt" , checksum = "lmn456" , size = 512 , mtime = datetime .now ())]
112112
113113 # Initialize LocalChanges with added, updated, and removed changes
114- local_changes = LocalPojectChanges (added = added , updated = updated , removed = removed )
114+ local_changes = LocalProjectChanges (added = added , updated = updated , removed = removed )
115115
116116 # Call get_upload_changes
117117 upload_changes = local_changes .get_upload_changes ()
@@ -143,7 +143,7 @@ def test_local_changes_post_init_validation_media():
143143 # Initialize LocalProjectChanges
144144 with patch ("mergin.local_changes.MAX_UPLOAD_MEDIA_SIZE" , SIZE_LIMIT_BYTES ):
145145 with pytest .raises (ChangesValidationError , match = "Some files exceed" ) as err :
146- LocalPojectChanges (added = added , updated = updated )
146+ LocalProjectChanges (added = added , updated = updated )
147147 print (err .value .invalid_changes )
148148 assert len (err .value .invalid_changes ) == 1
149149 assert "file2.jpg" == err .value .invalid_changes [0 ].path
@@ -179,14 +179,14 @@ def test_local_changes_post_init_validation_gpgkg():
179179 # Initialize LocalProjectChanges
180180 with patch ("mergin.local_changes.MAX_UPLOAD_VERSIONED_SIZE" , SIZE_LIMIT_BYTES ):
181181 with pytest .raises (ChangesValidationError ) as err :
182- LocalPojectChanges (added = added , updated = updated )
182+ LocalProjectChanges (added = added , updated = updated )
183183 assert len (err .value .invalid_changes ) == 1
184184 assert "file2.gpkg" == err .value .invalid_changes [0 ].path
185185 assert err .value .invalid_changes [0 ].size == LARGE_FILE_SIZE
186186
187187
188188def test_local_changes_post_init ():
189- """Test the __post_init__ method of LocalChanges ."""
189+ """Test the __post_init__ method of LocalProjectChanges ."""
190190 # Define constants
191191 ADDED_COUNT = 80
192192 UPDATED_COUNT = 21
@@ -204,7 +204,7 @@ def test_local_changes_post_init():
204204 ]
205205
206206 # Initialize LocalProjectChanges
207- local_changes = LocalPojectChanges (added = added , updated = updated )
207+ local_changes = LocalProjectChanges (added = added , updated = updated )
208208
209209 # Assertions
210210 assert len (local_changes .added ) == ADDED_COUNT # All added changes are included
0 commit comments