Esempio n. 1
0
    def test_boolean_value(self):
        product = self.create_product()
        bool_test = ProductQualityTest(store=self.store, product=product,
                                   test_type=ProductQualityTest.TYPE_BOOLEAN)
        bool_test.set_boolean_value(True)
        self.assertEqual(bool_test.get_boolean_value(), True)
        self.assertTrue(bool_test.result_value_passes(True))
        self.assertFalse(bool_test.result_value_passes(False))

        bool_test.set_boolean_value(False)
        self.assertEqual(bool_test.get_boolean_value(), False)
        self.assertTrue(bool_test.result_value_passes(False))
        self.assertFalse(bool_test.result_value_passes(True))

        self.assertRaises(AssertionError, bool_test.get_range_value)
Esempio n. 2
0
    def test_boolean_value(self):
        product = self.create_product()
        bool_test = ProductQualityTest(
            store=self.store,
            product=product,
            test_type=ProductQualityTest.TYPE_BOOLEAN)
        bool_test.set_boolean_value(True)
        self.assertEqual(bool_test.get_boolean_value(), True)
        self.assertTrue(bool_test.result_value_passes(True))
        self.assertFalse(bool_test.result_value_passes(False))

        bool_test.set_boolean_value(False)
        self.assertEqual(bool_test.get_boolean_value(), False)
        self.assertTrue(bool_test.result_value_passes(False))
        self.assertFalse(bool_test.result_value_passes(True))

        self.assertRaises(AssertionError, bool_test.get_range_value)
Esempio n. 3
0
    def test_is_completely_tested(self):
        item = self.create_production_item(quantity=10)
        order = item.order
        self.assertTrue(order.is_completely_tested())

        test1 = ProductQualityTest(store=self.store, product=item.product, test_type=ProductQualityTest.TYPE_BOOLEAN)
        test1.set_boolean_value(True)

        for material in item.order.get_material_items():
            material.product.storable.increase_stock(10, item.order.branch, StockTransactionHistory.TYPE_INITIAL, None)

        order.start_production()
        user = self.create_user()
        item.produce(1, produced_by=user, serials=[1])

        produced_item = order.produced_items.any()
        produced_item.test_passed = False
        self.assertFalse(order.is_completely_tested())
        produced_item.test_passed = True
        self.assertTrue(order.is_completely_tested())
Esempio n. 4
0
    def test_is_completely_tested(self):
        item = self.create_production_item(quantity=10)
        order = item.order
        self.assertTrue(order.is_completely_tested())

        test1 = ProductQualityTest(store=self.store,
                                   product=item.product,
                                   test_type=ProductQualityTest.TYPE_BOOLEAN)
        test1.set_boolean_value(True)

        for material in item.order.get_material_items():
            material.product.storable.increase_stock(
                10, item.order.branch, StockTransactionHistory.TYPE_INITIAL,
                None, self.current_user)

        order.start_production(self.current_user)
        user = self.create_user()
        item.produce(user, 1, serials=[1])

        produced_item = order.produced_items.any()
        produced_item.test_passed = False
        self.assertFalse(order.is_completely_tested())
        produced_item.test_passed = True
        self.assertTrue(order.is_completely_tested())
Esempio n. 5
0
    def test_production_quality_complete_process(self):
        # Order with one product to produce 4 units
        order = self.create_production_order()
        item = self.create_production_item(quantity=4, order=order)
        for material in item.order.get_material_items():
            storable = material.product.storable
            storable.increase_stock(4, order.branch,
                                    StockTransactionHistory.TYPE_INITIAL, None)

        test1 = ProductQualityTest(store=self.store, product=item.product,
                                   test_type=ProductQualityTest.TYPE_BOOLEAN)
        test1.set_boolean_value(True)
        test2 = ProductQualityTest(store=self.store, product=item.product,
                                   test_type=ProductQualityTest.TYPE_DECIMAL)
        test2.set_range_value(10, 20)
        order.start_production()
        self.assertEqual(order.status, ProductionOrder.ORDER_PRODUCING)

        # Since the item has tests, we cant produce anonimously
        self.assertRaises(AssertionError, item.produce, 1)
        user = self.create_user()

        # We still dont have any stock for this product
        storable = item.product.storable
        self.assertEqual(storable.get_balance_for_branch(order.branch), 0)

        self.assertEqual(order.produced_items.count(), 0)
        item.produce(1, user, [123456])
        self.assertEqual(order.produced_items.count(), 1)
        self.assertEqual(list(order.produced_items)[0].serial_number, 123456)

        self.assertEqual(order.status, ProductionOrder.ORDER_PRODUCING)

        # Produce the rest
        item.produce(3, user, [123457, 123458, 1234569])
        self.assertEqual(order.status, ProductionOrder.ORDER_QA)

        # For a produced item, initially, the tests should be empty
        p_item = list(order.produced_items.order_by(u'id'))[0]
        self.assertEqual(p_item.get_test_result(test1), None)
        self.assertEqual(p_item.get_test_result(test2), None)
        self.assertEqual(p_item.test_passed, False)

        # Add a first, faild test
        result = p_item.set_test_result_value(test1, False, user)
        self.assertEqual(p_item.get_test_result(test1), result)
        self.assertEqual(p_item.get_test_result(test2), None)

        self.assertEqual(result.get_boolean_value(), False)
        self.assertEqual(result.test_passed, False)

        # Set it to success
        p_item.set_test_result_value(test1, True, user)
        self.assertEqual(result.get_boolean_value(), True)
        self.assertEqual(result.test_passed, True)

        # Since the product has two tests, the produced item havent passed all
        # tests yet
        self.assertEqual(p_item.test_passed, False)

        # Add a result for the second test (failing)
        result = p_item.set_test_result_value(test2, Decimal(5), user)
        self.assertEqual(p_item.get_test_result(test2), result)

        self.assertEqual(result.get_decimal_value(), 5)
        self.assertEqual(result.test_passed, False)
        self.assertEqual(p_item.test_passed, False)

        # Now set the second test as a success
        p_item.set_test_result_value(test2, Decimal(15), user)
        self.assertEqual(result.test_passed, True)
        self.assertEqual(p_item.test_passed, True)

        # Lets now set the results for all tests as sucessful
        for p_item in order.produced_items.order_by(u'id'):
            p_item.set_test_result_value(test1, True, user)
            p_item.set_test_result_value(test2, Decimal(15), user)

        # Order should be now  CLOSED
        self.assertEqual(order.status, ProductionOrder.ORDER_CLOSED)

        # Items should have entered stock
        for p_item in order.produced_items:
            self.assertEqual(p_item.entered_stock, True)

        storable = item.product.storable
        self.assertEqual(storable.get_balance_for_branch(order.branch), 4)
Esempio n. 6
0
    def test_production_quality_complete_process(self):
        # Order with one product to produce 4 units
        order = self.create_production_order()
        item = self.create_production_item(quantity=4, order=order)
        for material in item.order.get_material_items():
            storable = material.product.storable
            storable.increase_stock(4, order.branch,
                                    StockTransactionHistory.TYPE_INITIAL, None,
                                    self.current_user)

        test1 = ProductQualityTest(store=self.store,
                                   product=item.product,
                                   test_type=ProductQualityTest.TYPE_BOOLEAN)
        test1.set_boolean_value(True)
        test2 = ProductQualityTest(store=self.store,
                                   product=item.product,
                                   test_type=ProductQualityTest.TYPE_DECIMAL)
        test2.set_range_value(10, 20)
        order.start_production(self.current_user)
        self.assertEqual(order.status, ProductionOrder.ORDER_PRODUCING)

        # Since the item has tests, we cant produce anonimously
        with self.assertRaises(AssertionError):
            item.produce(self.current_user, 1)
        user = self.create_user()

        # We still dont have any stock for this product
        storable = item.product.storable
        self.assertEqual(storable.get_balance_for_branch(order.branch), 0)

        self.assertEqual(order.produced_items.count(), 0)
        item.produce(user, 1, [123456])
        self.assertEqual(order.produced_items.count(), 1)
        self.assertEqual(list(order.produced_items)[0].serial_number, 123456)

        self.assertEqual(order.status, ProductionOrder.ORDER_PRODUCING)

        # Produce the rest
        item.produce(user, 3, [123457, 123458, 1234569])
        self.assertEqual(order.status, ProductionOrder.ORDER_QA)

        # For a produced item, initially, the tests should be empty
        p_item = list(order.produced_items.order_by(u'id'))[0]
        self.assertEqual(p_item.get_test_result(test1), None)
        self.assertEqual(p_item.get_test_result(test2), None)
        self.assertEqual(p_item.test_passed, False)

        # Add a first, faild test
        result = p_item.set_test_result_value(test1, False, user)
        self.assertEqual(p_item.get_test_result(test1), result)
        self.assertEqual(p_item.get_test_result(test2), None)

        self.assertEqual(result.get_boolean_value(), False)
        self.assertEqual(result.test_passed, False)

        # Set it to success
        p_item.set_test_result_value(test1, True, user)
        self.assertEqual(result.get_boolean_value(), True)
        self.assertEqual(result.test_passed, True)

        # Since the product has two tests, the produced item havent passed all
        # tests yet
        self.assertEqual(p_item.test_passed, False)

        # Add a result for the second test (failing)
        result = p_item.set_test_result_value(test2, Decimal(5), user)
        self.assertEqual(p_item.get_test_result(test2), result)

        self.assertEqual(result.get_decimal_value(), 5)
        self.assertEqual(result.test_passed, False)
        self.assertEqual(p_item.test_passed, False)

        # Now set the second test as a success
        p_item.set_test_result_value(test2, Decimal(15), user)
        self.assertEqual(result.test_passed, True)
        self.assertEqual(p_item.test_passed, True)

        # Lets now set the results for all tests as sucessful
        for p_item in order.produced_items.order_by(u'id'):
            p_item.set_test_result_value(test1, True, user)
            p_item.set_test_result_value(test2, Decimal(15), user)

        # Order should be now  CLOSED
        self.assertEqual(order.status, ProductionOrder.ORDER_CLOSED)

        # Items should have entered stock
        for p_item in order.produced_items:
            self.assertEqual(p_item.entered_stock, True)

        storable = item.product.storable
        self.assertEqual(storable.get_balance_for_branch(order.branch), 4)