Esempio n. 1
0
    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'
        )
Esempio n. 2
0
 def handle(self, *args, **options):
     categories = Category.objects \
         .select_related('category_template__metadata_model')
     for category in categories:
         doc_class = category.document_class()
         logger.info('Creating mapping for document type %s' %
                     doc_class.__name__)
         try:
             put_category_mapping(category.id)
         except ConnectionError:
             raise CommandError('Elasticsearch cannot be found')
Esempio n. 3
0
    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'
        )