Skip to content

Commit

Permalink
feat: added return to original string form for package
Browse files Browse the repository at this point in the history
  • Loading branch information
RonTamG committed Jan 6, 2024
1 parent b273de0 commit 2c3abf3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ def __init__(self, package_data) -> None:
else:
self.provides = []

self.all_fields = values

def __equ__(self, other) -> bool:
if isinstance(other, Package):
if self.name == other.name:
Expand All @@ -61,3 +63,6 @@ def __lt__(self, other) -> bool:
return self.name < other.name
else:
raise NotImplementedError

def __str__(self) -> str:
return "\n".join([f"{key}: {value}" for key, value in self.all_fields.items()])
8 changes: 8 additions & 0 deletions tests/test_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ def test_package_without_provides_field_should_have_empty_provides_list():
assert len(package.provides) == 0


def test_package_should_return_to_original_string():
data = valid_package_data()

package = Package(data)

assert str(package) == data


def valid_package_data():
return """Package: python3
Source: python3-defaults (3.11.4-5)
Expand Down

0 comments on commit 2c3abf3

Please sign in to comment.