Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 3
0
 def test_description(self):
     attr = attribute.Attribute("occi.foo.bar", description="foo")
     self.assertEqual("foo", attr.description)
Ejemplo n.º 4
0
 def test_required(self):
     attr = attribute.Attribute("occi.foo.bar", required=True)
     self.assertEqual(True, attr.required)
Ejemplo n.º 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)
Ejemplo n.º 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"})
Ejemplo n.º 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)
Ejemplo n.º 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)