Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
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)
Ejemplo n.º 3
0
    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)
Ejemplo n.º 4
0
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)