def test_replaced_by_expired(self): c = ConfigOption( "mysection.oldName", description="My old description", replaced_by="mysection.newName", expiration_date="2000-01-01", ) self.assertTrue(c.deprecated) self.assertTrue(c.is_expired())
def test_replaced_by_expired(self): def config_getter(key): self.assertEqual(key, "mysection.newName") return "newValue" c = ConfigOption( "mysection.oldName", description="My old description", replaced_by="mysection.newName", expiration_date="2000-01-01", config_getter=config_getter, ) self.assertTrue(c.deprecated) self.assertTrue(c.is_expired())
def test_deprecated_unexpired(self): my_value = "myValue" where_defined = "im defined here" key = "mysection.myName" c = ConfigOption( key, deprecated=True, deprecation_text="dep text", expiration_date="2100-01-01", ) c.set_value(my_value, where_defined) self.assertFalse(c.is_expired())
def test_deprecated_expired(self): my_value = "myValue" where_defined = "im defined here" key = "mysection.myName" c = ConfigOption( key, deprecated=True, deprecation_text="dep text", expiration_date="2000-01-01", ) with self.assertRaises(DeprecationError): c.set_value(my_value, where_defined) self.assertTrue(c.is_expired())