def test_message_with_different_collection_case_not_equal(self): """testing two different Message objects are not equal""" message1 = Message('1', '2', '3', '4', '5', 'ACollectionCase', 'f1a5e99c-8edf-489a-9c72-6cabe6c387f', 'ASurveyType', 'ACollectionExercise') message2 = Message('1', '2', '3', '4', '5', 'AnotherCollectionCase', 'f1a5e99c-8edf-489a-9c72-6cabe6c387f', 'ASurveyType', 'AnotherCollectionExercise') self.assertTrue(message1 != message2)
def test_message_with_different_business_id_not_equal(self): """testing two different Message objects are not equal""" message1 = Message('1', '2', '3', '4', '5', 'ACollectionCase', 'f1a5e99c-8edf-489a-9c72-6cabe6c387fc', 'ASurveyType', 'ACollectionExercise') message2 = Message('1', '2', '3', '4', '5', 'ACollectionCase', '7fc0e8ab-189c-4794-b8f4-9f05a1db185b', 'ASurveyType', 'AnotherCollectionExercise') self.assertTrue(message1 != message2)
def test_message(self): """creating Message object""" sut = Message('from', 'subject', 'body', ['to'], '5', 'AMsgId', 'ACollectionCase', 'ASurveyType', 'f1a5e99c-8edf-489a-9c72-6cabe6c387fc', 'CollectionExercise') sut_str = repr(sut) expected = '<Message(msg_id=AMsgId msg_to=[\'to\'] msg_from=from subject=subject body=body thread_id=5 collection_case=ACollectionCase ' \ 'business_id=f1a5e99c-8edf-489a-9c72-6cabe6c387fc collection_exercise=CollectionExercise survey=ASurveyType from_internal=False)>' self.assertEqual(sut_str, expected)
def setUp(self): """setup test environment""" app = create_app() app.testing = True self.engine = create_engine(app.config['SQLALCHEMY_DATABASE_URI']) self.test_message = Message(**{'msg_to': 'tej', 'msg_from': 'gemma', 'subject': 'MyMessage', 'body': 'hello', 'thread_id': ""}) with app.app_context(): database.db.init_app(current_app) database.db.drop_all() database.db.create_all() self.db = database.db self.app = app
def test_valid_domain_message_passes_deserialization(self): """checking marshaling message object to json does not raise errors""" schema = MessageSchema() message_object = Message( **{ 'msg_to': ['Tej'], 'msg_from': 'Gemma', 'subject': 'MyMessage', 'body': 'hello', 'thread_id': "", 'business_id': "7fc0e8ab-189c-4794-b8f4-9f05a1db185b" }) message_json = schema.dumps(message_object) self.assertTrue(message_json.errors == {})
def test_message_not_equal_to_different_type(self): message1 = Message('1', '2', '3', '4', '5', 'ACollectionCase', 'f1a5e99c-8edf-489a-9c72-6cabe6c387fc', 'ASurveyType') self.assertFalse(message1 == "Message1")
def test_message_equal(self): """testing two same Message objects are equal""" message1 = Message('1', '2', '3', '4', '5', 'MsgId') message2 = Message('1', '2', '3', '4', '5', 'MsgId') self.assertTrue(message1 == message2)