def pytest_runtest_teardown(): conn = DynamoDBConnection() conn.delete_table(Message.get_table_name()) conn.delete_table(ChannelJoinInfo.get_table_name()) conn.delete_table(ChannelUsageLog.get_table_name()) conn.delete_table(Channel.get_table_name()) conn.delete_table(ChannelWithdrawalLog.get_table_name()) Message.create_table() ChannelWithdrawalLog.create_table() ChannelJoinInfo.create_table() ChannelUsageLog.create_table() Channel.create_table()
def test_publish_version_2(channel1, user1, user2): with AuthenticatedClient(user1, version=u'2.0') as sock1: sock1.sendobj(dict(method='attend', channel=channel1)) sock1.recvobj() with AuthenticatedClient(user2, version=u'2.0') as sock2: sock2.sendobj(dict(method='attend', channel=channel1)) sock2.recvobj() sock1.sendobj( dict(method='publish', message='Hi!', type='text', channel=channel1)) response1 = sock1.recvobj() response2 = sock2.recvobj() assert response1 == response2 assert response1['method'] == 'publish' assert response1['writer'] == user1 assert response1['message'] == 'Hi!' time.sleep(0.3) channel_usage_log = ChannelUsageLog.get_item( datetime.datetime.fromtimestamp( response1['published_at']).strftime('%Y-%m-%d'), response1['channel']) assert channel_usage_log.last_published_at == response1['published_at']
def test_publish_version_3(channel1, user1, user2): with AuthenticatedClient(user1) as sock1: with AuthenticatedClient(user2) as sock2: sock1.sendobj(dict(method='publish', message='Hi!', type='text', channel=channel1)) response1 = sock1.recvobj() response2 = sock2.recvobj() assert response1 == response2 assert response1['method'] == 'publish' assert response1['writer'] == user1 assert response1['message'] == 'Hi!' time.sleep(0.3) channel_usage_log = ChannelUsageLog.get_item( datetime.datetime.fromtimestamp(response1['published_at']).strftime('%Y-%m-%d'), response1['channel'] ) assert channel_usage_log.last_published_at == response1['published_at']
def test_publish(channel1, user1, user2): with AuthenticatedClient(user1) as sock1: sock1.sendobj(dict(method="attend", channel=channel1)) sock1.recvobj() with AuthenticatedClient(user2) as sock2: sock2.sendobj(dict(method="attend", channel=channel1)) sock2.recvobj() sock1.sendobj(dict(method="publish", message="Hi!", type="text")) response1 = sock1.recvobj() response2 = sock2.recvobj() assert response1 == response2 assert response1["method"] == "publish" assert response1["writer"] == user1 assert response1["message"] == "Hi!" time.sleep(0.5) channel_usage_log = ChannelUsageLog.get_item( datetime.datetime.fromtimestamp(response1["published_at"]).strftime("%Y-%m-%d"), response1["channel"] ) assert channel_usage_log.last_published_at == response1["published_at"]