示例#1
0
文件: test_js.py 项目: andyjia/phase
    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'
        )
示例#2
0
    def handle(self, *args, **options):
        logger.info('Deleting index %s' % settings.ELASTIC_INDEX)

        try:
            delete_index()
        except ConnectionError:
            raise CommandError('Elasticsearch cannot be found')
示例#3
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'
        )
示例#4
0
    def handle(self, *args, **options):
        logger.info('Deleting index %s' % settings.ELASTIC_INDEX)

        try:
            delete_index()
        except ConnectionError:
            raise CommandError('Elasticsearch cannot be found')
示例#5
0
    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)
示例#6
0
    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)
示例#7
0
文件: test_js.py 项目: andyjia/phase
    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'
        )
示例#8
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'
        )
示例#9
0
 def tearDown(self):
     disconnect_signals()
     delete_index()
示例#10
0
文件: test_js.py 项目: thibault/phase
 def tearDown(self):
     disconnect_signals()
     delete_index()