def test_unknown_message(self): """Test a JSON message without a type returns an error""" message = loader('bounce') message['notificationType'] = 'Not A Valid Notification' result = views.process_message(message, self.notification) self.assertEqual(result.status_code, 200) self.assertEqual( result.content.decode('ascii'), 'Unknown Notification Type')
def test_missing_fields(self): """Test that missing vital fields returns an error""" message = loader('bounce') del(message['mail']) result = views.process_message(message, self.notification) self.assertEqual(result.status_code, 200) self.assertEqual( result.content.decode('ascii'), 'Missing Vital Fields')
def test_unknown_message(self): """Test a JSON message without a type returns an error""" message = loader('bounce') message['notificationType'] = 'Not A Valid Notification' result = views.process_message(message, self.notification) self.assertEqual(result.status_code, 200) self.assertEqual(result.content.decode('ascii'), 'Unknown Notification Type')
def test_missing_fields(self): """Test that missing vital fields returns an error""" message = loader('bounce') del (message['mail']) result = views.process_message(message, self.notification) self.assertEqual(result.status_code, 200) self.assertEqual(result.content.decode('ascii'), 'Missing Vital Fields')
def test_bounce(self, mock): """Test that a bounce is sent to process_bounce""" views.process_message(self.bounce, self.notification) mock.assert_called_with(self.bounce, self.notification)
def test_complaint(self, mock): """Test that a complaint is sent to process_complaint""" notification = loader('complaint_notification') views.process_message(self.complaint, notification) mock.assert_called_with(self.complaint, notification)