You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ebermergen-td/srv/tests/test_auto_id.py

36 lines
793 B
Python

5 years ago
import unittest
from ebermergen.models.auto_id import AutoID
class TestAutoID(unittest.TestCase):
def setUp(self):
AutoID.reset_id()
def test_first_instance(self):
a = AutoID()
self.assertEqual(a.id, 1)
def test_increment(self):
a, b = AutoID(), AutoID()
self.assertEqual(a.id, 1)
self.assertEqual(b.id, 2)
def test_inheritance(self):
class ClassA(AutoID):
pass
class ClassB(AutoID):
pass
a = ClassA()
b = ClassB()
self.assertEqual(a.id, 1)
self.assertEqual(b.id, 1)
a2 = ClassA()
b2 = ClassB()
self.assertEqual(a.id, 1)
self.assertEqual(b.id, 1)
self.assertEqual(a2.id, 2)
self.assertEqual(b2.id, 2)