def setUp(self): delete_index() create_index() self.category = CategoryFactory() put_category_mapping(self.category.id) user = UserFactory(email='*****@*****.**', password='******', is_superuser=True, category=self.category) connect_signals() for doc_id in xrange(20): doc = DocumentFactory( document_key='hazop-report-%d' % doc_id, category=self.category, ) index_document(doc.id) # ES needs some time to finish indexing time.sleep(1) document_list_url = reverse('category_document_list', args=[ self.category.organisation.slug, self.category.slug ]) self.url = '%s%s' % (self.live_server_url, document_list_url) self.client.login(email=user.email, password='******') self.test_file = os.path.join( os.path.dirname(__file__), 'casper_tests', 'tests.js' )
def handle(self, *args, **options): logger.info('Deleting index %s' % settings.ELASTIC_INDEX) try: delete_index() except ConnectionError: raise CommandError('Elasticsearch cannot be found')
def setUp(self): delete_index() create_index() self.category = CategoryFactory() put_category_mapping(self.category.id) user = UserFactory(email='*****@*****.**', password='******', is_superuser=True, category=self.category) connect_signals() for doc_id in range(20): doc = DocumentFactory( document_key='hazop-report-%d' % doc_id, category=self.category, ) index_document(doc.id) # ES needs some time to finish indexing time.sleep(1) document_list_url = reverse('category_document_list', args=[ self.category.organisation.slug, self.category.slug ]) self.url = '%s%s' % (self.live_server_url, document_list_url) self.client.login(email=user.email, password='******') self.test_file = os.path.join( os.path.dirname(__file__), 'casper_tests', 'tests.js' )
def test_export_create_cleanup_old_exports(self): delete_index() create_index() now = timezone.now() for delta in range(0, 25): ExportFactory(owner=self.user, category=self.category, created_on=now + timedelta(days=-delta)) self.assertEqual(Export.objects.all().count(), 25) self.client.post(self.url) self.assertEqual(Export.objects.all().count(), 20)
def test_export_create_cleanup_old_exports(self): delete_index() create_index() now = timezone.now() for delta in range(0, 25): ExportFactory( owner=self.user, category=self.category, created_on=now + timedelta(days=-delta)) self.assertEqual(Export.objects.all().count(), 25) self.client.post(self.url) self.assertEqual(Export.objects.all().count(), 20)
def setUp(self): delete_index() create_index() self.category = CategoryFactory() self.slug = '/{}/{}/'.format( self.category.organisation.slug, self.category.category_template.slug) put_category_mapping(self.category.id) user = UserFactory(email='*****@*****.**', password='******', is_superuser=True, category=self.category) connect_signals() for doc_id in xrange(20): DocumentFactory( document_key='hazop-report-%d' % doc_id, category=self.category, ) document_list_url = reverse('category_document_list', args=[ self.category.organisation.slug, self.category.slug ]) self.b1 = BookmarkFactory( user=user, category=self.category, name='Hazop documents', url='%s?search_terms=hazop' % document_list_url ) self.b2 = BookmarkFactory( user=user, category=self.category, name='Rev ordered documents', url='%s?sort_by=current_revision' % document_list_url ) self.url = '%s%s' % (self.live_server_url, document_list_url) self.client.login(email=user.email, password='******') self.test_file = os.path.join( os.path.dirname(__file__), 'casper_tests', 'tests.js' )
def setUp(self): delete_index() create_index() self.category = CategoryFactory() self.slug = '/{}/{}/'.format( self.category.organisation.slug, self.category.category_template.slug) put_category_mapping(self.category.id) user = UserFactory(email='*****@*****.**', password='******', is_superuser=True, category=self.category) connect_signals() for doc_id in range(20): DocumentFactory( document_key='hazop-report-%d' % doc_id, category=self.category, ) document_list_url = reverse('category_document_list', args=[ self.category.organisation.slug, self.category.slug ]) self.b1 = BookmarkFactory( user=user, category=self.category, name='Hazop documents', url='%s?search_terms=hazop' % document_list_url ) self.b2 = BookmarkFactory( user=user, category=self.category, name='Rev ordered documents', url='%s?sort_by=current_revision' % document_list_url ) self.url = '%s%s' % (self.live_server_url, document_list_url) self.client.login(email=user.email, password='******') self.test_file = os.path.join( os.path.dirname(__file__), 'casper_tests', 'tests.js' )
def tearDown(self): disconnect_signals() delete_index()