Ran black on sources, add black config

This commit is contained in:
Griatch 2020-07-27 21:09:13 +02:00
parent abe4b1e4ee
commit 0df87037e7
32 changed files with 1031 additions and 232 deletions

View file

@ -132,7 +132,6 @@ class TypeclassBase(SharedMemoryModelBase):
if not dbmodel:
raise TypeError(f"{name} does not appear to inherit from a database model.")
# typeclass proxy setup
# first check explicit __applabel__ on the typeclass, then figure
# it out from the dbmodel
@ -141,6 +140,7 @@ class TypeclassBase(SharedMemoryModelBase):
attrs["__applabel__"] = dbmodel._meta.app_label
if "Meta" not in attrs:
class Meta:
proxy = True
app_label = attrs.get("__applabel__", "typeclasses")
@ -162,8 +162,7 @@ class TypeclassBase(SharedMemoryModelBase):
# attach signals
signals.post_save.connect(call_at_first_save, sender=new_class)
signals.pre_delete.connect(
remove_attributes_on_delete, sender=new_class)
signals.pre_delete.connect(remove_attributes_on_delete, sender=new_class)
return new_class

View file

@ -43,10 +43,12 @@ class TestAttributes(EvenniaTest):
self.assertEqual(self.obj1.attributes.get(key), value)
def test_batch_add(self):
attrs = [("key1", "value1"),
("key2", "value2", "category2"),
("key3", "value3"),
("key4", "value4", "category4", "attrread:id(1)", False)]
attrs = [
("key1", "value1"),
("key2", "value2", "category2"),
("key3", "value3"),
("key4", "value4", "category4", "attrread:id(1)", False),
]
new_attrs = self.obj1.attributes.batch_add(*attrs)
attrobj = self.obj1.attributes.get(key="key4", category="category4", return_obj=True)
self.assertEqual(attrobj.value, "value4")
@ -136,11 +138,7 @@ class TestTypedObjectManager(EvenniaTest):
)
def test_batch_add(self):
tags = ["tag1",
("tag2", "category2"),
"tag3",
("tag4", "category4", "data4")
]
tags = ["tag1", ("tag2", "category2"), "tag3", ("tag4", "category4", "data4")]
self.obj1.tags.batch_add(*tags)
self.assertEqual(self.obj1.tags.get("tag1"), "tag1")
tagobj = self.obj1.tags.get("tag4", category="category4", return_tagobj=True)