示例#1
0
 def test_validate_valid(self):
     tender = Tender(
         {"title": "whatever", "mainProcurementCategory": "goods", "milestones": [copy.deepcopy(self.milestones)]}
     )
     tender.validate()
     data = tender.serialize("embedded")
     self.assertIn("mainProcurementCategory", data)
     self.assertIn(data["mainProcurementCategory"], "goods")
示例#2
0
 def test_validate_not_valid(self):
     tender = Tender(
         {"title": "whatever", "mainProcurementCategory": "test", "milestones": [copy.deepcopy(self.milestones)]}
     )
     with self.assertRaises(ModelValidationError) as e:
         tender.validate()
     self.assertEqual(
         e.exception.messages, {"mainProcurementCategory": ["Value must be one of ['goods', 'services', 'works']."]}
     )
示例#3
0
 def test_validate_empty(self):
     with self.assertRaises(ModelValidationError) as e:
         tender = Tender({
             "title": "whatever",
             "milestones": [copy.deepcopy(self.milestones)]
         })
         tender.validate()
     self.assertEqual(
         e.exception.message,
         {"mainProcurementCategory": [u"This field is required."]})
 def test_validate_empty(self):
     tender = Tender({"title": "whatever"})
     tender.validate()
     data = tender.serialize("embedded")
     self.assertNotIn("mainProcurementCategory", data)