Exemple #1
0
 def test_send_result_json(self):
     self.request.headers["Accept"] = "application/json"
     response = server.send_result(200,self.request,self.auth_data);
     self.assertTrue(response.headers['content-type'] == "application/json; charset=UTF-8")
     dict = json.loads(response.unicode_body)
     self.assertTrue(dict['auth']['user']['username'],'username');
     self.assertTrue(dict['auth']['user']['tenantId'],'12345');
     self.assertTrue(dict['auth']['token']['id'],'2231312');
     self.assertTrue(dict['auth']['token']['expires'],date.today());
Exemple #2
0
    def test_send_result_xml(self):
        self.request.headers["Accept"] = "application/xml"
        response = server.send_result(200,self.request,self.auth_data);
       
        self.assertTrue(response.headers['content-type'] == "application/xml; charset=UTF-8")
        xml = etree.fromstring(response.unicode_body)

        user = xml.find("{http://docs.openstack.org/identity/api/v2.0}user")
        token = xml.find("{http://docs.openstack.org/identity/api/v2.0}token")
        
        self.assertTrue(user.get("username"),"username")
        self.assertTrue(user.get("tenantId"),'12345');
        self.assertTrue(token.get("id"),'2231312');
        self.assertTrue(token.get("expires"),date.today());