def test_send_message_to_empty(): test_iid = test_utils.make_instance() mtype = 'test' contents = ['quack', 'duck'] test_utils.send_new_message(test_iid, mtype, '', contents) response = test_utils.get_messages(test_iid, mtype, '', 1) assert response[0]['type'] == mtype assert response[0]['contents'] == ['quack', 'duck']
def test_get_all_types(): test_iid = test_utils.make_instance() mtype = 'test' contents = ['quack', 'duck'] test_utils.send_new_message(test_iid, 'type1', [firstpid], contents) test_utils.send_new_message(test_iid, 'type2', [firstpid], contents) response = test_utils.get_messages(test_iid, '', '', 2) assert response[0]['type'] == 'type1' assert response[1]['type'] == 'type2'
def test_messages_email_strip(): test_iid = test_utils.make_instance() mtype = 'test' contents = ['quack', 'duck'] recipient = ['"Bob Jones" <*****@*****.**>'] test_utils.send_new_message(test_iid, mtype, recipient, contents, pid = '"Frank Lloyd" <*****@*****.**>') response = test_utils.get_messages(test_iid, mtype, '', 1, pid = '"Bob Johnson" <*****@*****.**>') assert response[0]['type'] == mtype
def test_send_message_to_multiple_people(): test_iid = test_utils.make_instance() mtype = 'test' contents = ['quack', 'duck'] player2 = '*****@*****.**' test_utils.add_player(test_iid, player2) test_utils.send_new_message(test_iid, 'type1', [firstpid, player2], contents) test_utils.send_new_message(test_iid, 'type2', [firstpid, player2], contents) response = test_utils.get_messages(test_iid, '', '', 2) assert response[0]['type'] == 'type1' assert response[1]['type'] == 'type2' response = test_utils.get_messages(test_iid, '', '', 2, pid = player2) assert response[0]['type'] == 'type1' assert response[1]['type'] == 'type2'
def test_only_get_new_messages(): test_iid = test_utils.make_instance() mtype = 'test' contents = ['quack', 'duck'] test_utils.send_new_message(test_iid, mtype, [firstpid], contents) response = test_utils.get_messages(test_iid, mtype, '', 1) date = response[0]['mtime'] assert date response = test_utils.get_messages(test_iid, mtype, date, 1) assert len(response) == 0 test_utils.send_new_message(test_iid, mtype, [firstpid], contents) response = test_utils.get_messages(test_iid, mtype, date, 1) assert len(response) == 1
def test_send_message_to_multiple_people(): test_iid = test_utils.make_instance() mtype = 'test' contents = ['quack', 'duck'] player2 = '*****@*****.**' test_utils.add_player(test_iid, player2) test_utils.send_new_message(test_iid, 'type1', [firstpid, player2], contents) test_utils.send_new_message(test_iid, 'type2', [firstpid, player2], contents) response = test_utils.get_messages(test_iid, '', '', 2) assert response[0]['type'] == 'type1' assert response[1]['type'] == 'type2' response = test_utils.get_messages(test_iid, '', '', 2, pid=player2) assert response[0]['type'] == 'type1' assert response[1]['type'] == 'type2'
def test_messages_email_strip(): test_iid = test_utils.make_instance() mtype = 'test' contents = ['quack', 'duck'] recipient = ['"Bob Jones" <*****@*****.**>'] test_utils.send_new_message(test_iid, mtype, recipient, contents, pid='"Frank Lloyd" <*****@*****.**>') response = test_utils.get_messages(test_iid, mtype, '', 1, pid='"Bob Johnson" <*****@*****.**>') assert response[0]['type'] == mtype