From f472d95d2b2e4edf41e2eefe1eee7461163c85bb Mon Sep 17 00:00:00 2001 From: L1ghtn1ng Date: Tue, 31 Dec 2019 03:17:41 +0000 Subject: [PATCH] add pytest-asyncio to deps and got otx test working --- Pipfile | 1 + Pipfile.lock | 10 +++++++++- requirements/dev.txt | 1 + tests/discovery/test_otx.py | 17 ++++++++++------- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/Pipfile b/Pipfile index 6fe0e91d..7afd2ddc 100644 --- a/Pipfile +++ b/Pipfile @@ -24,3 +24,4 @@ flake8 = "==3.7.9" mypy = "==0.761" mypy-extensions = "==0.4.3" pytest = "==5.3.2" +pytest-asyncio = "==0.10.0" diff --git a/Pipfile.lock b/Pipfile.lock index a63f6437..391014bb 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "db30e9238d9e3525a4640e043831ac8c039b4af08d806b3c1c9a7510a8062334" + "sha256": "3c66802d9f73f10cb71706dadf043463fab1c81208678d871343a10f60f83ba7" }, "pipfile-spec": 6, "requires": {}, @@ -495,6 +495,14 @@ "index": "pypi", "version": "==5.3.2" }, + "pytest-asyncio": { + "hashes": [ + "sha256:9fac5100fd716cbecf6ef89233e8590a4ad61d729d1732e0a96b84182df1daaf", + "sha256:d734718e25cfc32d2bf78d346e99d33724deeba774cc4afdf491530c6184b63b" + ], + "index": "pypi", + "version": "==0.10.0" + }, "six": { "hashes": [ "sha256:1f1b7d42e254082a9db6279deae68afb421ceba6158efa6131de7b3003ee93fd", diff --git a/requirements/dev.txt b/requirements/dev.txt index 1a0cd8ad..1d5617da 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -1,4 +1,5 @@ -r base.txt flake8==3.7.9 pytest==5.3.2 +pytest-asyncio==0.10.0 mypy==0.761 diff --git a/tests/discovery/test_otx.py b/tests/discovery/test_otx.py index 58d6d018..5f720d4d 100644 --- a/tests/discovery/test_otx.py +++ b/tests/discovery/test_otx.py @@ -11,21 +11,24 @@ class TestOtx(object): def domain() -> str: return 'metasploit.com' - def test_api(self): + @pytest.mark.asyncio + async def test_api(self): base_url = f'https://otx.alienvault.com/api/v1/indicators/domain/{TestOtx.domain()}/passive_dns' headers = {'User-Agent': Core.get_user_agent()} request = requests.get(base_url, headers=headers) assert request.status_code == 200 - def test_search(self): + @pytest.mark.asyncio + async def test_search(self): search = otxsearch.SearchOtx(TestOtx.domain()) - search.process() - assert isinstance(search.get_hostnames(), set) + await search.process() + assert isinstance(await search.get_hostnames(), set) - def test_search_no_results(self): + @pytest.mark.asyncio + async def test_search_no_results(self): search = otxsearch.SearchOtx('radiant.eu') - search.process() - assert len(search.get_hostnames()) == 0 + await search.process() + assert len(await search.get_hostnames()) == 0 if __name__ == '__main__':