Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

property trouble, need release #31

Merged
merged 1 commit into from
May 25, 2024
Merged
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
8 changes: 8 additions & 0 deletions src/osmdiff/augmenteddiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,21 @@ def remarks(self):
def timestamp(self):
return self._timestamp

@timestamp.setter
def timestamp(self, value):
self._timestamp = value

@property
def sequence_number(self):
return self._sequence_number

@sequence_number.setter
def sequence_number(self, value):
try:
# value can be none
if value is None:
self._sequence_number = None
return
self._sequence_number = int(value)
except ValueError:
raise ValueError(
Expand Down
4 changes: 4 additions & 0 deletions src/osmdiff/osmchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ def sequence_number(self) -> int:
@sequence_number.setter
def sequence_number(self, value):
try:
# value can be none
if value is None:
self._sequence_number = None
return
self._sequence_number = int(value)
except ValueError:
raise ValueError(
Expand Down
10 changes: 9 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
import pytest
import xml.etree.ElementTree as ET


# Define a fixture to load the XML file
@pytest.fixture
def osmchange_xml_obj():
with open("tests/data/test_osmchange.xml", "r") as fh:
return ET.parse(fh)



# Path to the changeset XML file
@pytest.fixture
def osmchange_file_path():
return "tests/data/test_osmchange.xml"


# Path to the augmented diff XML file
@pytest.fixture
def adiff_file_path():
return "tests/data/test_adiff.xml"
31 changes: 31 additions & 0 deletions tests/test_adiff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from osmdiff import Node, AugmentedDiff, Relation, Way
from typing_extensions import assert_type


class TestAugmentedDiff:
"tests for AugmentedDiff class"

def test_init_augmenteddiff(self):
"Test AugmentedDiff init"
augmenteddiff = AugmentedDiff()
assert_type(augmenteddiff, AugmentedDiff)
assert_type(augmenteddiff.create, list)
assert_type(augmenteddiff.modify, list)
assert_type(augmenteddiff.delete, list)
assert len(augmenteddiff.create) == 0
assert len(augmenteddiff.modify) == 0
assert len(augmenteddiff.delete) == 0

def test_set_sequencenumber(self):
"Sequence number is not defined by default but can be set manually"
augmented_diff = AugmentedDiff()
assert not augmented_diff.sequence_number
augmented_diff.sequence_number = 12345
assert augmented_diff.sequence_number == 12345
augmented_diff.sequence_number = "12345"
assert augmented_diff.sequence_number == 12345

def test_read_changeset_from_xml_file(self, adiff_file_path):
"Test initializing from an XML object"
# not implemented yet
pass