def test_basics(self): """Attribute creation and attribute references""" attr = Attribute("foo") self.assertEqual("foo", attr.name) self.assertEqual("foo", str(attr)) self.assertEqual("foo", attr.ref()) self.assertEqual("foo", attr.ref(simplify=False)) self.assertEqual("foo", attr.ref(simplify=True))
def test_locale(self): """References to localizable attributes""" attr = Attribute("foo") self.assertRaises(ArgumentError, attr.ref, locale="xx") attr = Attribute("foo", locales=["en", "sk"]) self.assertEqual("foo", attr.name) self.assertEqual("foo", str(attr)) self.assertEqual("foo", attr.ref()) self.assertEqual("foo.en", attr.ref(locale="en")) self.assertEqual("foo.sk", attr.ref(locale="sk")) self.assertRaises(ArgumentError, attr.ref, locale="xx")
def setUp(self): attrs = [ { "name": "a" }, { "name": "b", "expression": "a + 1" }, { "name": "c", "expression": "b + 1" }, { "name": "d", "expression": "10" }, { "name": "e", "expression": "unknown" }, { "name": "loop1", "expression": "loop2 + 1" }, { "name": "loop2", "expression": "loop1 + 1" }, { "name": "indirect_loop1", "expression": "intermediate" }, { "name": "intermediate", "expression": "indirect_loop1" }, { "name": "indirect_loop2", "expression": "indirect_loop1" }, ] self.attrs = { attr["name"]: Attribute.from_metadata(attr) for attr in attrs } self.deps = { name: attr.dependencies for name, attr in self.attrs.items() }
def setUp(self): attrs = [ {"name": "a"}, {"name": "b", "expression": "a + 1"}, {"name": "c", "expression": "b + 1"}, {"name": "d", "expression": "10"}, {"name": "e", "expression": "unknown"}, {"name": "loop1", "expression": "loop2 + 1"}, {"name": "loop2", "expression": "loop1 + 1"}, {"name": "indirect_loop1", "expression": "intermediate"}, {"name": "intermediate", "expression": "indirect_loop1"}, {"name": "indirect_loop2", "expression": "indirect_loop1"}, ] self.attrs = {attr["name"]: Attribute.from_metadata(attr) for attr in attrs} self.deps = {name: attr.dependencies for name, attr in self.attrs.items()}