def test_required_if(self): price_msg = 'Widget Price is missing' description_msg = 'Widget Description is missing' self.assertTrue(description_msg not in self.instance.validate(), 'Optional field produces missing validation message') self.assertTrue( price_msg not in self.instance.validate(), 'required_if validation message incorrectly generated') self.instance.widget_available = D('Yes') self.assertTrue(price_msg in self.instance.validate(), 'required_if validation message not generated') self.instance.widget_price = 20.00 self.assertTrue( price_msg not in self.instance.validate(), 'required_if validation message incorrectly generated')
def test_other_equality(self): self.assertNotEqual(D('Test'), 'Test')
def test_coded_value_inequality(self): self.assertFalse(D('Test') != CodedValue(3, 'Test')) self.assertFalse(CodedValue(3, 'Test') != D('Test'))
def test_coded_value_equality(self): self.assertEqual(D('Test'), CodedValue(3, 'Test')) self.assertEqual(CodedValue(3, 'Test'), D('Test')) self.assertNotEqual(D('Test 1'), CodedValue(3, 'Test 2')) self.assertNotEqual(CodedValue(3, 'Test 2'), D('Test 1'))
def test_self_equality(self): self.assertEqual(D('Test'), D('Test')) self.assertNotEqual(D('Test 1'), D('Test 2'))
def test_init(self): with self.assertRaises(TypeError): D(25) with self.assertRaises(TypeError): D(None)
def is_available(self): return self.widget_available == D('Yes')
def test_get_description_for(self): self.assertEqual(self.instance.widget_available, D('No'))
def test_set_by_description(self): self.instance.widget_available = D('Yes') self.assertEqual(self.instance.widget_available, 100)