コード例 #1
0
 def test_role_xml_serialization(self):
     role = Role(id=1, name="the role", blank=None)
     xml_str = role.to_xml()
     expected = ('<role xmlns="http://docs.openstack.org/identity/api/v2.0"'
                 ' id="1" name="the role"/>')
     self.assertTrue(testutils.XMLTools.xmlEqual(xml_str, expected),
                     msg='%s != %s' % (xml_str, expected))
コード例 #2
0
 def test_role_xml_serialization_mapping(self):
     role = Role(id=1, name="the role", service_id="s1", tenant_id="t1")
     xml_str = role.to_xml()
     self.assertTrue(
         testutils.XMLTools.xmlEqual(xml_str, '<role id="1" name="the role" serviceId="s1" tenantId="t1"/>')
     )
     self.assertEquals(role.service_id, "s1")
コード例 #3
0
 def test_role_xml_serialization(self):
     role = Role(id=1, name="the role", blank=None)
     xml_str = role.to_xml()
     expected = ('<role xmlns="http://docs.openstack.org/identity/api/v2.0"'
                 ' id="1" name="the role"/>')
     self.assertTrue(testutils.XMLTools.xmlEqual(xml_str, expected),
                     msg='%s != %s' % (xml_str, expected))
コード例 #4
0
 def test_role_json_serialization(self):
     role = Role(id=1, name="the role", blank=None)
     role["dynamic"] = "test"
     json_str = role.to_json()
     d1 = json.loads(json_str)
     d2 = {"role": {"name": "the role", "id": "1", "dynamic": "test"}}
     self.assertDictEqual(d1, d2)
コード例 #5
0
 def test_role_json_serialization(self):
     role = Role(id=1, name="the role", blank=None)
     role["dynamic"] = "test"
     json_str = role.to_json()
     d1 = json.loads(json_str)
     d2 = {"role": {"name": "the role", "id": "1", "dynamic": "test"}}
     self.assertDictEqual(d1, d2)
コード例 #6
0
 def test_role_xml_serialization_mapping(self):
     role = Role(id=1, name="the role", service_id="s1", tenant_id="t1")
     xml_str = role.to_xml()
     expected = ('<role xmlns="http://docs.openstack.org/identity/api/v2.0"'
                 ' id="1" name="the role" serviceId="s1" tenantId="t1"/>')
     self.assertTrue(testutils.XMLTools.xmlEqual(xml_str, expected),
                     msg='%s != %s' % (xml_str, expected))
     self.assertEquals(role.service_id, "s1")
コード例 #7
0
 def test_role_xml_serialization_mapping(self):
     role = Role(id=1, name="the role",
                 service_id="s1",
                 tenant_id="t1")
     xml_str = role.to_xml()
     self.assertTrue(testutils.XMLTools.xmlEqual(xml_str,
         '<role id="1" name="the role" serviceId="s1" tenantId="t1"/>'))
     self.assertEquals(role.service_id, "s1")
コード例 #8
0
    def test_role_json_deserialization(self):
        role = Role.from_json('{"name": "the role", "id": "1"}',
                            hints={"contract_attributes": ['id', 'name']})
        self.assertIsInstance(role, Role)
        self.assertEquals(role.id, "1")
        self.assertEquals(role.name, "the role")

        role = Role.from_json('{"role":{"name": "r1", "serviceId": "s1"}}')
        self.assertEquals(role.service_id, "s1")
コード例 #9
0
 def test_role_json_serialization_mapped(self):
     role = Role(id=1, name="the role",
                 service_id="s1",
                 tenant_id="t1")
     json_str = role.to_json()
     d1 = json.loads(json_str)
     d2 = {"role": {"name": "the role", "id": "1", "serviceId": "s1",
                    "tenantId": "t1"}}
     self.assertDictEqual(d1, d2)
コード例 #10
0
    def test_role_json_deserialization(self):
        role = Role.from_json('{"name": "the role", "id": "1"}',
                              hints={"contract_attributes": ['id', 'name']})
        self.assertIsInstance(role, Role)
        self.assertEquals(role.id, "1")
        self.assertEquals(role.name, "the role")

        role = Role.from_json('{"role":{"name": "r1", "serviceId": "s1"}}')
        self.assertEquals(role.service_id, "s1")
コード例 #11
0
 def test_role_json_serialization_mapped(self):
     role = Role(id=1, name="the role",
                 service_id="s1",
                 tenant_id="t1")
     json_str = role.to_json()
     d1 = json.loads(json_str)
     d2 = {"role": {"name": "the role", "id": "1", "serviceId": "s1",
                    "tenantId": "t1"}}
     self.assertDictEqual(d1, d2)
コード例 #12
0
 def test_role_xml_serialization_mapping(self):
     role = Role(id=1, name="the role",
                 service_id="s1",
                 tenant_id="t1")
     xml_str = role.to_xml()
     expected = ('<role xmlns="http://docs.openstack.org/identity/api/v2.0"'
                 ' id="1" name="the role" serviceId="s1" tenantId="t1"/>')
     self.assertTrue(testutils.XMLTools.xmlEqual(xml_str, expected),
             msg='%s != %s' % (xml_str,
                 expected))
     self.assertEquals(role.service_id, "s1")
コード例 #13
0
ファイル: role.py プロジェクト: OpenStack-Kha/keystone
 def to_model(ref):
     """ Returns Keystone model object based on SQLAlchemy model"""
     if ref:
         return Role(id=str(ref.id),
                     name=ref.name,
                     description=ref.desc,
                     service_id=ref.service_id)
コード例 #14
0
 def test_role_static_properties(self):
     role = Role(id=1, name="the role", service_id=1, blank=None)
     self.assertEquals(role.id, "1")
     self.assertEquals(role.name, "the role")
     self.assertEquals(role.service_id, "1")
     self.assertEquals(role.description, None)
     self.assertRaises(AttributeError, getattr, role, 'some_bad_property')
コード例 #15
0
 def test_role(self):
     role = Role()
     self.assertEquals(
         str(role.__class__), "<class 'keystone.models.Role'>",
         "role should be of instance "
         "class keystone.models.Role but instead "
         "was '%s'" % str(role.__class__))
     self.assertIsInstance(role, dict, "")
コード例 #16
0
 def test_role_validation(self):
     role = Role(id=1, name="the role", blank=None)
     self.assertTrue(role.validate())
コード例 #17
0
 def test_role_validation(self):
     role = Role(id=1, name="the role", blank=None)
     self.assertTrue(role.validate())
コード例 #18
0
 def test_role_inspection(self):
     role = Role(id=1, name="the role", blank=None)
     self.assertFalse(role.inspect())
コード例 #19
0
 def test_role_xml_deserialization(self):
     role = Role(id=1, name="the role", blank=None)
     self.assertIsInstance(role, Role)
コード例 #20
0
 def test_role_json_deserialization_types(self):
     role = Role.from_json('{"name": "the role", "id": 1}')
     self.assertIsInstance(role, Role)
     self.assertEquals(role.id, "1",
                       "'id' should always be returned as a string")
     self.assertEquals(role.name, "the role")
コード例 #21
0
 def test_role_xml_serialization(self):
     role = Role(id=1, name="the role", blank=None)
     xml_str = role.to_xml()
     self.assertTrue(testutils.XMLTools.xmlEqual(xml_str, '<role id="1" name="the role"/>'))
コード例 #22
0
 def test_role_json_deserialization(self):
     role = Role.from_json('{"name": "the role", "id": "1"}', hints={"contract_attributes": ["id", "name"]})
     self.assertIsInstance(role, Role)
     self.assertEquals(role.id, "1")
     self.assertEquals(role.name, "the role")
コード例 #23
0
 def test_role_json_deserialization_types(self):
     role = Role.from_json('{"name": "the role", "id": 1}')
     self.assertIsInstance(role, Role)
     self.assertEquals(role.id, "1",
                       "'id' should always be returned as a string")
     self.assertEquals(role.name, "the role")
コード例 #24
0
 def test_role_inspection(self):
     role = Role(id=1, name="the role", blank=None)
     self.assertFalse(role.inspect())
コード例 #25
0
 def test_role_properties(self):
     role = Role(id=1, name="the role", blank=None)
     role["dynamic"] = "test"
     self.assertEquals(role["dynamic"], "test")
コード例 #26
0
 def test_role_xml_serialization(self):
     role = Role(id=1, name="the role", blank=None)
     xml_str = role.to_xml()
     self.assertTrue(testutils.XMLTools.xmlEqual(xml_str,
                     '<role id="1" name="the role"/>'))