Esempio n. 1
0
    def test_index_view_shows_only_available_objects(self):
        """
        Test that no URL can be reached
        unless a corresponding CompanyUser exists
        """
        username, password = '******', 'wis_pwa'
        user = add_User(username=username, password=password)
        company3 = add_Company(
            nombre_comercial='Tienda 3',
            ruc='1234567842',
            razon_social='Pace Pil',
            direccion_matriz="C del pepeno")
        add_CompanyUser(user=user, company=company3)
        establecimiento3 = add_instance(
            models.Establecimiento,
            company=company3,
            descripcion="Matriz",
            direccion='C del pepano',
            codigo="001",
        )

        add_instance(models.PuntoEmision,
                     establecimiento=establecimiento3,
                     descripcion="Caja de la matriz",
                     codigo="001")

        ob3 = self.cls(company=company3, **self.data)
        ob3.save()

        c = Client()
        r = c.post("/accounts/login/",
                   {'username': username, 'password': password})
        self.assertEquals(r['location'],
                          "http://testserver" + reverse('billing_index'))

        reverse_index_args = (company3.id,)
        r = c.get(
            reverse(self.index_view, args=reverse_index_args))
        context_object_name = r.context_data['view'].context_object_name
        self.assertEquals(
            # queryset objects are never equal
            # so I have to convert them to lists to compare properly
            list(r.context_data[context_object_name]),
            list(self.cls.objects.filter(company=company3)),
            "The list view shows objects from a different company")

        r = self.c.get(
            reverse(self.index_view, args=self.reverse_index_args))
        context_object_name = r.context_data['view'].context_object_name
        self.assertEquals(
            # queryset objects are never equal
            # so I have to convert them to lists to compare properly
            list(r.context_data[context_object_name]),
            list(self.cls.objects.filter(company=self.company)),
            "The list view shows objects from a different company")
Esempio n. 2
0
    def test_index_view_shows_only_available_objects(self):
        """
        Test that no URL can be reached
        unless a corresponding CompanyUser exists
        """
        username, password = '******', 'wis_pwa'
        user = add_User(username=username, password=password)
        company3 = add_Company(nombre_comercial='Tienda 3',
                               ruc='1234567842',
                               razon_social='Pace Pil',
                               direccion_matriz="C del pepeno")
        add_CompanyUser(user=user, company=company3)
        establecimiento3 = add_instance(
            models.Establecimiento,
            company=company3,
            descripcion="Matriz",
            direccion='C del pepano',
            codigo="001",
        )

        add_instance(models.PuntoEmision,
                     establecimiento=establecimiento3,
                     descripcion="Caja de la matriz",
                     codigo="001")

        ob3 = self.cls(company=company3, **self.data)
        ob3.save()

        c = Client()
        r = c.post("/accounts/login/", {
            'username': username,
            'password': password
        })
        self.assertEquals(r['location'],
                          "http://testserver" + reverse('billing_index'))

        reverse_index_args = (company3.id, )
        r = c.get(reverse(self.index_view, args=reverse_index_args))
        context_object_name = r.context_data['view'].context_object_name
        self.assertEquals(
            # queryset objects are never equal
            # so I have to convert them to lists to compare properly
            list(r.context_data[context_object_name]),
            list(self.cls.objects.filter(company=company3)),
            "The list view shows objects from a different company")

        r = self.c.get(reverse(self.index_view, args=self.reverse_index_args))
        context_object_name = r.context_data['view'].context_object_name
        self.assertEquals(
            # queryset objects are never equal
            # so I have to convert them to lists to compare properly
            list(r.context_data[context_object_name]),
            list(self.cls.objects.filter(company=self.company)),
            "The list view shows objects from a different company")
Esempio n. 3
0
    def test_view_index_multiple_companies(self):
        """
        A logged-in user can view the billing index,
        and the index shows the available companies
        """
        add_instance(models.CompanyUser, user=self.user, company=self.company2)

        response = self.c.get(reverse('billing_index'))
        self.assertEquals(response.status_code, 200)

        for c in [self.company, self.company2]:
            self.assertIn(c, response.context['companies'])
            self.assertContains(response, c)
Esempio n. 4
0
    def setUp(self):
        username, password = '******', 'paco_pw'
        self.user = add_User(username=username, password=password)

        self.company = add_instance(models.Company,
                                    nombre_comercial='Tienda 1',
                                    ruc='1234567890',
                                    razon_social='Paco Pil',
                                    direccion_matriz="C del pepino")

        self.company_user = add_instance(models.CompanyUser,
                                         user=self.user,
                                         company=self.company)
Esempio n. 5
0
    def setUp(self):
        super(MakeBaseInstances, self).setUp()
        self.iva = add_instance(
            models.Iva,
            descripcion="12%",
            codigo='12',
            porcentaje=Decimal(12.0))

        self.ice = add_instance(
            models.Ice,
            descripcion="Bebidas gaseosas",
            codigo='3051',
            porcentaje=50.0)
Esempio n. 6
0
    def setUp(self):
        username, password = '******', 'paco_pw'
        self.user = add_User(username=username, password=password)

        self.company = add_instance(
            models.Company,
            nombre_comercial='Tienda 1',
            ruc='1234567890',
            razon_social='Paco Pil',
            direccion_matriz="C del pepino")

        self.company_user = add_instance(
            models.CompanyUser,
            user=self.user,
            company=self.company)
Esempio n. 7
0
    def test_view_index_multiple_companies(self):
        """
        A logged-in user can view the billing index,
        and the index shows the available companies
        """
        add_instance(models.CompanyUser,
                     user=self.user,
                     company=self.company2)

        response = self.c.get(reverse('billing_index'))
        self.assertEquals(response.status_code, 200)

        for c in [self.company, self.company2]:
            self.assertIn(c, response.context['companies'])
            self.assertContains(response, c)
Esempio n. 8
0
    def setUp(self):
        super(MakeBaseInstances, self).setUp()
        self.company = add_instance(models.Company, **base_data['Company'])

        self.establecimiento = add_instance(models.Establecimiento,
                                            company=self.company,
                                            **base_data['Establecimiento'])

        self.punto_emision = add_instance(models.PuntoEmision,
                                          establecimiento=self.establecimiento,
                                          **base_data['PuntoEmision'])

        self.user = add_User(username="******", password='******')
        self.company_user = add_instance(models.CompanyUser,
                                         company=self.company,
                                         user=self.user)
Esempio n. 9
0
 def setUp(self):
     super(IndexViewTests, self).setUp()
     self.company2 = add_instance(models.Company,
                                  nombre_comercial='Tienda 2',
                                  ruc='1234567892',
                                  razon_social='Paca Pil',
                                  direccion_matriz="C del pepano")
Esempio n. 10
0
    def setUp(self):
        super(MakeBaseInstances, self).setUp()
        self.company = add_instance(models.Company, **base_data['Company'])

        self.establecimiento = add_instance(models.Establecimiento,
                                            company=self.company,
                                            **base_data['Establecimiento'])

        self.punto_emision = add_instance(models.PuntoEmision,
                                          establecimiento=self.establecimiento,
                                          **base_data['PuntoEmision'])

        self.user = add_User(username="******", password='******')
        self.company_user = add_instance(models.CompanyUser,
                                         company=self.company,
                                         user=self.user)
Esempio n. 11
0
 def setUp(self):
     super(IndexViewTests, self).setUp()
     self.company2 = add_instance(
         models.Company,
         nombre_comercial='Tienda 2',
         ruc='1234567892',
         razon_social='Paca Pil',
         direccion_matriz="C del pepano")
Esempio n. 12
0
    def setUp(self):
        self.company = add_instance(
            billing.models.Company,
            **billing.testsuite.test_models.base_data['Company'])

        self.bill_data = dict(
            number='33344556677',
            numero_autorizacion='12342423423',
            ambiente_sri='pruebas',
            clave_acceso='4545454545',
            )

        self.bill = add_instance(
            billing.models.Bill,
            company=self.company,
            date=get_date(),
            xml_content='<xml>stufff</xml>',
            fecha_autorizacion=date(2015, 5, 1),
            issues='asdf',  # FIXME, should be in response
            **self.bill_data)
Esempio n. 13
0
    def setUp(self):
        self.company = add_instance(
            billing.models.Company,
            **billing.testsuite.test_models.base_data['Company'])

        self.bill_data = dict(
            number='33344556677',
            numero_autorizacion='12342423423',
            ambiente_sri='pruebas',
            clave_acceso='4545454545',
        )

        self.bill = add_instance(
            billing.models.Bill,
            company=self.company,
            date=get_date(),
            xml_content='<xml>stufff</xml>',
            fecha_autorizacion=date(2015, 5, 1),
            issues='asdf',  # FIXME, should be in response
            **self.bill_data)
Esempio n. 14
0
 def setUp(self):
     super(MakeBaseInstances, self).setUp()
     self.item = add_instance(models.Item,
                              name="Test Item",
                              code="12345",
                              description="No desc",
                              tipo='producto',
                              decimales_qty=0,
                              company=self.company)
     self.item.tax_items.add(self.iva, self.ice)
     self.batch = add_instance(models.Batch,
                               item=self.item,
                               unit_cost=Decimal(5),
                               code='444',
                               acquisition_date=get_date())
     self.sku = add_instance(models.SKU,
                             batch=self.batch,
                             qty=Decimal(10),
                             unit_price=Decimal(20),
                             establecimiento=self.establecimiento,
                             location="In the backyard")
Esempio n. 15
0
 def setUp(self):
     super(MakeBaseInstances, self).setUp()
     self.item = add_instance(
         models.Item,
         name="Test Item",
         code="12345",
         description="No desc",
         tipo='producto',
         decimales_qty=0,
         company=self.company)
     self.item.tax_items.add(self.iva, self.ice)
     self.batch = add_instance(
         models.Batch,
         item=self.item,
         unit_cost=Decimal(5),
         code='444',
         acquisition_date=get_date())
     self.sku = add_instance(
         models.SKU,
         batch=self.batch,
         qty=Decimal(10),
         unit_price=Decimal(20),
         establecimiento=self.establecimiento,
         location="In the backyard")
Esempio n. 16
0
 def setUp(self):
     self.company = add_instance(
         billing.models.Company,
         **billing.testsuite.test_models.base_data['Company'])
Esempio n. 17
0
 def setUp(self):
     super(MakeBaseInstances, self).setUp()
     self.customer = add_instance(
         models.Customer,
         company=self.company,
         **base_data['BaseCustomer'])
Esempio n. 18
0
 def setUp(self):
     self.company = add_instance(
         billing.models.Company,
         **billing.testsuite.test_models.base_data['Company'])
Esempio n. 19
0
 def setUp(self):
     super(MakeBaseInstances, self).setUp()
     self.customer = add_instance(models.Customer,
                                  company=self.company,
                                  **base_data['BaseCustomer'])