Beispiel #1
0
    def test_code_with_multiple_company(self):
        current_ean = TEST_EAN13
        company1 = CompanyFactory.create(name='test-company1', description='test-description')
        company2 = CompanyFactory.create(name='test-company2', description='test-description')

        product = ProductFactory.create(code=current_ean, company=company1, brand__company=company2)

        with mock.patch("pola.logic.get_by_code", return_value=product):
            response = get_result_from_code(current_ean)
        # TODO: Add support for multiple companies in this response
        expected_response = (
            {
                'altText': None,
                'card_type': 'type_grey',
                'code': '5900084231145',
                'description': 'test-description',
                'is_friend': False,
                'name': company1.official_name,
                'plCapital': None,
                'plCapital_notes': None,
                'plNotGlobEnt': None,
                'plNotGlobEnt_notes': None,
                'plRegistered': None,
                'plRegistered_notes': None,
                'plRnD': None,
                'plRnD_notes': None,
                'plScore': None,
                'plWorkers': None,
                'plWorkers_notes': None,
                'product_id': product.id,
                'report_button_text': 'Zgłoś',
                'report_button_type': 'type_white',
                'report_text': ('Zgłoś jeśli posiadasz bardziej aktualne dane na temat tego produktu'),
                'sources': {},
            },
            {"was_590": True, "was_plScore": False, "was_verified": False},
            product,
        )
        self.maxDiff = None
        self.assertEqual(expected_response[0], response[0])
        self.assertEqual(expected_response, response)
Beispiel #2
0
 def test_should_return_200_when_polish_and_known_product(self):
     c = CompanyFactory.create(
         plCapital=100,
         plWorkers=0,
         plRnD=100,
         plRegistered=100,
         plNotGlobEnt=100,
         description="KOTEK",
         sources="KOTEK|BBBB",
         verified=True,
         is_friend=True,
         plCapital_notes="AA",
         plWorkers_notes="BBB",
         plRnD_notes="CCC",
         plRegistered_notes="DDD",
         plNotGlobEnt_notes="EEEE",
     )
     p = ProductFactory.create(code=5900049011829, company=c, brand=None)
     response = self.json_request(self.url + "?device_id=TEST-DEVICE-ID&code=" + str(p.code))
     self.assertEqual(200, response.status_code)
Beispiel #3
0
    def setUp(self):
        self.aem_admin = UserFactory.create(group=AemGroupFactory.create(
            slug_field=settings.AEM_ADMIN_SLUG_FIELD,
            linked_group__name=settings.AEM_ADMIN_LINKED_GROUP_NAME,
            can_add_permission_slugs=settings.
            AEM_ADMIN_CAN_ADD_USER_PERMISSIONS,
            client_permissions=settings.AEM_ADMIN_CLIENT_PERMISSIONS,
            customer_permissions=settings.AEM_ADMIN_CUSTOMER_PERMISSIONS,
            company_permissions=settings.AEM_ADMIN_COMPANY_PERMISSIONS))

        self.aem_employee = UserFactory.create(group=AemGroupFactory.create(
            slug_field=settings.AEM_EMPLOYEE_SLUG_FIELD,
            linked_group__name=settings.AEM_EMPLOYEE_LINKED_GROUP_NAME,
            can_add_permission_slugs=settings.
            AEM_EMPLOYEE_CAN_ADD_USER_PERMISSIONS,
            client_permissions=settings.AEM_EMPLOYEE_CLIENT_PERMISSIONS,
            customer_permissions=settings.AEM_EMPLOYEE_CUSTOMER_PERMISSIONS,
            company_permissions=settings.AEM_EMPLOYEE_COMPANY_PERMISSIONS))

        client_company = CompanyFactory.create()

        self.aem_customer_super_user = UserFactory.create(
            company=client_company,
            group=AemGroupFactory.create(
                slug_field=settings.AEM_CUSTOMER_SUPER_USER_SLUG_FIELD,
                linked_group__name=settings.
                AEM_CUSTOMER_SUPER_USER_LINKED_GROUP_NAME,
                can_add_permission_slugs=settings.
                AEM_CUSTOMER_SUPER_USER_CAN_ADD_USER_PERMISSIONS,
                client_permissions=settings.
                AEM_CUSTOMER_SUPER_USER_CLIENT_PERMISSIONS,
                customer_permissions=settings.
                AEM_CUSTOMER_SUPER_USER_CUSTOMER_PERMISSIONS,
                company_permissions=settings.
                AEM_CUSTOMER_SUPER_USER_COMPANY_PERMISSIONS))

        self.aem_customer_admin = UserFactory.create(
            company=client_company,
            group=AemGroupFactory.create(
                slug_field=settings.AEM_CUSTOMER_ADMIN_SLUG_FIELD,
                linked_group__name=settings.
                AEM_CUSTOMER_ADMIN_LINKED_GROUP_NAME,
                can_add_permission_slugs=settings.
                AEM_CUSTOMER_ADMIN_CAN_ADD_USER_PERMISSIONS,
                client_permissions=settings.
                AEM_CUSTOMER_ADMIN_CLIENT_PERMISSIONS,
                customer_permissions=settings.
                AEM_CUSTOMER_ADMIN_CUSTOMER_PERMISSIONS,
                company_permissions=settings.
                AEM_CUSTOMER_ADMIN_COMPANY_PERMISSIONS))

        self.aem_customer_user = UserFactory.create(
            company=client_company,
            group=AemGroupFactory.create(
                slug_field=settings.AEM_CUSTOMER_USER_SLUG_FIELD,
                linked_group__name=settings.
                AEM_CUSTOMER_USER_LINKED_GROUP_NAME,
                can_add_permission_slugs=settings.
                AEM_CUSTOMER_USER_CAN_ADD_USER_PERMISSIONS,
                client_permissions=settings.
                AEM_CUSTOMER_USER_CLIENT_PERMISSIONS,
                customer_permissions=settings.
                AEM_CUSTOMER_USER_CUSTOMER_PERMISSIONS,
                company_permissions=settings.
                AEM_CUSTOMER_USER_COMPANY_PERMISSIONS))