# Path: stackimpact/utils.py
# def timestamp():
#     return int(time.time())


import unittest
import sys
import json
import stackimpact
from stackimpact.utils import timestamp
from test_server import TestServer





class MessageQueueTest(unittest.TestCase):


    def test_flush(self):
        server = TestServer(5005)
        server.start()

        stackimpact._agent = None
        agent = stackimpact.start(
            dashboard_address = 'http://localhost:5005',
            agent_key = 'key1',
            app_name = 'TestPythonApp',
            debug = True
        )

        m = {
            'm1': 1
        }
        agent.message_queue.add('t1', m)

        m = {
            'm2': 2
        }        
        agent.message_queue.add('t1', m)


# Path: stackimpact/utils.py
# def timestamp():
#     return int(time.time())


# Path: tests/message_queue_test.py
import unittest
import sys
import json
import stackimpact
from stackimpact.utils import timestamp
from test_server import TestServer






class MessageQueueTest(unittest.TestCase):


    def test_flush(self):
        server = TestServer(5005)
        server.start()

        stackimpact._agent = None
        agent = stackimpact.start(
            dashboard_address = 'http://localhost:5005',
            agent_key = 'key1',
            app_name = 'TestPythonApp',
            debug = True
        )

        m = {
            'm1': 1
        }
        agent.message_queue.add('t1', m)

        m = {
            'm2': 2
        }        
        agent.message_queue.add('t1', m)


        agent.message_queue.queue[0]['added_at'] = timestamp() - 20 * 60