add pytest-asyncio to deps and got otx test working

This commit is contained in:
L1ghtn1ng
2019-12-31 03:17:41 +00:00
parent 483dcafb4f
commit f472d95d2b
4 changed files with 21 additions and 8 deletions
+1
View File
@@ -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"
Generated
+9 -1
View File
@@ -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",
+1
View File
@@ -1,4 +1,5 @@
-r base.txt
flake8==3.7.9
pytest==5.3.2
pytest-asyncio==0.10.0
mypy==0.761
+10 -7
View File
@@ -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__':