Esempio n. 1
0
    def setUp(self):
        self.main_cat_1 = ParentCategoryFactory.create()
        self.main_cat_2 = ParentCategoryFactory.create()

        self.s1 = SignalFactory.create(category_assignment__category__parent=self.main_cat_1)
        self.s2 = SignalFactory.create(category_assignment__category__parent=self.main_cat_2)

        # We are testing the authenticated part of the API, hence:
        self.client.force_authenticate(user=self.superuser)
    def setUp(self):
        self.main_category = ParentCategoryFactory.create(name='main',
                                                          slug='main')
        self.link_main_category = '/signals/v1/public/terms/categories/main'

        self.sub_category_1 = CategoryFactory.create(name='sub1',
                                                     slug='sub1',
                                                     parent=self.main_category)
        self.link_sub_category_1 = f'{self.link_main_category}/sub_categories/sub1'

        self.sub_category_2 = CategoryFactory.create(name='sub2',
                                                     slug='sub2',
                                                     parent=self.main_category)
        self.link_sub_category_2 = f'{self.link_main_category}/sub_categories/sub2'

        self.sia_read_write_user.user_permissions.add(
            Permission.objects.get(codename='sia_can_view_all_categories'))
        self.client.force_authenticate(user=self.sia_read_write_user)

        self.initial_data_base = dict(
            text='Mensen in het cafe maken erg veel herrie',
            location=dict(geometrie=dict(
                type='point', coordinates=[4.90022563, 52.36768424])),
            category=dict(category_url=self.link_sub_category_1),
            reporter=dict(email='*****@*****.**'),
            incident_date_start=timezone.now().strftime('%Y-%m-%dT%H:%M'),
            source='Telefoon – ASC',
        )

        self.retrieve_signal_schema = self.load_json_schema(
            os.path.join(THIS_DIR, 'json_schema',
                         'get_signals_v1_private_signals_{pk}.json'))
    def setUp(self):
        sia_category_write_permission = Permission.objects.get(codename='sia_category_write')
        self.sia_read_write_user.user_permissions.add(sia_category_write_permission)

        self.parent_category = ParentCategoryFactory.create()

        CategoryFactory.create_batch(5, parent=self.parent_category)
        self.parent_category.refresh_from_db()

        super(TestPrivateCategoryEndpoint, self).setUp()
Esempio n. 4
0
    def setUp(self):
        """Setup test environment"""
        # Create a test user for Techtek.
        self.techtek_user = UserFactory(email='*****@*****.**')
        # Give the Techtek user the correct permissions.
        required_permissions = Permission.objects.filter(
            codename__in=['sia_read', 'sia_write'])
        self.techtek_user.user_permissions.set(required_permissions)

        # Various relevant endpoints
        self.signals_list = '/signals/v1/private/signals/'
        self.signal_detail = '/signals/v1/private/signals/{pk}'
        self.category_url_template = \
            '{server}/signals/v1/public/terms/categories/{main_slug}/sub_categories/{sub_slug}'

        # Fill test database with some signals to demonstrate filtering.
        techtek_parent_category = ParentCategoryFactory.create(
            slug=TECHTEK_MAIN_SLUG)
        techtek_sub_cat = CategoryFactory.create(
            slug=TECHTEK_SUB_SLUG, parent=techtek_parent_category)

        self._techtek_signal_1 = SignalFactoryValidLocation(
            category_assignment__category=techtek_sub_cat,
            text='De straatverlichting werkt niet.',
            status__state=workflow.GEMELD,
        )
        self._techtek_signal_2 = SignalFactoryValidLocation(
            category_assignment__category=techtek_sub_cat,
            text='De openbare klok op de hoek werkt niet.',
            status__state=workflow.AFGEHANDELD,
        )

        other_parent_cat = ParentCategoryFactory.create(
            slug=NOT_TECHTEK_MAIN_SLUG)
        other_cat = CategoryFactory.create(slug=NOT_TECHTEK_SUB_SLUG,
                                           parent=other_parent_cat)
        self._signal = SignalFactory(
            category_assignment__category=other_cat,
            text='Er ligt een accu in de sloot.',
            status__state=workflow.GEMELD,
        )
Esempio n. 5
0
    def setUp(self):
        self.department_read = Permission.objects.get(
            codename='sia_department_read')
        self.department_write = Permission.objects.get(
            codename='sia_department_write')
        self.sia_read_write_user.user_permissions.add(self.department_read)
        self.sia_read_write_user.user_permissions.add(self.department_write)

        self.department = DepartmentFactory.create()

        self.maincategory = ParentCategoryFactory.create()
        self.subcategory = CategoryFactory.create(parent=self.maincategory)
Esempio n. 6
0
    def test_filter_maincategory_and_category_slugs_not_a_unique_slug(self):
        parent_category = ParentCategoryFactory.create(name='not_unique')
        category = CategoryFactory.create(name='not_unique', parent=parent_category)

        SignalFactory.create(category_assignment__category=category)

        params = {
            'maincategory_slug': [parent_category.slug, ],
            'category_slug': [category.slug, ]
        }

        result_ids = self._request_filter_signals(params)
        self.assertEqual(1, len(result_ids))
Esempio n. 7
0
    def setUp(self):
        self.retrieve_sub_category_question_schema = self.load_json_schema(
            os.path.join(
                THIS_DIR,
                'json_schema',
                'get_signals_v1_public_questions_categories_{slug}_sub_categories_{sub_slug}.json'
            )
        )

        question = QuestionFactory.create_batch(1)
        question2 = QuestionFactory.create_batch(1)
        self.parent_category = ParentCategoryFactory.create(questions=question2)
        CategoryFactory.create_batch(1, parent=self.parent_category, questions=question)
        self.parent_category.refresh_from_db()
        super(TestCategoryQuestionEndpoints, self).setUp()
    def setUp(self):
        self.list_categories_schema = self.load_json_schema(
            os.path.join(THIS_DIR, 'json_schema',
                         'get_signals_v1_public_terms_categories.json'))
        self.retrieve_category_schema = self.load_json_schema(
            os.path.join(THIS_DIR, 'json_schema',
                         'get_signals_v1_public_terms_categories_{slug}.json'))
        self.retrieve_sub_category_schema = self.load_json_schema(
            os.path.join(
                THIS_DIR, 'json_schema',
                'get_signals_v1_public_terms_categories_{slug}_sub_categories_{sub_slug}.json'
            ))

        self.parent_category = ParentCategoryFactory.create()
        CategoryFactory.create_batch(5, parent=self.parent_category)
        self.parent_category.refresh_from_db()

        super(TestCategoryTermsEndpoints, self).setUp()