def test_attr_transformation_fail(self): attrs = _Attrs('test', {'number': 'abc'}, {'count': ('number', int)}) self.assertRaises(ValueError, lambda: attrs.count)
def test_raises_on_missing_required_attribute(self): attrs = _Attrs('test', {}, {'name': 'node-name'}) self.assertRaises(AttributeError, lambda: attrs.name)
def test_attr_transformation_success(self): attrs = _Attrs('test', {'number': '7'}, {'count': ('number', int)}) self.assertEqual(7, attrs.count)
def test_get_declared_attr(self): attrs = _Attrs('test', {'node-name': 'node1'}, {'name': 'node-name'}) self.assertEqual('node1', attrs.name)
def test_raises_on_undeclared_attribute(self): attrs = _Attrs('test', {'node-name': 'node1'}, {}) self.assertRaises(AttributeError, lambda: attrs.name)