def test_get_uuid(self):
        """Good GET request for one search."""

        # Select one row from the pre-defined searches.
        row = SavedSearch.objects.all()[0]

        token = create_and_login()

        factory = APIRequestFactory()
        view = SavedSearchViewSet.as_view({'get': 'retrieve'})
        request = factory.get(SEARCH_URL,
                              HTTP_AUTHORIZATION=AUTHORIZATION_PAYLOAD % token)
        response = view(request, uuid=row.uuid)
        response.render()

        # pylint: disable=E1101
        self.assertEqual(response.status_code, HTTP_200_OK)

        response_content = json.loads(response.content)

        for key in ['created', 'updated', 'last_start', 'last_end']:
            self.assertIsInstance(response_content[key],
                                  (basestring, NoneType))

        self.assertEqual(row.name, response_content["name"])
        self.assertEqual(row.protected, response_content["protected"])
        self.assertEqual(row.query, response_content["query"])
        self.assertEqual(row.uuid, response_content["uuid"])
        self.assertEqual(row.owner, response_content["owner"])
        self.assertEqual(row.index_prefix, response_content["index_prefix"])
        self.assertEqual(row.doc_type, response_content["doc_type"])
        self.assertEqual(row.timestamp_field,
                         response_content["timestamp_field"])
        self.assertEqual(row.target_interval,
                         response_content["target_interval"])
    def test_get_uuid(self):
        """Good GET request for one search."""

        # Select one row from the pre-defined searches.
        row = SavedSearch.objects.filter(hidden=False)[0]

        token = create_and_login()

        factory = APIRequestFactory()
        view = SavedSearchViewSet.as_view({'get': 'retrieve'})
        request = factory.get(SEARCH_URL,
                              HTTP_AUTHORIZATION=AUTHORIZATION_PAYLOAD % token)
        response = view(request, uuid=row.uuid)
        response.render()

        # pylint: disable=E1101
        self.assertEqual(response.status_code, HTTP_200_OK)

        response_content = json.loads(response.content)

        for key in ['created', 'updated', 'last_start', 'last_end']:
            self.assertIsInstance(response_content[key],
                                  (basestring, NoneType))

        self.assertEqual(row.name, response_content["name"])
        self.assertEqual(row.protected, response_content["protected"])
        self.assertEqual(row.query, response_content["query"])
        self.assertEqual(row.uuid, response_content["uuid"])
        self.assertEqual(row.owner, response_content["owner"])
        self.assertEqual(row.index_prefix, response_content["index_prefix"])
        self.assertEqual(row.doc_type, response_content["doc_type"])
        self.assertEqual(row.timestamp_field,
                         response_content["timestamp_field"])
        self.assertEqual(row.target_interval,
                         response_content["target_interval"])
Example #3
0
urlpatterns = patterns(
    '',
    url(r'^agents', AgentsDataView.as_view(), name='nova-agents'),
    url(r'^aggregates', AggregatesDataView.as_view(), name='nova-aggregates'),
    url(r'^availability_zones',
        AvailZonesDataView.as_view(),
        name='nova-availability-zones'),
    url(r'^cloudpipes', CloudpipesDataView.as_view(), name='nova-cloudpipes'),
    url(r'^flavors', FlavorsDataView.as_view(), name='nova-flavors'),
    url(r'^floating_ip_pools',
        FloatingIpPoolsDataView.as_view(),
        name='nova-floating-ip-pools'),
    url(r'^hosts', HostsDataView.as_view(), name='nova-hosts'),
    url(r'^hypervisors',
        HypervisorsDataView.as_view(),
        name='nova-hypervisors'),
    url(r'^networks', NetworksDataView.as_view(), name='nova-networks'),
    url(r'^security_groups',
        SecGroupsDataView.as_view(),
        name='nova-security-groups'),
    url(r'^servers', ServersDataView.as_view(), name='nova-servers'),
    url(r'^services', ServicesDataView.as_view(), name='nova-services'),
    )

# Other views.
urlpatterns += patterns(
    '',
    url(r'^hypervisor/spawns/', SavedSearchViewSet.as_view(
        {'get': 'results'}), {'uuid': '21f5c6db-5a2e-41d4-9462-c3cdc03a837b'})
    )