def test_delete_index(self): app_config = apps.get_app_config('videos') create_index(app_config, 'Video') self.assertTrue(index_exists(Video.get_index_name())) delete_index(Video.get_index_name()) with self.assertRaises(IndexNotFound): get_index(Video.get_index_name())
def test_get_document(self): app_config = apps.get_app_config('videos') create_index(app_config, 'Video') self.assertTrue(index_exists(Video.get_index_name())) time.sleep(1) v = Video.objects.create( title="Test Video", video_id="Leg1tVid1D", thumbnail_url="http://example.com/legitthumbnail.jpeg") doc = get_document(v) self.assertTrue(isinstance(doc, dict))
def test_create_document_conflict(self): app_config = apps.get_app_config('videos') create_index(app_config, 'Video') self.assertTrue(index_exists(Video.get_index_name())) time.sleep(1) v = Video.objects.create( title="Test Video", video_id="Leg1tVid1D", thumbnail_url="http://example.com/legitthumbnail.jpeg") err = create_document(v) err_msg = "Conflict: document already exists for {0} with id {1}." self.assertEqual(err, err_msg.format(v.__class__.__name__, v.pk))
def test_create_document(self): app_config = apps.get_app_config('videos') create_index(app_config, 'Video') self.assertTrue(index_exists(Video.get_index_name())) time.sleep(1) v = Video.objects.create( title="Test Video", video_id="Leg1tVid1D", thumbnail_url="http://example.com/legitthumbnail.jpeg") # Created Via signal assert the document exists doc = get_document(v) self.assertEqual(doc['_source'], v.get_document_body())
def test_create_document_conflict(self): app_config = apps.get_app_config('videos') create_index(app_config, 'Video') self.assertTrue(index_exists(Video.get_index_name())) time.sleep(1) v = Video.objects.create( title="Test Video", video_id="Leg1tVid1D", thumbnail_url="http://example.com/legitthumbnail.jpeg") err = create_document(v) err_msg = "Conflict: document already exists for {0} with id {1}." self.assertEqual( err, err_msg.format(v.__class__.__name__, v.pk))
def test_get_index(self): app_config = apps.get_app_config('videos') create_index(app_config, 'Video') self.assertTrue(index_exists(Video.get_index_name())) index = get_index(Video.get_index_name()) self.assertTrue(isinstance(index, dict))
def test_index_exists(self): app_config = apps.get_app_config('videos') create_index(app_config, 'Video') self.assertTrue(index_exists(Video.get_index_name()))
def test_create_index(self): app_config = apps.get_app_config('videos') create_index(app_config, 'Video') self.assertTrue(ES.indices.exists(index=[Video.get_index_name()]))
def test_get_index_name(self): self.assertEqual(Video.get_index_name(), 'test_trickapi_video_index')
def test_get_index_name(self): self.assertEqual( Video.get_index_name(), 'test_trickapi_video_index')