Exemplo n.º 1
0
 def test_get(self):
     catalog = CatalogFactory(viewers=[self.catalog_user.username])
     self.mock_catalog_api('api/v1/catalogs/',
                           {'results': [catalog.attributes]})
     response = self.client.get(self.url)
     self.assertEqual(response.status_code, 200)
     self.assertIn(catalog.name, response.content.decode('utf-8'))
Exemplo n.º 2
0
 def test_post_invalid(self):
     catalog = CatalogFactory(viewers=[self.catalog_user.username])
     self.mock_catalog_endpoint({'results': [catalog.attributes]})
     response = self.client.post(self.url, {
         'name': '',
         'query': '*',
         'viewers': [self.catalog_user.username]
     })
     self.assertEqual(response.status_code, 400)
     # Assert that no POST was made to the catalog API
     self.assertEqual(len([r for r in httpretty.httpretty.latest_requests if r.method == 'POST']), 0)
Exemplo n.º 3
0
 def test_post(self):
     catalog_data = {
         'name': 'test-catalog',
         'query': '*',
         'viewers': [self.catalog_user.username]
     }
     catalog_id = 123
     self.mock_catalog_endpoint(dict(catalog_data, id=catalog_id), method=httpretty.POST)
     response = self.client.post(self.url, catalog_data)
     self.assertEqual(httpretty.last_request().method, 'POST')
     self.mock_catalog_endpoint(CatalogFactory().attributes, catalog_id=catalog_id)
     self.assertRedirects(response, reverse('api_admin:catalog-edit', kwargs={'catalog_id': catalog_id}))
Exemplo n.º 4
0
 def setUp(self):
     super(CatalogEditViewTest, self).setUp()
     self.catalog_user = UserFactory()
     self.catalog = CatalogFactory(viewers=[self.catalog_user.username])
     self.url = reverse('api_admin:catalog-edit',
                        kwargs={'catalog_id': self.catalog.id})
Exemplo n.º 5
0
 def setUp(self):
     super(CatalogEditViewTest, self).setUp()  # lint-amnesty, pylint: disable=super-with-arguments
     self.catalog_user = UserFactory()
     self.catalog = CatalogFactory(viewers=[self.catalog_user.username])
     self.url = reverse('api_admin:catalog-edit', kwargs={'catalog_id': self.catalog.id})
Exemplo n.º 6
0
 def test_get(self):
     catalog = CatalogFactory(viewers=[self.catalog_user.username])
     self.mock_catalog_endpoint({'results': [catalog.attributes]})
     response = self.client.get(self.url)
     self.assertContains(response, catalog.name)