def test_get_metadata(self): """ test for model_access.get_metadata() """ metadata = model_access.get_metadata('wsmith') categories = metadata['categories'] keys = list(categories[0].keys()).sort() expected_keys = ['description', 'id', 'title'].sort() self.assertEqual(keys, expected_keys) agencies = metadata['agencies'] keys = list(agencies[0].keys()).sort() expected_keys = ['short_name', 'title', 'icon', 'listing_count'].sort() self.assertEqual(keys, expected_keys) contact_types = metadata['contact_types'] keys = list(contact_types[0].keys()).sort() expected_keys = ['required', 'name'].sort() self.assertEqual(keys, expected_keys) intents = metadata['intents'] keys = list(intents[0].keys()).sort() expected_keys = ['label', 'action', 'media_type', 'icon'].sort() self.assertEqual(keys, expected_keys) listing_types = metadata['listing_types'] keys = list(listing_types[0].keys()).sort() expected_keys = ['title', 'description'].sort() self.assertEqual(keys, expected_keys)
def MetadataView(request): """ Metadata for the store including categories, agencies, contact types, intents, and listing types """ data = model_access.get_metadata(request.user.username) return Response(data)
def test_get_metadata(self): """ test for model_access.get_metadata() """ metadata = model_access.get_metadata('wsmith') categories = metadata['categories'] keys = list(categories[0].keys()).sort() expected_keys = ['description', 'title'].sort() self.assertEqual(keys, expected_keys) agencies = metadata['agencies'] keys = list(agencies[0].keys()).sort() expected_keys = ['short_name', 'title', 'icon', 'listing_count'].sort() self.assertEqual(keys, expected_keys) contact_types = metadata['contact_types'] keys = list(contact_types[0].keys()).sort() expected_keys = ['required', 'name'].sort() self.assertEqual(keys, expected_keys) intents = metadata['intents'] keys = list(intents[0].keys()).sort() expected_keys = ['label', 'action', 'media_type', 'icon'].sort() self.assertEqual(keys, expected_keys) listing_types = metadata['listing_types'] keys = list(listing_types[0].keys()).sort() expected_keys = ['title', 'description'].sort() self.assertEqual(keys, expected_keys)
def MetadataView(request): """ Metadata for the store including categories, agencies, contact types, intents, and listing types """ request_username = request.user.username data = model_access.get_metadata(request_username) return Response(data)