def test_create_invalid_contract(self): contract_data = { 'organizer_email': '1234', 'signed_date': INVALID_SIGN_DATE, 'description': 'some description', 'case_number': '345978', 'salesforce_id': '23465789', 'salesforce_case_id': '4680990', } expected_error_dict_messages = { 'link_to_salesforce_case': ['This field cannot be blank.'], 'organizer_account_name': ['This field cannot be blank.'], 'organizer_email': ['Enter a valid email address.'], 'signed_date': [ "'{}' value has an invalid date format. " "It must be in YYYY-MM-DD format.".format(INVALID_SIGN_DATE) ] } contract = Contract(**contract_data) with self.assertRaises(ValidationError) as cm: contract.full_clean() self.assertEqual(expected_error_dict_messages, cm.exception.message_dict)
def test_create_valid_contract(self): contract_data = { 'organizer_account_name': 'Planner Eventos', 'organizer_email': '*****@*****.**', 'signed_date': '2019-09-14', 'description': 'some description', 'case_number': '345978', 'salesforce_id': '23465789', 'salesforce_case_id': '4680990', 'link_to_salesforce_case': 'https://pe33.zzxxzzz.com/5348fObs', } contract = Contract(**contract_data) contract.full_clean() contract_data.pop('signed_date') contract.full_clean()