Skip to content

Commit

Permalink
add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yunstanford committed Jan 8, 2017
1 parent b0581ae commit a8eeccb
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/test_migration.py
Expand Up @@ -118,3 +118,27 @@ def exist_mock_return(path):

await worker.send_one_wsp(storage, metric, new_metric)
server.close()


@pytest.mark.asyncio
async def test_run(monkeypatch):
loop = asyncio.get_event_loop()
host = '127.0.0.1'
port = 2003
server = await asyncio.start_server(handler, host, port)
worker = Migration('/opt/graphite/storage/whisper/zon',
host, port, loop=loop)
await worker.connect_to_graphite()
def fetch_mock_return(path, i):
return ((1483668388, 1483668390, 2), [7])
monkeypatch.setattr(whisper, 'fetch', fetch_mock_return)
def walk_mock_return(path):
yield ('/opt/graphite/storage/whisper/zon', [], ['where.wsp'])
monkeypatch.setattr(os, 'walk', walk_mock_return)

await worker.run()
server.close()




0 comments on commit a8eeccb

Please sign in to comment.