def test_init(self): re_property = Property(name="Test", default=False) self.assertFalse(re_property.value) re_property.value = True self.assertTrue(re_property.value) with self.assertRaises(TypeError): re_property.value = "other"
def test_set_bool_with_ON_and_OFF(self): re_property = Property(name="Test", default=False) re_property.value = "ON" self.assertTrue(re_property.value) re_property.value = "OFF" self.assertFalse(re_property.value) re_property.value = "" self.assertFalse(re_property.value)
def test_set_value_not_stripped(self): re_property = Property(name="Test", default=False) re_property.value = "ON " self.assertTrue(re_property) re_property_text = Property(name="Text", default="") re_property_text.value = "foo " compare("foo", re_property_text.value)
def test_hash(self): re_property = Property(name="Test", default=False) pre_hash = hash(re_property) re_property.value = True self.assertNotEqual(pre_hash, hash(re_property)) re_property = Property(name="Test", default="") pre_hash = hash(re_property) re_property.value = "value" self.assertNotEqual(pre_hash, hash(re_property))
def __init__(self, article_type: str = RE_DATEN, re_daten_properties: ArticleProperties = None, text: str = "", author: Tuple[str, str] = ("", "")): self._article_type = "" self.article_type = article_type self._text = "" self.text = text self._author = ("", "") self.author = author self._properties = (Property("BAND", ""), Property("SPALTE_START", ""), Property("SPALTE_END", ""), Property("VORGÄNGER", ""), Property("NACHFOLGER", ""), Property("SORTIERUNG", ""), Property("KORREKTURSTAND", ""), Property("KURZTEXT", ""), Property("WIKIPEDIA", ""), Property("WIKISOURCE", ""), Property("GND", ""), Property("KEINE_SCHÖPFUNGSHÖHE", False), Property("TODESJAHR", ""), Property("GEBURTSJAHR", ""), Property("NACHTRAG", False), Property("ÜBERSCHRIFT", False), Property("VERWEIS", False)) self._init_properties(re_daten_properties)
def test_repr(self): re_property = Property(name="Test", default=False) compare("<Property (name: Test, value: False, type: bool)>", repr(re_property))
def test_set_bool_bug_non_capitalized(self): re_property = Property(name="Test", default=False) re_property.value = "on" self.assertTrue(re_property)
def test_wrong_default(self): with self.assertRaises(TypeError): re_property = Property(name="Test", default=1) re_property.value_to_string()
def test_format_bool(self): re_property = Property(name="Test", default=False) self.assertEqual(re_property.value_to_string(), "OFF") re_property.value = True self.assertEqual(re_property.value_to_string(), "ON")