def create_catalog_index( apps, schema_editor ): if not Catalog._index.exists(): Catalog.init() if Catalog.search().count() < 1: response = catalog.get() serializer = Catalog_serializer( data=response.native, many=True ) serializer.is_valid( raise_exception=True ) serializer.save()
def test_should_work(self): catalog = Catalog.search()[:1] catalog = catalog.execute()[0] catalog_id = catalog.meta.id new_data = {'count': catalog.count + 10} when = datetime.datetime.utcnow() - datetime.timedelta(days=1) update_catalog(catalog_id, new_data, when) result = Catalog._index.flush() catalog_v2 = Catalog.get(catalog_id) self.assertEqual(catalog_v2.count, new_data['count'])
def test_should_be_a_dict(self): catalog = Catalog.search()[:1].execute()[0] url = reverse(self.url_name, kwargs={'pk': catalog.meta.id}) response = self.client.get(url) assert_status_code(response, status.HTTP_200_OK) self.assertIsInstance(response.data, dict) self.assertTrue(response.data) self.assertIn('pk', response.data) self.assertIn('fields', response.data) self.assertIsInstance(response.data['fields'], list) self.assertTrue(response.data['fields'])
def test_should_return_404(self): catalog = Catalog.search()[:1].execute()[0] url = reverse(self.url_name, kwargs={'pk': '1'}) response = self.client.get(url) assert_status_code(response, status.HTTP_404_NOT_FOUND)