fix: format all code with black
and from now on should not deviate from that...
This commit is contained in:
parent
49f9a0228b
commit
a6bb538ce9
59 changed files with 2762 additions and 2131 deletions
|
@ -18,22 +18,20 @@ else:
|
|||
role.name = "Managers"
|
||||
self.assertEqual(str(role), "Managers")
|
||||
|
||||
|
||||
class TestPermission(TestCase):
|
||||
|
||||
def test_basic(self):
|
||||
perm = model.Permission()
|
||||
self.assertEqual(str(perm), "")
|
||||
perm.permission = 'users.create'
|
||||
perm.permission = "users.create"
|
||||
self.assertEqual(str(perm), "users.create")
|
||||
|
||||
|
||||
class TestUser(TestCase):
|
||||
|
||||
def test_str(self):
|
||||
user = model.User()
|
||||
self.assertEqual(str(user), "")
|
||||
user.username = 'barney'
|
||||
user.username = "barney"
|
||||
self.assertEqual(str(user), "barney")
|
||||
|
||||
def test_str_with_person(self):
|
||||
|
@ -44,7 +42,6 @@ else:
|
|||
user.person = person
|
||||
self.assertEqual(str(user), "Barney Rubble")
|
||||
|
||||
|
||||
class TestUserAPIToken(TestCase):
|
||||
|
||||
def test_str(self):
|
||||
|
|
|
@ -11,35 +11,32 @@ except ImportError:
|
|||
pass
|
||||
else:
|
||||
|
||||
|
||||
class MockUser(mod.Base):
|
||||
__tablename__ = 'mock_user'
|
||||
uuid = mod.uuid_column(sa.ForeignKey('user.uuid'), default=False)
|
||||
__tablename__ = "mock_user"
|
||||
uuid = mod.uuid_column(sa.ForeignKey("user.uuid"), default=False)
|
||||
user = orm.relationship(
|
||||
User,
|
||||
backref=orm.backref('_mock', uselist=False, cascade='all, delete-orphan'))
|
||||
backref=orm.backref("_mock", uselist=False, cascade="all, delete-orphan"),
|
||||
)
|
||||
favorite_color = sa.Column(sa.String(length=100), nullable=False)
|
||||
|
||||
|
||||
class TestWuttaModelBase(TestCase):
|
||||
|
||||
def test_make_proxy(self):
|
||||
self.assertFalse(hasattr(User, 'favorite_color'))
|
||||
MockUser.make_proxy(User, '_mock', 'favorite_color')
|
||||
self.assertTrue(hasattr(User, 'favorite_color'))
|
||||
user = User(favorite_color='green')
|
||||
self.assertEqual(user.favorite_color, 'green')
|
||||
|
||||
self.assertFalse(hasattr(User, "favorite_color"))
|
||||
MockUser.make_proxy(User, "_mock", "favorite_color")
|
||||
self.assertTrue(hasattr(User, "favorite_color"))
|
||||
user = User(favorite_color="green")
|
||||
self.assertEqual(user.favorite_color, "green")
|
||||
|
||||
class TestSetting(TestCase):
|
||||
|
||||
def test_basic(self):
|
||||
setting = mod.Setting()
|
||||
self.assertEqual(str(setting), "")
|
||||
setting.name = 'foo'
|
||||
setting.name = "foo"
|
||||
self.assertEqual(str(setting), "foo")
|
||||
|
||||
|
||||
class TestPerson(TestCase):
|
||||
|
||||
def test_basic(self):
|
||||
|
|
|
@ -17,40 +17,46 @@ else:
|
|||
def test_basic(self):
|
||||
|
||||
class MyBatch(mod.BatchMixin, model.Base):
|
||||
__tablename__ = 'testing_mybatch'
|
||||
__tablename__ = "testing_mybatch"
|
||||
|
||||
model.Base.metadata.create_all(bind=self.session.bind)
|
||||
metadata = sa.MetaData()
|
||||
metadata.reflect(self.session.bind)
|
||||
self.assertIn('testing_mybatch', metadata.tables)
|
||||
self.assertIn("testing_mybatch", metadata.tables)
|
||||
|
||||
batch = MyBatch(id=42, uuid=_uuid.UUID('0675cdac-ffc9-7690-8000-6023de1c8cfd'))
|
||||
self.assertEqual(repr(batch), "MyBatch(uuid=UUID('0675cdac-ffc9-7690-8000-6023de1c8cfd'))")
|
||||
batch = MyBatch(
|
||||
id=42, uuid=_uuid.UUID("0675cdac-ffc9-7690-8000-6023de1c8cfd")
|
||||
)
|
||||
self.assertEqual(
|
||||
repr(batch),
|
||||
"MyBatch(uuid=UUID('0675cdac-ffc9-7690-8000-6023de1c8cfd'))",
|
||||
)
|
||||
self.assertEqual(str(batch), "00000042")
|
||||
self.assertEqual(batch.id_str, "00000042")
|
||||
|
||||
batch2 = MyBatch()
|
||||
self.assertIsNone(batch2.id_str)
|
||||
|
||||
|
||||
class TestBatchRowMixin(DataTestCase):
|
||||
|
||||
def test_basic(self):
|
||||
|
||||
class MyBatch2(mod.BatchMixin, model.Base):
|
||||
__tablename__ = 'testing_mybatch2'
|
||||
__tablename__ = "testing_mybatch2"
|
||||
|
||||
class MyBatchRow2(mod.BatchRowMixin, model.Base):
|
||||
__tablename__ = 'testing_mybatch_row2'
|
||||
__tablename__ = "testing_mybatch_row2"
|
||||
__batch_class__ = MyBatch2
|
||||
|
||||
model.Base.metadata.create_all(bind=self.session.bind)
|
||||
metadata = sa.MetaData()
|
||||
metadata.reflect(self.session.bind)
|
||||
self.assertIn('testing_mybatch2', metadata.tables)
|
||||
self.assertIn('testing_mybatch_row2', metadata.tables)
|
||||
self.assertIn("testing_mybatch2", metadata.tables)
|
||||
self.assertIn("testing_mybatch_row2", metadata.tables)
|
||||
|
||||
# nb. this gives coverage but doesn't really test much
|
||||
batch = MyBatch2(id=42, uuid=_uuid.UUID('0675cdac-ffc9-7690-8000-6023de1c8cfd'))
|
||||
batch = MyBatch2(
|
||||
id=42, uuid=_uuid.UUID("0675cdac-ffc9-7690-8000-6023de1c8cfd")
|
||||
)
|
||||
row = MyBatchRow2()
|
||||
batch.rows.append(row)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue