Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions mergin/merginproject.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,8 @@ def compare_file_sets(self, origin, current):

:Example:

>>> origin = [{'checksum': '08b0e8caddafe74bf5c11a45f65cedf974210fed', 'path': 'base.gpkg', 'size': 2793, 'mtime': '2019-08-26T11:08:34.051221+02:00'}]
>>> current = [{'checksum': 'c9a4fd2afd513a97aba19d450396a4c9df8b2ba4', 'path': 'test.qgs', 'size': 31980, 'mtime': '2019-08-26T11:09:30.051221+02:00'}]
>>> origin = [{'checksum': '08b0e8caddafe74bf5c11a45f65cedf974210fed', 'path': 'base.gpkg', 'size': 2793, 'mtime': '2019-08-26T11:08:34.051221+02:00'}] # pragma: allowlist secret
>>> current = [{'checksum': 'c9a4fd2afd513a97aba19d450396a4c9df8b2ba4', 'path': 'test.qgs', 'size': 31980, 'mtime': '2019-08-26T11:09:30.051221+02:00'}] # pragma: allowlist secret
>>> self.compare_file_sets(origin, current)
{"added": [{'checksum': 'c9a4fd2afd513a97aba19d450396a4c9df8b2ba4', 'path': 'test.qgs', 'size': 31980, 'mtime': '2019-08-26T11:09:30.051221+02:00'}], "removed": [[{'checksum': '08b0e8caddafe74bf5c11a45f65cedf974210fed', 'path': 'base.gpkg', 'size': 2793, 'mtime': '2019-08-26T11:08:34.051221+02:00'}]], "renamed": [], "updated": []}

Expand Down
14 changes: 1 addition & 13 deletions mergin/test/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@
import pytest
import pytz
import sqlite3
import glob
from unittest.mock import patch, Mock
from unittest.mock import patch

from unittest.mock import patch, Mock

from .. import InvalidProject
from ..client import (
Expand Down Expand Up @@ -1382,16 +1380,6 @@ def _create_spatial_table(db_file):
cursor.execute("COMMIT;")


def _delete_spatial_table(db_file):
"""Drops spatial table called 'test' in sqlite database. Useful to simulate change of database schema."""
con = sqlite3.connect(db_file)
cursor = con.cursor()
cursor.execute("DROP TABLE poi;")
cursor.execute("DELETE FROM gpkg_geometry_columns WHERE table_name='poi';")
cursor.execute("DELETE FROM gpkg_contents WHERE table_name='poi';")
cursor.execute("COMMIT;")


def _check_test_table(db_file):
"""Checks whether the 'test' table exists and has one row - otherwise fails with an exception."""
assert _get_table_row_count(db_file, "test") == 1
Expand Down
6 changes: 3 additions & 3 deletions mergin/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import tempfile
from enum import Enum
from typing import Optional, Type, Union, ByteString
from .common import ClientError, WorkspaceRole
from .common import ClientError


def generate_checksum(file, chunk_size=4096):
Expand All @@ -20,7 +20,7 @@ def generate_checksum(file, chunk_size=4096):
:param chunk_size: size of chunk
:return: sha1 checksum
"""
checksum = hashlib.sha1()
checksum = hashlib.sha1() # nosec B324 - usedforsecurity=False flag is compatible with python 3.9+
with open(file, "rb") as f:
while True:
chunk = f.read(chunk_size)
Expand Down Expand Up @@ -306,7 +306,7 @@ def get_data_checksum(data: ByteString) -> str:
:param data: data to calculate checksum
:return: sha1 checksum
"""
checksum = hashlib.sha1()
checksum = hashlib.sha1() # nosec B324 - usedforsecurity=False flag is compatible with python 3.9+
checksum.update(data)
return checksum.hexdigest()

Expand Down