def test_should_get_domain_error_when_data_is_none(self): # given campaign_id = 1 # when then with self.assertRaises(DomainError): campaign_mapper.map_create_timeline_entry_request( None, campaign_id)
def test_should_get_domain_error_when_title_was_not_given(self): # given data_json = {"sessionDate": "2050-01-01", "summaryText": "Test"} campaign_id = 1 # when then with self.assertRaises(DomainError): campaign_mapper.map_create_timeline_entry_request( data_json, campaign_id)
def test_should_get_domain_error_when_campaign_id_is_none(self): # given data_json = { "title": "Test", "sessionDate": "2050-01-01", "summaryText": "Test test test test test." } # when then with self.assertRaises(DomainError): campaign_mapper.map_create_timeline_entry_request(data_json, None)
def test_should_get_value_error_when_campaign_id_is_invalid(self): # given data_json = { "title": "Test", "sessionDate": "2050-01-01", "summaryText": "Test test test test test." } # when then with self.assertRaises(ValueError): campaign_mapper.map_create_timeline_entry_request( data_json, list())
def test_should_get_domain_error_when_session_date_format_is_invalid(self): # given data_json = { "title": "Test", "sessionDate": "01.01.2050", "summaryText": "Test test test test test." } campaign_id = 1 # when then with self.assertRaises(DomainError): campaign_mapper.map_create_timeline_entry_request( data_json, campaign_id)
def test_should_map_data_json_when_summary_text_was_not_given(self): # given data_json = {"title": "Test", "sessionDate": "2050-01-01"} campaign_id = 1 # when result = campaign_mapper.map_create_timeline_entry_request( data_json, campaign_id) # then self.assertEqual(result["title"], "Test") self.assertEqual(result["sessionDate"], date.fromisoformat("2050-01-01")) self.assertEqual(result["summaryText"], None) self.assertEqual(result["campaignId"], 1)