Esempio n. 1
0
    def test_stocklocationinventory_list_filter(self, member1, client1,
                                                planninguser1):
        with tenant_context(member1.tenant):
            client1.force_login(planninguser1)
            product1 = factories.ProductFactory(name='test product')

            location1 = factories.StockLocationFactory()

            factories.StockLocationInventoryFactory(
                product=product1,
                location=location1,
                amount=5,
            )

            product2 = factories.ProductFactory(name='nog een product')

            location2 = factories.StockLocationFactory()

            factories.StockLocationInventoryFactory(
                product=product2,
                location=location2,
                amount=5,
            )

        response = client1.get(
            '%s?location=%d' %
            (reverse('stocklocationinventory-list'), location1.id))

        assert response.status_code == status.HTTP_200_OK
        assert response.data['count'] == 1
        assert response.data['results'][0]['amount'] == 5
Esempio n. 2
0
    def test_stocklocationinventory_list_product_types(self, member1, client1,
                                                       planninguser1):
        with tenant_context(member1.tenant):
            client1.force_login(planninguser1)
            prod1 = factories.ProductFactory(product_type='type 1')

            prod2 = factories.ProductFactory(product_type='type 2')

            prod3 = factories.ProductFactory(product_type='type 3')

            loc1 = factories.StockLocationFactory()

            factories.StockLocationInventoryFactory(
                product=prod1,
                location=loc1,
                amount=5,
            )

            factories.StockLocationInventoryFactory(
                product=prod1,
                location=loc1,
                amount=15,
            )

            factories.StockLocationInventoryFactory(
                product=prod2,
                location=loc1,
                amount=5,
            )

            factories.StockLocationInventoryFactory(
                product=prod3,
                location=loc1,
                amount=5,
            )

        url = '%s?location_id=%s' % (
            reverse('stocklocationinventory-list-product-types'), loc1.id)
        response = client1.get(url)

        assert response.status_code == status.HTTP_200_OK
        assert len(response.data) == 3
Esempio n. 3
0
    def test_stocklocationinventory_delete(self, member1, client1,
                                           planninguser1):
        with tenant_context(member1.tenant):
            client1.force_login(planninguser1)
            prod1 = factories.ProductFactory()
            loc1 = factories.StockLocationFactory()

            inventory = factories.StockLocationInventoryFactory(
                product=prod1,
                location=loc1,
                amount=5,
            )

        url = reverse('stocklocationinventory-detail',
                      kwargs={'pk': inventory.id})
        response = client1.delete(url, format='json')

        assert response.status_code == status.HTTP_204_NO_CONTENT
Esempio n. 4
0
    def test_stocklocationinventory_list(self, member1, client1,
                                         planninguser1):
        with tenant_context(member1.tenant):
            client1.force_login(planninguser1)
            product = factories.ProductFactory()
            location = factories.StockLocationFactory()

        factories.StockLocationInventoryFactory(
            product=product,
            location=location,
            amount=5,
        )

        response = client1.get(reverse('stocklocationinventory-list'))

        assert response.status_code == status.HTTP_200_OK
        assert response.data['count'] == 1
        assert response.data['results'][0]['amount'] == 5
Esempio n. 5
0
    def test_stocklocationinventory_retrieve(self, member1, client1,
                                             planninguser1):
        with tenant_context(member1.tenant):
            client1.force_login(planninguser1)
            prod1 = factories.ProductFactory()
            loc1 = factories.StockLocationFactory()

        inventory = factories.StockLocationInventoryFactory(
            product=prod1,
            location=loc1,
            amount=5,
        )

        response = client1.get(
            reverse('stocklocationinventory-detail',
                    kwargs={'pk': inventory.id}))

        assert response.status_code == status.HTTP_200_OK
        assert response.data['amount'] == 5