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)
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)
def test_decimal_value(self): product = self.create_product() test = ProductQualityTest(store=self.store, product=product, test_type=ProductQualityTest.TYPE_DECIMAL) test.set_range_value(Decimal(10), Decimal(20)) self.assertEqual(test.get_range_value(), (Decimal(10), Decimal(20))) self.assertFalse(test.result_value_passes(Decimal('9.99'))) self.assertTrue(test.result_value_passes(Decimal(10))) self.assertTrue(test.result_value_passes(Decimal(15))) self.assertTrue(test.result_value_passes(Decimal(20))) self.assertFalse(test.result_value_passes(Decimal('20.0001'))) self.assertFalse(test.result_value_passes(Decimal(30))) test.set_range_value(Decimal(30), Decimal(40)) self.assertEqual(test.get_range_value(), (Decimal(30), Decimal(40))) self.assertTrue(test.result_value_passes(Decimal(30))) # Negative values test.set_range_value(Decimal(-5), Decimal(5)) self.assertEqual(test.get_range_value(), (Decimal(-5), Decimal(5))) self.assertRaises(AssertionError, test.get_boolean_value)