Exemple #1
0
 def test_update(self):
     mapping1 = {"occi.foo.1": attribute.Attribute("occi.foo.1", "bar")}
     mapping2 = {"occi.foo.2": attribute.Attribute("occi.foo.2", "baz")}
     col1 = attribute.AttributeCollection(mapping1)
     col2 = attribute.AttributeCollection(mapping2)
     self.assertEqual(mapping1, col1.attributes)
     self.assertEqual(mapping2, col2.attributes)
     col1.update(col2)
     mapping1.update(mapping2)
     self.assertEqual(mapping1, col1.attributes)
Exemple #2
0
 def test_base(self):
     attr = attribute.Attribute("occi.foo.bar", "bar")
     self.assertEqual("bar", attr.value)
     self.assertEqual("occi.foo.bar", attr.name)
     self.assertEqual(False, attr.required)
     self.assertEqual(None, attr.default)
     self.assertEqual(None, attr.description)
Exemple #3
0
 def test_description(self):
     attr = attribute.Attribute("occi.foo.bar", description="foo")
     self.assertEqual("foo", attr.description)
Exemple #4
0
 def test_required(self):
     attr = attribute.Attribute("occi.foo.bar", required=True)
     self.assertEqual(True, attr.required)
Exemple #5
0
 def test_default_value(self):
     attr = attribute.Attribute("occi.foo.bar", default="bar")
     self.assertEqual(None, attr.value)
     self.assertEqual("bar", attr.default)
Exemple #6
0
 def test_update_invalid(self):
     mapping = {"occi.foo.1": attribute.Attribute("occi.foo.1", "bar")}
     col = attribute.AttributeCollection(mapping)
     self.assertRaises(TypeError, col.update, {"foo": "bar"})
Exemple #7
0
 def test_collection_from_map(self):
     mapping = {"foo": attribute.Attribute("occi.foo.bar", "crap")}
     col = attribute.AttributeCollection(mapping)
     self.assertEqual(mapping, col.attributes)
Exemple #8
0
 def test_base(self):
     attr = attribute.Attribute("occi.foo.bar", "bar")
     self.assertEqual("bar", attr.value)
     self.assertEqual("occi.foo.bar", attr.name)