mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-06 22:54:16 +02:00
[api] refactoring: implementing __eq__ and __hash__ for PackageUpdate
This commit is contained in:
0
tests/api/__init__.py
Normal file
0
tests/api/__init__.py
Normal file
0
tests/api/abstract/__init__.py
Normal file
0
tests/api/abstract/__init__.py
Normal file
18
tests/api/abstract/test_model.py
Normal file
18
tests/api/abstract/test_model.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from unittest import TestCase
|
||||
|
||||
from bauh.api.abstract.model import PackageUpdate
|
||||
|
||||
|
||||
class PackageUpdateTest(TestCase):
|
||||
|
||||
def test__hash__return_same_hash_for_equal_packages(self):
|
||||
a = PackageUpdate(pkg_id='a', name='b', version='c', pkg_type='d')
|
||||
b = PackageUpdate(pkg_id='a', name='b', version='c', pkg_type='d')
|
||||
self.assertEqual(a, b)
|
||||
self.assertEqual(hash(a), hash(b))
|
||||
|
||||
def test__hash__return_different_hash_for_not_equal_packages(self):
|
||||
a = PackageUpdate(pkg_id='a', name='b', version='c', pkg_type='d')
|
||||
b = PackageUpdate(pkg_id='a', name='b', version='c', pkg_type='e')
|
||||
self.assertNotEqual(a, b)
|
||||
self.assertNotEqual(hash(a), hash(b))
|
||||
Reference in New Issue
Block a user