def test_get_element(self): doc_id = self.insert_docs(self.test_db, self.test_collection, self.insert_data) item_id = str(doc_id[0]) test_get_element_url = self.base_url + (self.get_item_path % (self.test_db, self.test_collection, item_id)) return_value = GET(test_get_element_url, accept = [self.test_json_mimetype], async = False, credentials = [self.test_user, self.test_password,""], ) self.assertEquals(type(return_value).__name__, "str") doc_obj = json.loads(return_value)[settings.DOC_CONTAINER] self.assertTrue(u'_id' in doc_obj) self.assertEquals(doc_obj[u'_id'][u'$oid'],unicode(item_id)) del doc_obj[u'_id'] #del self.test_doc[u'_id'] self.assertTrue(check_dictionaries_match(doc_obj, self.test_doc))
def test_get_element_custom_mimetype_amf(self): doc_id = self.insert_docs(self.test_db, self.test_collection, self.insert_data) item_id = str(doc_id[0]) test_get_element_url = self.base_url + (self.get_item_path % (self.test_db, self.test_collection, item_id)) response_obj = GET(test_get_element_url, async = False, accept = [self.test_amf_mimetype] , resp = True, credentials = [self.test_user, self.test_password,""]) return_value, http_status = self.get_http_response(response_obj) self.assertEquals(type(return_value).__name__, "str") decoder = Decoder(amf3=True) doc_obj = decoder.decode(return_value)[settings.DOC_CONTAINER] self.assertTrue(u'_id' in doc_obj) del doc_obj[u'_id'] self.assertTrue(check_dictionaries_match(doc_obj, self.test_doc))