Reworking tests
Reworking tests with pytest
This commit is contained in:
parent
c78202c347
commit
d4414bd150
7 changed files with 556 additions and 439 deletions
|
|
@ -1,6 +1,5 @@
|
|||
from nose.tools import *
|
||||
import nose
|
||||
import mock
|
||||
import pytest
|
||||
from tinydb.storages import MemoryStorage
|
||||
from tinydb import TinyDB, Query
|
||||
import bumper
|
||||
|
|
@ -10,13 +9,13 @@ import platform
|
|||
|
||||
|
||||
def test_get_milli_time():
|
||||
assert_equals(
|
||||
assert (
|
||||
bumper.get_milli_time(
|
||||
datetime.datetime(
|
||||
2018, 1, 1, 1, 0, 0, 0, tzinfo=datetime.timezone.utc
|
||||
).timestamp()
|
||||
),
|
||||
1514768400000,
|
||||
)
|
||||
== 1514768400000
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -27,80 +26,73 @@ def test_user_db():
|
|||
# Test os_db_path
|
||||
platform.system = mock.MagicMock(return_value="Windows")
|
||||
p = platform.system()
|
||||
os.getenv = mock.MagicMock(return_value="C:\AppData")
|
||||
os.getenv = mock.MagicMock(return_value="C:\\AppData")
|
||||
o = os.getenv("APPDATA")
|
||||
assert_equals(bumper.os_db_path(createdir=False), os.path.join(os.getenv("APPDATA"), "bumper.db"))
|
||||
assert bumper.os_db_path(createdir=False) == os.path.join(
|
||||
os.getenv("APPDATA"), "bumper.db"
|
||||
)
|
||||
|
||||
platform.system = mock.MagicMock(return_value="Linux")
|
||||
assert_equals(bumper.os_db_path(createdir=False), os.path.expanduser("~/.config/bumper.db"))
|
||||
assert bumper.os_db_path(createdir=False) == os.path.expanduser(
|
||||
"~/.config/bumper.db"
|
||||
)
|
||||
|
||||
bumper.db = "tests/tmp.db" # Set db location for testing
|
||||
bumper.user_add("testuser") # Add testuser
|
||||
|
||||
assert_equals(
|
||||
bumper.user_get("testuser")["userid"], "testuser"
|
||||
assert (
|
||||
bumper.user_get("testuser")["userid"] == "testuser"
|
||||
) # Test that testuser was created and returned
|
||||
|
||||
bumper.user_add_device("testuser", "dev_1234") # Add device to testuser
|
||||
|
||||
assert_equals(
|
||||
bumper.user_by_deviceid("dev_1234")["userid"], "testuser"
|
||||
assert (
|
||||
bumper.user_by_deviceid("dev_1234")["userid"] == "testuser"
|
||||
) # Test that testuser was found by deviceid
|
||||
|
||||
bumper.user_remove_device("testuser", "dev_1234") # Remove device from testuser
|
||||
|
||||
assert_true(
|
||||
"dev_1234" not in bumper.user_get("testuser")["devices"]
|
||||
) # Test that dev_1234 was not found in testuser devices
|
||||
assert "dev_1234" not in bumper.user_get("testuser")["devices"]
|
||||
# Test that dev_1234 was not found in testuser devices
|
||||
|
||||
bumper.user_add_bot("testuser", "bot_1234") # Add bot did to testuser
|
||||
|
||||
assert_true(
|
||||
"bot_1234" in bumper.user_get("testuser")["bots"]
|
||||
) # Test that bot was found in testuser's bot list
|
||||
assert "bot_1234" in bumper.user_get("testuser")["bots"]
|
||||
# Test that bot was found in testuser's bot list
|
||||
|
||||
bumper.user_remove_bot("testuser", "bot_1234") # Remove bot did from testuser
|
||||
|
||||
assert_true(
|
||||
"bot_1234" not in bumper.user_get("testuser")["bots"]
|
||||
) # Test that bot was not found in testuser's bot list
|
||||
assert "bot_1234" not in bumper.user_get("testuser")["bots"]
|
||||
# Test that bot was not found in testuser's bot list
|
||||
|
||||
bumper.user_add_token("testuser", "token_1234") # Add token to testuser
|
||||
|
||||
assert_true(
|
||||
bumper.check_token("testuser", "token_1234")
|
||||
) # Test that token was found for testuser
|
||||
assert bumper.check_token("testuser", "token_1234")
|
||||
# Test that token was found for testuser
|
||||
|
||||
assert_true(
|
||||
bumper.user_get_token("testuser", "token_1234")
|
||||
) # Test that token was returned for testuser
|
||||
assert bumper.user_get_token("testuser", "token_1234")
|
||||
# Test that token was returned for testuser
|
||||
|
||||
bumper.user_add_authcode(
|
||||
"testuser", "token_1234", "auth_1234"
|
||||
) # Add authcode to token_1234 for testuser
|
||||
assert_true(
|
||||
bumper.check_authcode("testuser", "auth_1234")
|
||||
) # Test that authcode was found for testuser
|
||||
assert bumper.check_authcode("testuser", "auth_1234")
|
||||
# Test that authcode was found for testuser
|
||||
|
||||
bumper.user_revoke_authcode(
|
||||
"testuser", "token_1234", "auth_1234"
|
||||
) # Remove authcode from testuser
|
||||
assert_false(
|
||||
bumper.check_authcode("testuser", "auth_1234")
|
||||
) # Test that authcode was not found for testuser
|
||||
assert bumper.check_authcode("testuser", "auth_1234") == False
|
||||
# Test that authcode was not found for testuser
|
||||
bumper.user_revoke_token("testuser", "token_1234") # Remove token from testuser
|
||||
assert_false(
|
||||
bumper.check_token("testuser", "token_1234")
|
||||
assert (
|
||||
bumper.check_token("testuser", "token_1234") == False
|
||||
) # Test that token was not found for testuser
|
||||
bumper.user_add_token("testuser", "token_1234") # Add token_1234
|
||||
bumper.user_add_token("testuser", "token_4321") # Add token_4321
|
||||
assert_equals(
|
||||
len(bumper.user_get_tokens("testuser")), 2
|
||||
) # Test 2 tokens are available
|
||||
assert len(bumper.user_get_tokens("testuser")) == 2 # Test 2 tokens are available
|
||||
bumper.user_revoke_all_tokens("testuser") # Revoke all tokens
|
||||
assert_equals(
|
||||
len(bumper.user_get_tokens("testuser")), 0
|
||||
) # Test 0 tokens are available
|
||||
assert len(bumper.user_get_tokens("testuser")) == 0 # Test 0 tokens are available
|
||||
|
||||
db = TinyDB("tests/tmp.db")
|
||||
tokens = db.table("tokens")
|
||||
|
|
@ -114,13 +106,9 @@ def test_user_db():
|
|||
}
|
||||
) # Add expired token
|
||||
db.close()
|
||||
assert_equals(
|
||||
len(bumper.user_get_tokens("testuser")), 1
|
||||
) # Test 1 tokens are available
|
||||
assert len(bumper.user_get_tokens("testuser")) == 1 # Test 1 tokens are available
|
||||
bumper.user_revoke_expired_tokens("testuser") # Revoke expired tokens
|
||||
assert_equals(
|
||||
len(bumper.user_get_tokens("testuser")), 0
|
||||
) # Test 0 tokens are available
|
||||
assert len(bumper.user_get_tokens("testuser")) == 0 # Test 0 tokens are available
|
||||
|
||||
db = TinyDB("tests/tmp.db")
|
||||
tokens = db.table("tokens")
|
||||
|
|
@ -134,53 +122,49 @@ def test_user_db():
|
|||
}
|
||||
) # Add expired token
|
||||
db.close()
|
||||
assert_equals(
|
||||
len(bumper.user_get_tokens("testuser")), 1
|
||||
) # Test 1 tokens are available
|
||||
assert len(bumper.user_get_tokens("testuser")) == 1 # Test 1 tokens are available
|
||||
bumper.revoke_expired_tokens() # Revoke expired tokens
|
||||
assert_equals(
|
||||
len(bumper.user_get_tokens("testuser")), 0
|
||||
) # Test 0 tokens are available
|
||||
assert len(bumper.user_get_tokens("testuser")) == 0 # Test 0 tokens are available
|
||||
|
||||
|
||||
def test_bot_db():
|
||||
bumper.db = "tests/tmp.db" # Set db location for testing
|
||||
bumper.bot_add("sn_123", "did_123", "dev_123", "res_123", "co_123")
|
||||
assert_true(bumper.bot_get("did_123")) # Test that bot was added to db
|
||||
assert bumper.bot_get("did_123") # Test that bot was added to db
|
||||
|
||||
bumper.bot_set_nick("did_123", "nick_123")
|
||||
assert_equals(
|
||||
bumper.bot_get("did_123")["nick"], "nick_123"
|
||||
assert (
|
||||
bumper.bot_get("did_123")["nick"] == "nick_123"
|
||||
) # Test that nick was added to bot
|
||||
|
||||
bumper.bot_set_mqtt("did_123", True)
|
||||
assert_true(
|
||||
bumper.bot_get("did_123")["mqtt_connection"]
|
||||
) # Test that mqtt was set True for bot
|
||||
assert bumper.bot_get("did_123")[
|
||||
"mqtt_connection"
|
||||
] # Test that mqtt was set True for bot
|
||||
|
||||
bumper.bot_set_xmpp("did_123", True)
|
||||
assert_true(
|
||||
bumper.bot_get("did_123")["xmpp_connection"]
|
||||
) # Test that xmpp was set True for bot
|
||||
assert bumper.bot_get("did_123")[
|
||||
"xmpp_connection"
|
||||
] # Test that xmpp was set True for bot
|
||||
|
||||
bumper.bot_remove("did_123")
|
||||
assert_false(bumper.bot_get("did_123")) # Test that bot is no longer in db
|
||||
assert bumper.bot_get("did_123") == None # Test that bot is no longer in db
|
||||
|
||||
|
||||
def test_client_db():
|
||||
bumper.db = "tests/tmp.db" # Set db location for testing
|
||||
bumper.client_add("user_123", "realm_123", "resource_123")
|
||||
assert_true(bumper.client_get("resource_123")) # Test client was added
|
||||
assert bumper.client_get("resource_123") # Test client was added
|
||||
|
||||
bumper.client_set_mqtt("resource_123", True)
|
||||
assert_true(
|
||||
bumper.client_get("resource_123")["mqtt_connection"]
|
||||
) # Test that mqtt was set True for client
|
||||
assert bumper.client_get("resource_123")[
|
||||
"mqtt_connection"
|
||||
] # Test that mqtt was set True for client
|
||||
|
||||
bumper.client_set_xmpp("resource_123", False)
|
||||
assert_false(
|
||||
bumper.client_get("resource_123")["xmpp_connection"]
|
||||
assert (
|
||||
bumper.client_get("resource_123")["xmpp_connection"] == False
|
||||
) # Test that xmpp was set False for client
|
||||
assert_equals(
|
||||
len(bumper.get_disconnected_xmpp_clients()), 1
|
||||
assert (
|
||||
len(bumper.get_disconnected_xmpp_clients()) == 1
|
||||
) # Test len of connected xmpp clients is 1
|
||||
|
|
|
|||
|
|
@ -1,16 +1,22 @@
|
|||
from nose.tools import *
|
||||
import mock
|
||||
import bumper
|
||||
import asyncio
|
||||
import pytest
|
||||
import os
|
||||
import json
|
||||
import tinydb
|
||||
from aiohttp.test_utils import TestClient, TestServer, loop_context
|
||||
from aiohttp import request
|
||||
import pytest_aiohttp
|
||||
from aiohttp import web
|
||||
|
||||
confserver = bumper.ConfServer("127.0.0.1:11111", False, mock.MagicMock)
|
||||
confserver.confserver_app()
|
||||
app = confserver.app
|
||||
|
||||
def create_confserver():
|
||||
return bumper.ConfServer("127.0.0.1:11111", False, mock.MagicMock)
|
||||
|
||||
|
||||
def create_app(loop):
|
||||
confserver = bumper.ConfServer("127.0.0.1:11111", False, mock.MagicMock)
|
||||
confserver.confserver_app(loop=loop)
|
||||
return confserver.app
|
||||
|
||||
|
||||
def async_return(result):
|
||||
|
|
@ -19,151 +25,115 @@ def async_return(result):
|
|||
return f
|
||||
|
||||
|
||||
def test_disconnect():
|
||||
async def test_disconnect_async():
|
||||
await confserver.disconnect()
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
# Test
|
||||
loop.run_until_complete(test_disconnect_async())
|
||||
|
||||
|
||||
def test_base():
|
||||
async def test_base(aiohttp_client):
|
||||
if os.path.exists("tests/tmp.db"):
|
||||
os.remove("tests/tmp.db") # Remove existing db
|
||||
bumper.db = "tests/tmp.db" # Set db location for testing
|
||||
loop = asyncio.get_event_loop()
|
||||
client = TestClient(TestServer(app), loop=loop)
|
||||
loop.run_until_complete(client.start_server())
|
||||
root = "http://{}".format(confserver.address)
|
||||
client = await aiohttp_client(create_app)
|
||||
|
||||
async def test_handle_base():
|
||||
resp = await client.get("/")
|
||||
assert resp.status == 200
|
||||
text = await resp.text()
|
||||
assert "Bumper!" in text
|
||||
|
||||
# Test
|
||||
loop.run_until_complete(test_handle_base())
|
||||
|
||||
loop.run_until_complete(
|
||||
client.close()
|
||||
) # Close test server after all tests are done
|
||||
resp = await client.get("/")
|
||||
assert resp.status == 200
|
||||
text = await resp.text()
|
||||
assert "Bumper!" in text
|
||||
|
||||
|
||||
def test_login():
|
||||
async def test_login(aiohttp_client):
|
||||
if os.path.exists("tests/tmp.db"):
|
||||
os.remove("tests/tmp.db") # Remove existing db
|
||||
bumper.db = "tests/tmp.db" # Set db location for testing
|
||||
loop = asyncio.get_event_loop()
|
||||
client = TestClient(TestServer(app), loop=loop)
|
||||
loop.run_until_complete(client.start_server())
|
||||
root = "http://{}".format(confserver.address)
|
||||
client = await aiohttp_client(create_app)
|
||||
|
||||
async def test_handle_login():
|
||||
resp = await client.get("/1/private/us/en/dev_1234/ios/1/0/0/user/login")
|
||||
assert resp.status == 200
|
||||
text = await resp.text()
|
||||
jsonresp = json.loads(text)
|
||||
if jsonresp:
|
||||
assert jsonresp["code"] == bumper.RETURN_API_SUCCESS
|
||||
assert "accessToken" in jsonresp["data"]
|
||||
assert "uid" in jsonresp["data"]
|
||||
assert "username" in jsonresp["data"]
|
||||
else:
|
||||
assert jsonresp
|
||||
|
||||
# Test
|
||||
loop.run_until_complete(test_handle_login())
|
||||
# Test without user
|
||||
resp = await client.get("/1/private/us/en/dev_1234/ios/1/0/0/user/login")
|
||||
assert resp.status == 200
|
||||
text = await resp.text()
|
||||
jsonresp = json.loads(text)
|
||||
assert jsonresp["code"] == bumper.RETURN_API_SUCCESS
|
||||
assert "accessToken" in jsonresp["data"]
|
||||
assert "uid" in jsonresp["data"]
|
||||
assert "username" in jsonresp["data"]
|
||||
|
||||
# Add a user to db and test with existing users
|
||||
bumper.user_add("testuser")
|
||||
# Test
|
||||
loop.run_until_complete(test_handle_login())
|
||||
resp = await client.get("/1/private/us/en/dev_1234/ios/1/0/0/user/login")
|
||||
assert resp.status == 200
|
||||
text = await resp.text()
|
||||
jsonresp = json.loads(text)
|
||||
assert jsonresp["code"] == bumper.RETURN_API_SUCCESS
|
||||
assert "accessToken" in jsonresp["data"]
|
||||
assert "uid" in jsonresp["data"]
|
||||
assert "username" in jsonresp["data"]
|
||||
|
||||
# Add a bot to db that will be added to user
|
||||
bumper.bot_add("sn_123", "did_123", "dev_123", "res_123", "com_123")
|
||||
# Test
|
||||
loop.run_until_complete(test_handle_login())
|
||||
|
||||
loop.run_until_complete(
|
||||
client.close()
|
||||
) # Close test server after all tests are done
|
||||
resp = await client.get("/1/private/us/en/dev_1234/ios/1/0/0/user/login")
|
||||
assert resp.status == 200
|
||||
text = await resp.text()
|
||||
jsonresp = json.loads(text)
|
||||
assert jsonresp["code"] == bumper.RETURN_API_SUCCESS
|
||||
assert "accessToken" in jsonresp["data"]
|
||||
assert "uid" in jsonresp["data"]
|
||||
assert "username" in jsonresp["data"]
|
||||
|
||||
|
||||
def test_logout():
|
||||
async def test_logout(aiohttp_client):
|
||||
if os.path.exists("tests/tmp.db"):
|
||||
os.remove("tests/tmp.db") # Remove existing db
|
||||
bumper.db = "tests/tmp.db" # Set db location for testing
|
||||
loop = asyncio.get_event_loop()
|
||||
client = TestClient(TestServer(app), loop=loop)
|
||||
loop.run_until_complete(client.start_server())
|
||||
root = "http://{}".format(confserver.address)
|
||||
|
||||
async def test_handle_logout(token=None):
|
||||
resp = await client.get(
|
||||
"/1/private/us/en/dev_1234/ios/1/0/0/user/logout?accessToken={}".format(
|
||||
token
|
||||
)
|
||||
)
|
||||
assert resp.status == 200
|
||||
text = await resp.text()
|
||||
jsonresp = json.loads(text)
|
||||
if jsonresp:
|
||||
assert jsonresp["code"] == bumper.RETURN_API_SUCCESS
|
||||
else:
|
||||
assert jsonresp
|
||||
client = await aiohttp_client(create_app)
|
||||
|
||||
# Add a token to user and test
|
||||
bumper.user_add("testuser")
|
||||
bumper.user_add_device("testuser", "dev_1234")
|
||||
bumper.user_add_token("testuser", "token_1234")
|
||||
# Test
|
||||
loop.run_until_complete(test_handle_logout(token="token_1234"))
|
||||
resp = await client.get(
|
||||
"/1/private/us/en/dev_1234/ios/1/0/0/user/logout?accessToken={}".format(
|
||||
"token_1234"
|
||||
)
|
||||
)
|
||||
|
||||
loop.run_until_complete(
|
||||
client.close()
|
||||
) # Close test server after all tests are done
|
||||
assert resp.status == 200
|
||||
text = await resp.text()
|
||||
jsonresp = json.loads(text)
|
||||
assert jsonresp["code"] == bumper.RETURN_API_SUCCESS
|
||||
|
||||
|
||||
def test_checkLogin():
|
||||
async def test_checkLogin(aiohttp_client):
|
||||
if os.path.exists("tests/tmp.db"):
|
||||
os.remove("tests/tmp.db") # Remove existing db
|
||||
bumper.db = "tests/tmp.db" # Set db location for testing
|
||||
loop = asyncio.get_event_loop()
|
||||
client = TestClient(TestServer(app), loop=loop)
|
||||
loop.run_until_complete(client.start_server())
|
||||
root = "http://{}".format(confserver.address)
|
||||
client = await aiohttp_client(create_app)
|
||||
|
||||
async def test_handle_checkLogin(token=None):
|
||||
resp = await client.get(
|
||||
"/1/private/us/en/dev_1234/ios/1/0/0/user/checkLogin?accessToken={}".format(
|
||||
token
|
||||
)
|
||||
# Test without token
|
||||
resp = await client.get(
|
||||
"/1/private/us/en/dev_1234/ios/1/0/0/user/checkLogin?accessToken={}".format(
|
||||
None
|
||||
)
|
||||
assert resp.status == 200
|
||||
text = await resp.text()
|
||||
jsonresp = json.loads(text)
|
||||
if jsonresp:
|
||||
assert jsonresp["code"] == bumper.RETURN_API_SUCCESS
|
||||
assert "accessToken" in jsonresp["data"]
|
||||
if not token:
|
||||
assert jsonresp["data"]["accessToken"] != "token_1234"
|
||||
else:
|
||||
assert jsonresp["data"]["accessToken"] == "token_1234"
|
||||
|
||||
assert "uid" in jsonresp["data"]
|
||||
assert "username" in jsonresp["data"]
|
||||
else:
|
||||
assert jsonresp
|
||||
|
||||
# Test
|
||||
loop.run_until_complete(test_handle_checkLogin())
|
||||
)
|
||||
assert resp.status == 200
|
||||
text = await resp.text()
|
||||
jsonresp = json.loads(text)
|
||||
assert jsonresp["code"] == bumper.RETURN_API_SUCCESS
|
||||
assert "accessToken" in jsonresp["data"]
|
||||
assert jsonresp["data"]["accessToken"] != "token_1234"
|
||||
assert "uid" in jsonresp["data"]
|
||||
assert "username" in jsonresp["data"]
|
||||
|
||||
# Add a user to db and test with existing users
|
||||
bumper.user_add("testuser")
|
||||
# Test
|
||||
loop.run_until_complete(test_handle_checkLogin())
|
||||
resp = await client.get(
|
||||
"/1/private/us/en/dev_1234/ios/1/0/0/user/checkLogin?accessToken={}".format(
|
||||
None
|
||||
)
|
||||
)
|
||||
assert resp.status == 200
|
||||
text = await resp.text()
|
||||
jsonresp = json.loads(text)
|
||||
assert jsonresp["code"] == bumper.RETURN_API_SUCCESS
|
||||
assert "accessToken" in jsonresp["data"]
|
||||
assert jsonresp["data"]["accessToken"] != "token_1234"
|
||||
assert "uid" in jsonresp["data"]
|
||||
assert "username" in jsonresp["data"]
|
||||
|
||||
# Remove dev from tmpuser
|
||||
bumper.user_remove_device("tmpuser", "dev_1234")
|
||||
|
|
@ -172,231 +142,156 @@ def test_checkLogin():
|
|||
bumper.user_add("testuser")
|
||||
bumper.user_add_device("testuser", "dev_1234")
|
||||
bumper.user_add_token("testuser", "token_1234")
|
||||
# Test
|
||||
loop.run_until_complete(test_handle_checkLogin(token="token_1234"))
|
||||
|
||||
loop.run_until_complete(
|
||||
client.close()
|
||||
) # Close test server after all tests are done
|
||||
resp = await client.get(
|
||||
"/1/private/us/en/dev_1234/ios/1/0/0/user/checkLogin?accessToken={}".format(
|
||||
"token_1234"
|
||||
)
|
||||
)
|
||||
assert resp.status == 200
|
||||
text = await resp.text()
|
||||
jsonresp = json.loads(text)
|
||||
assert jsonresp["code"] == bumper.RETURN_API_SUCCESS
|
||||
assert "accessToken" in jsonresp["data"]
|
||||
assert jsonresp["data"]["accessToken"] == "token_1234"
|
||||
assert "uid" in jsonresp["data"]
|
||||
assert "username" in jsonresp["data"]
|
||||
|
||||
|
||||
def test_getAuthCode():
|
||||
async def test_getAuthCode(aiohttp_client):
|
||||
if os.path.exists("tests/tmp.db"):
|
||||
os.remove("tests/tmp.db") # Remove existing db
|
||||
bumper.db = "tests/tmp.db" # Set db location for testing
|
||||
loop = asyncio.get_event_loop()
|
||||
client = TestClient(TestServer(app), loop=loop)
|
||||
loop.run_until_complete(client.start_server())
|
||||
root = "http://{}".format(confserver.address)
|
||||
|
||||
async def test_handle_getAuthCode(uid=None, token=None):
|
||||
resp = await client.get(
|
||||
"/1/private/us/en/dev_1234/ios/1/0/0/user/getAuthCode?uid={}&accessToken={}".format(
|
||||
uid, token
|
||||
)
|
||||
)
|
||||
assert resp.status == 200
|
||||
text = await resp.text()
|
||||
jsonresp = json.loads(text)
|
||||
if jsonresp:
|
||||
if token:
|
||||
assert jsonresp["code"] == bumper.RETURN_API_SUCCESS
|
||||
assert "authCode" in jsonresp["data"]
|
||||
assert "ecovacsUid" in jsonresp["data"]
|
||||
else:
|
||||
assert jsonresp["code"] == bumper.ERR_TOKEN_INVALID
|
||||
else:
|
||||
assert jsonresp
|
||||
client = await aiohttp_client(create_app)
|
||||
|
||||
# Test without user or token
|
||||
loop.run_until_complete(test_handle_getAuthCode())
|
||||
resp = await client.get(
|
||||
"/1/private/us/en/dev_1234/ios/1/0/0/user/getAuthCode?uid={}&accessToken={}".format(
|
||||
None, None
|
||||
)
|
||||
)
|
||||
assert resp.status == 200
|
||||
text = await resp.text()
|
||||
jsonresp = json.loads(text)
|
||||
assert jsonresp["code"] == bumper.ERR_TOKEN_INVALID
|
||||
|
||||
# Add a token to user and test
|
||||
bumper.user_add("testuser")
|
||||
bumper.user_add_device("testuser", "dev_1234")
|
||||
bumper.user_add_token("testuser", "token_1234")
|
||||
# Test
|
||||
loop.run_until_complete(test_handle_getAuthCode(uid="testuser", token="token_1234"))
|
||||
resp = await client.get(
|
||||
"/1/private/us/en/dev_1234/ios/1/0/0/user/getAuthCode?uid={}&accessToken={}".format(
|
||||
"testuser", "token_1234"
|
||||
)
|
||||
)
|
||||
assert resp.status == 200
|
||||
text = await resp.text()
|
||||
jsonresp = json.loads(text)
|
||||
assert jsonresp["code"] == bumper.RETURN_API_SUCCESS
|
||||
assert "authCode" in jsonresp["data"]
|
||||
assert "ecovacsUid" in jsonresp["data"]
|
||||
|
||||
# The above should have added an authcode to token, try again to test with existing authcode
|
||||
# Test
|
||||
loop.run_until_complete(test_handle_getAuthCode(uid="testuser", token="token_1234"))
|
||||
|
||||
loop.run_until_complete(
|
||||
client.close()
|
||||
) # Close test server after all tests are done
|
||||
|
||||
|
||||
def test_checkAgreement():
|
||||
if os.path.exists("tests/tmp.db"):
|
||||
os.remove("tests/tmp.db") # Remove existing db
|
||||
bumper.db = "tests/tmp.db" # Set db location for testing
|
||||
loop = asyncio.get_event_loop()
|
||||
client = TestClient(TestServer(app), loop=loop)
|
||||
loop.run_until_complete(client.start_server())
|
||||
root = "http://{}".format(confserver.address)
|
||||
|
||||
async def test_handle_checkAgreement():
|
||||
resp = await client.get(
|
||||
"/1/private/us/en/dev_1234/ios/1/0/0/user/checkAgreement"
|
||||
resp = await client.get(
|
||||
"/1/private/us/en/dev_1234/ios/1/0/0/user/getAuthCode?uid={}&accessToken={}".format(
|
||||
"testuser", "token_1234"
|
||||
)
|
||||
assert resp.status == 200
|
||||
text = await resp.text()
|
||||
jsonresp = json.loads(text)
|
||||
if jsonresp:
|
||||
assert jsonresp["code"] == bumper.RETURN_API_SUCCESS
|
||||
else:
|
||||
assert jsonresp
|
||||
|
||||
# Test
|
||||
loop.run_until_complete(test_handle_checkAgreement())
|
||||
|
||||
loop.run_until_complete(
|
||||
client.close()
|
||||
) # Close test server after all tests are done
|
||||
)
|
||||
assert resp.status == 200
|
||||
text = await resp.text()
|
||||
jsonresp = json.loads(text)
|
||||
assert jsonresp["code"] == bumper.RETURN_API_SUCCESS
|
||||
assert "authCode" in jsonresp["data"]
|
||||
assert "ecovacsUid" in jsonresp["data"]
|
||||
|
||||
|
||||
def test_homePageAlert():
|
||||
async def test_checkAgreement(aiohttp_client):
|
||||
if os.path.exists("tests/tmp.db"):
|
||||
os.remove("tests/tmp.db") # Remove existing db
|
||||
bumper.db = "tests/tmp.db" # Set db location for testing
|
||||
loop = asyncio.get_event_loop()
|
||||
client = TestClient(TestServer(app), loop=loop)
|
||||
loop.run_until_complete(client.start_server())
|
||||
root = "http://{}".format(confserver.address)
|
||||
client = await aiohttp_client(create_app)
|
||||
|
||||
async def test_handle_homePageAlert():
|
||||
resp = await client.get(
|
||||
"/1/private/us/en/dev_1234/ios/1/0/0/campaign/homePageAlert"
|
||||
)
|
||||
assert resp.status == 200
|
||||
text = await resp.text()
|
||||
jsonresp = json.loads(text)
|
||||
if jsonresp:
|
||||
assert jsonresp["code"] == bumper.RETURN_API_SUCCESS
|
||||
else:
|
||||
assert jsonresp
|
||||
|
||||
# Test
|
||||
loop.run_until_complete(test_handle_homePageAlert())
|
||||
|
||||
loop.run_until_complete(
|
||||
client.close()
|
||||
) # Close test server after all tests are done
|
||||
resp = await client.get("/1/private/us/en/dev_1234/ios/1/0/0/user/checkAgreement")
|
||||
assert resp.status == 200
|
||||
text = await resp.text()
|
||||
jsonresp = json.loads(text)
|
||||
assert jsonresp["code"] == bumper.RETURN_API_SUCCESS
|
||||
|
||||
|
||||
def test_checkVersion():
|
||||
async def test_homePageAlert(aiohttp_client):
|
||||
if os.path.exists("tests/tmp.db"):
|
||||
os.remove("tests/tmp.db") # Remove existing db
|
||||
bumper.db = "tests/tmp.db" # Set db location for testing
|
||||
loop = asyncio.get_event_loop()
|
||||
client = TestClient(TestServer(app), loop=loop)
|
||||
loop.run_until_complete(client.start_server())
|
||||
root = "http://{}".format(confserver.address)
|
||||
client = await aiohttp_client(create_app)
|
||||
|
||||
async def test_handle_checkVersion():
|
||||
resp = await client.get(
|
||||
"/1/private/us/en/dev_1234/ios/1/0/0/common/checkVersion"
|
||||
)
|
||||
assert resp.status == 200
|
||||
text = await resp.text()
|
||||
jsonresp = json.loads(text)
|
||||
if jsonresp:
|
||||
assert jsonresp["code"] == bumper.RETURN_API_SUCCESS
|
||||
else:
|
||||
assert jsonresp
|
||||
|
||||
# Test
|
||||
loop.run_until_complete(test_handle_checkVersion())
|
||||
|
||||
loop.run_until_complete(
|
||||
client.close()
|
||||
) # Close test server after all tests are done
|
||||
resp = await client.get(
|
||||
"/1/private/us/en/dev_1234/ios/1/0/0/campaign/homePageAlert"
|
||||
)
|
||||
assert resp.status == 200
|
||||
text = await resp.text()
|
||||
jsonresp = json.loads(text)
|
||||
assert jsonresp["code"] == bumper.RETURN_API_SUCCESS
|
||||
|
||||
|
||||
def test_getProductIotMap():
|
||||
async def test_checkVersion(aiohttp_client):
|
||||
if os.path.exists("tests/tmp.db"):
|
||||
os.remove("tests/tmp.db") # Remove existing db
|
||||
bumper.db = "tests/tmp.db" # Set db location for testing
|
||||
loop = asyncio.get_event_loop()
|
||||
client = TestClient(TestServer(app), loop=loop)
|
||||
loop.run_until_complete(client.start_server())
|
||||
root = "http://{}".format(confserver.address)
|
||||
client = await aiohttp_client(create_app)
|
||||
|
||||
async def test_handle_getProductIotMap():
|
||||
resp = await client.post("/api/pim/product/getProductIotMap")
|
||||
assert resp.status == 200
|
||||
text = await resp.text()
|
||||
jsonresp = json.loads(text)
|
||||
if jsonresp:
|
||||
assert jsonresp["code"] == bumper.RETURN_API_SUCCESS
|
||||
else:
|
||||
assert jsonresp
|
||||
|
||||
# Test
|
||||
loop.run_until_complete(test_handle_getProductIotMap())
|
||||
|
||||
loop.run_until_complete(
|
||||
client.close()
|
||||
) # Close test server after all tests are done
|
||||
resp = await client.get("/1/private/us/en/dev_1234/ios/1/0/0/common/checkVersion")
|
||||
assert resp.status == 200
|
||||
text = await resp.text()
|
||||
jsonresp = json.loads(text)
|
||||
assert jsonresp["code"] == bumper.RETURN_API_SUCCESS
|
||||
|
||||
|
||||
def test_getUsersAPI():
|
||||
async def test_getProductIotMap(aiohttp_client):
|
||||
if os.path.exists("tests/tmp.db"):
|
||||
os.remove("tests/tmp.db") # Remove existing db
|
||||
bumper.db = "tests/tmp.db" # Set db location for testing
|
||||
loop = asyncio.get_event_loop()
|
||||
client = TestClient(TestServer(app), loop=loop)
|
||||
loop.run_until_complete(client.start_server())
|
||||
root = "http://{}".format(confserver.address)
|
||||
client = await aiohttp_client(create_app)
|
||||
|
||||
async def test_handle_getUsersApi():
|
||||
resp = await client.get("/api/users/user.do")
|
||||
assert resp.status == 200
|
||||
text = await resp.text()
|
||||
jsonresp = json.loads(text)
|
||||
if jsonresp:
|
||||
assert jsonresp["result"] == "fail"
|
||||
else:
|
||||
assert jsonresp
|
||||
|
||||
# Test
|
||||
loop.run_until_complete(test_handle_getUsersApi())
|
||||
|
||||
loop.run_until_complete(
|
||||
client.close()
|
||||
) # Close test server after all tests are done
|
||||
resp = await client.post("/api/pim/product/getProductIotMap")
|
||||
assert resp.status == 200
|
||||
text = await resp.text()
|
||||
jsonresp = json.loads(text)
|
||||
assert jsonresp["code"] == bumper.RETURN_API_SUCCESS
|
||||
|
||||
|
||||
def test_postUsersAPI():
|
||||
async def test_getUsersAPI(aiohttp_client):
|
||||
if os.path.exists("tests/tmp.db"):
|
||||
os.remove("tests/tmp.db") # Remove existing db
|
||||
bumper.db = "tests/tmp.db" # Set db location for testing
|
||||
loop = asyncio.get_event_loop()
|
||||
client = TestClient(TestServer(app), loop=loop)
|
||||
loop.run_until_complete(client.start_server())
|
||||
root = "http://{}".format(confserver.address)
|
||||
client = await aiohttp_client(create_app)
|
||||
|
||||
async def test_handle_postUsersApi(postbody=None):
|
||||
resp = await client.post("/api/users/user.do", json=postbody)
|
||||
resp = await client.get("/api/users/user.do")
|
||||
assert resp.status == 200
|
||||
text = await resp.text()
|
||||
jsonresp = json.loads(text)
|
||||
assert jsonresp["result"] == "fail"
|
||||
|
||||
assert resp.status == 200
|
||||
text = await resp.text()
|
||||
jsonresp = json.loads(text)
|
||||
if jsonresp:
|
||||
assert jsonresp["result"] == "ok"
|
||||
else:
|
||||
assert jsonresp
|
||||
|
||||
async def test_postUsersAPI(aiohttp_client):
|
||||
if os.path.exists("tests/tmp.db"):
|
||||
os.remove("tests/tmp.db") # Remove existing db
|
||||
bumper.db = "tests/tmp.db" # Set db location for testing
|
||||
client = await aiohttp_client(create_app)
|
||||
|
||||
# Test FindBest
|
||||
postbody = {"todo": "FindBest", "service": "EcoMsgNew"}
|
||||
# Test
|
||||
loop.run_until_complete(test_handle_postUsersApi(postbody))
|
||||
resp = await client.post("/api/users/user.do", json=postbody)
|
||||
assert resp.status == 200
|
||||
text = await resp.text()
|
||||
jsonresp = json.loads(text)
|
||||
assert jsonresp["result"] == "ok"
|
||||
|
||||
# Test EcoUpdate
|
||||
postbody = {"todo": "FindBest", "service": "EcoUpdate"}
|
||||
# Test
|
||||
loop.run_until_complete(test_handle_postUsersApi(postbody))
|
||||
resp = await client.post("/api/users/user.do", json=postbody)
|
||||
assert resp.status == 200
|
||||
text = await resp.text()
|
||||
jsonresp = json.loads(text)
|
||||
assert jsonresp["result"] == "ok"
|
||||
|
||||
# Test loginByItToken - Uses the authcode
|
||||
bumper.user_add("testuser")
|
||||
|
|
@ -415,7 +310,11 @@ def test_postUsersAPI():
|
|||
"token": "auth_1234",
|
||||
"userId": "testuser",
|
||||
}
|
||||
loop.run_until_complete(test_handle_postUsersApi(postbody))
|
||||
resp = await client.post("/api/users/user.do", json=postbody)
|
||||
assert resp.status == 200
|
||||
text = await resp.text()
|
||||
jsonresp = json.loads(text)
|
||||
assert jsonresp["result"] == "ok"
|
||||
|
||||
# Test GetDeviceList
|
||||
postbody = {
|
||||
|
|
@ -429,7 +328,11 @@ def test_postUsersAPI():
|
|||
"todo": "GetDeviceList",
|
||||
"userid": "testuser",
|
||||
}
|
||||
loop.run_until_complete(test_handle_postUsersApi(postbody))
|
||||
resp = await client.post("/api/users/user.do", json=postbody)
|
||||
assert resp.status == 200
|
||||
text = await resp.text()
|
||||
jsonresp = json.loads(text)
|
||||
assert jsonresp["result"] == "ok"
|
||||
|
||||
# Test SetDeviceNick
|
||||
postbody = {
|
||||
|
|
@ -444,7 +347,11 @@ def test_postUsersAPI():
|
|||
"nick": "botnick",
|
||||
"did": "did_1234",
|
||||
}
|
||||
loop.run_until_complete(test_handle_postUsersApi(postbody))
|
||||
resp = await client.post("/api/users/user.do", json=postbody)
|
||||
assert resp.status == 200
|
||||
text = await resp.text()
|
||||
jsonresp = json.loads(text)
|
||||
assert jsonresp["result"] == "ok"
|
||||
|
||||
# Test AddOneDevice - Same as set nick for some bots
|
||||
postbody = {
|
||||
|
|
@ -459,7 +366,11 @@ def test_postUsersAPI():
|
|||
"nick": "botnick",
|
||||
"did": "did_1234",
|
||||
}
|
||||
loop.run_until_complete(test_handle_postUsersApi(postbody))
|
||||
resp = await client.post("/api/users/user.do", json=postbody)
|
||||
assert resp.status == 200
|
||||
text = await resp.text()
|
||||
jsonresp = json.loads(text)
|
||||
assert jsonresp["result"] == "ok"
|
||||
|
||||
# Test DeleteOneDevice - remove bot
|
||||
postbody = {
|
||||
|
|
@ -473,79 +384,50 @@ def test_postUsersAPI():
|
|||
"todo": "DeleteOneDevice",
|
||||
"did": "did_1234",
|
||||
}
|
||||
loop.run_until_complete(test_handle_postUsersApi(postbody))
|
||||
|
||||
loop.run_until_complete(
|
||||
client.close()
|
||||
) # Close test server after all tests are done
|
||||
resp = await client.post("/api/users/user.do", json=postbody)
|
||||
assert resp.status == 200
|
||||
text = await resp.text()
|
||||
jsonresp = json.loads(text)
|
||||
assert jsonresp["result"] == "ok"
|
||||
|
||||
|
||||
def test_postLookup():
|
||||
async def test_postLookup(aiohttp_client):
|
||||
if os.path.exists("tests/tmp.db"):
|
||||
os.remove("tests/tmp.db") # Remove existing db
|
||||
bumper.db = "tests/tmp.db" # Set db location for testing
|
||||
loop = asyncio.get_event_loop()
|
||||
client = TestClient(TestServer(app), loop=loop)
|
||||
loop.run_until_complete(client.start_server())
|
||||
root = "http://{}".format(confserver.address)
|
||||
|
||||
async def test_handle_lookup(postbody=None):
|
||||
resp = await client.post("/lookup.do", json=postbody)
|
||||
|
||||
assert resp.status == 200
|
||||
text = await resp.text()
|
||||
jsonresp = json.loads(text)
|
||||
if jsonresp:
|
||||
assert jsonresp["result"] == "ok"
|
||||
else:
|
||||
assert jsonresp
|
||||
client = await aiohttp_client(create_app)
|
||||
|
||||
# Test FindBest
|
||||
postbody = {"todo": "FindBest", "service": "EcoMsgNew"}
|
||||
# Test
|
||||
loop.run_until_complete(test_handle_lookup(postbody))
|
||||
resp = await client.post("/lookup.do", json=postbody)
|
||||
assert resp.status == 200
|
||||
text = await resp.text()
|
||||
test_resp = json.loads(text)
|
||||
assert test_resp["result"] == "ok"
|
||||
|
||||
# Test EcoUpdate
|
||||
postbody = {"todo": "FindBest", "service": "EcoUpdate"}
|
||||
# Test
|
||||
loop.run_until_complete(test_handle_lookup(postbody))
|
||||
|
||||
loop.run_until_complete(
|
||||
client.close()
|
||||
) # Close test server after all tests are done
|
||||
resp = await client.post("/lookup.do", json=postbody)
|
||||
assert resp.status == 200
|
||||
text = await resp.text()
|
||||
test_resp = json.loads(text)
|
||||
assert test_resp["result"] == "ok"
|
||||
|
||||
|
||||
def test_devmgr():
|
||||
async def test_devmgr(aiohttp_client):
|
||||
if os.path.exists("tests/tmp.db"):
|
||||
os.remove("tests/tmp.db") # Remove existing db
|
||||
bumper.db = "tests/tmp.db" # Set db location for testing
|
||||
loop = asyncio.get_event_loop()
|
||||
client = TestClient(TestServer(app), loop=loop)
|
||||
loop.run_until_complete(client.start_server())
|
||||
root = "http://{}".format(confserver.address)
|
||||
|
||||
async def test_devmanager(postbody=None, command=False):
|
||||
resp = await client.post("/api/iot/devmanager.do", json=postbody)
|
||||
|
||||
assert resp.status == 200
|
||||
text = await resp.text()
|
||||
jsonresp = json.loads(text)
|
||||
if jsonresp:
|
||||
if not command:
|
||||
assert jsonresp["ret"] == "ok"
|
||||
else:
|
||||
if "ret" in jsonresp:
|
||||
if jsonresp["ret"] == "ok":
|
||||
assert jsonresp["resp"]
|
||||
else:
|
||||
assert jsonresp["errno"]
|
||||
else:
|
||||
assert jsonresp
|
||||
confserver = create_confserver()
|
||||
client = await aiohttp_client(create_app)
|
||||
|
||||
# Test PollSCResult
|
||||
postbody = {"td": "PollSCResult"}
|
||||
# Test
|
||||
loop.run_until_complete(test_devmanager(postbody, command=False))
|
||||
resp = await client.post("/api/dim/devmanager.do", json=postbody)
|
||||
assert resp.status == 200
|
||||
text = await resp.text()
|
||||
test_resp = json.loads(text)
|
||||
assert test_resp["ret"] == "ok"
|
||||
|
||||
# Test BotCommand
|
||||
bumper.bot_add("sn_1234", "did_1234", "dev_1234", "res_1234", "eco-ng")
|
||||
|
|
@ -561,25 +443,99 @@ def test_devmgr():
|
|||
confserver.helperbot.send_command = mock.MagicMock(
|
||||
return_value=async_return(command_getstatus_resp)
|
||||
)
|
||||
# Test
|
||||
loop.run_until_complete(test_devmanager(postbody, command=True))
|
||||
resp = await client.post("/api/dim/devmanager.do", json=postbody)
|
||||
assert resp.status == 200
|
||||
text = await resp.text()
|
||||
test_resp = json.loads(text)
|
||||
assert test_resp["ret"] == "ok"
|
||||
|
||||
# Test return fail timeout
|
||||
command_timeout_resp = {"id": "resp_1234", "errno": "timeout", "ret": "fail"}
|
||||
confserver.helperbot.send_command = mock.MagicMock(
|
||||
return_value=async_return(command_timeout_resp)
|
||||
)
|
||||
# Test
|
||||
loop.run_until_complete(test_devmanager(postbody, command=True))
|
||||
resp = await client.post("/api/dim/devmanager.do", json=postbody)
|
||||
assert resp.status == 200
|
||||
text = await resp.text()
|
||||
test_resp = json.loads(text)
|
||||
assert test_resp["ret"] == "fail"
|
||||
|
||||
# Set bot not on mqtt
|
||||
bumper.bot_set_mqtt("did_1234", False)
|
||||
confserver.helperbot.send_command = mock.MagicMock(
|
||||
return_value=async_return(command_getstatus_resp)
|
||||
)
|
||||
# Test
|
||||
loop.run_until_complete(test_devmanager(postbody, command=True))
|
||||
resp = await client.post("/api/dim/devmanager.do", json=postbody)
|
||||
assert resp.status == 200
|
||||
text = await resp.text()
|
||||
test_resp = json.loads(text)
|
||||
assert test_resp["ret"] == "fail"
|
||||
|
||||
|
||||
async def test_dim_devmanager(aiohttp_client):
|
||||
if os.path.exists("tests/tmp.db"):
|
||||
os.remove("tests/tmp.db") # Remove existing db
|
||||
bumper.db = "tests/tmp.db" # Set db location for testing
|
||||
confserver = create_confserver()
|
||||
client = await aiohttp_client(create_app)
|
||||
|
||||
# Test PollSCResult
|
||||
postbody = {"td": "PollSCResult"}
|
||||
resp = await client.post("/api/dim/devmanager.do", json=postbody)
|
||||
assert resp.status == 200
|
||||
text = await resp.text()
|
||||
test_resp = json.loads(text)
|
||||
assert test_resp["ret"] == "ok"
|
||||
|
||||
# Test HasUnreadMsg
|
||||
postbody = {"td": "HasUnreadMsg"}
|
||||
resp = await client.post("/api/dim/devmanager.do", json=postbody)
|
||||
assert resp.status == 200
|
||||
text = await resp.text()
|
||||
test_resp = json.loads(text)
|
||||
assert test_resp["ret"] == "ok"
|
||||
assert test_resp["unRead"] == False
|
||||
|
||||
# Test BotCommand
|
||||
bumper.bot_add("sn_1234", "did_1234", "dev_1234", "res_1234", "eco-ng")
|
||||
bumper.bot_set_mqtt("did_1234", True)
|
||||
postbody = {"toId": "did_1234"}
|
||||
|
||||
# Test return get status
|
||||
command_getstatus_resp = {
|
||||
"id": "resp_1234",
|
||||
"resp": "<ctl ret='ok' status='idle'/>",
|
||||
"ret": "ok",
|
||||
}
|
||||
confserver.helperbot.send_command = mock.MagicMock(
|
||||
return_value=async_return(command_getstatus_resp)
|
||||
)
|
||||
resp = await client.post("/api/dim/devmanager.do", json=postbody)
|
||||
assert resp.status == 200
|
||||
text = await resp.text()
|
||||
test_resp = json.loads(text)
|
||||
assert test_resp["ret"] == "ok"
|
||||
|
||||
# Test return fail timeout
|
||||
command_timeout_resp = {"id": "resp_1234", "errno": "timeout", "ret": "fail"}
|
||||
confserver.helperbot.send_command = mock.MagicMock(
|
||||
return_value=async_return(command_timeout_resp)
|
||||
)
|
||||
resp = await client.post("/api/dim/devmanager.do", json=postbody)
|
||||
assert resp.status == 200
|
||||
text = await resp.text()
|
||||
test_resp = json.loads(text)
|
||||
assert test_resp["ret"] == "fail"
|
||||
assert test_resp["errno"] == "timeout"
|
||||
|
||||
# Set bot not on mqtt
|
||||
bumper.bot_set_mqtt("did_1234", False)
|
||||
confserver.helperbot.send_command = mock.MagicMock(
|
||||
return_value=async_return(command_getstatus_resp)
|
||||
)
|
||||
resp = await client.post("/api/dim/devmanager.do", json=postbody)
|
||||
assert resp.status == 200
|
||||
text = await resp.text()
|
||||
test_resp = json.loads(text)
|
||||
assert test_resp["ret"] == "fail"
|
||||
|
||||
loop.run_until_complete(
|
||||
client.close()
|
||||
) # Close test server after all tests are done
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
# Bumper tests
|
||||
Bumper uses nosetests for the majority of test cases. Install requirements using `pipenv install --dev`
|
||||
Bumper uses pytest for the majority of test cases. Install requirements using `pipenv install --dev`
|
||||
|
||||
## Testing
|
||||
Enter pipenv shell `pipenv shell`
|
||||
|
||||
### Run tests
|
||||
`nosetests`
|
||||
`python -m pytest`
|
||||
|
||||
### Run tests with coverage
|
||||
`nosetests --cover-package bumper --with-coverage`
|
||||
`python -m pytest --cov=bumper tests/`
|
||||
|
||||
### Run tests with coverage html report
|
||||
`nosetests --cover-package bumper --with-coverage --cover-html-dir="tests/report" --cover-html`
|
||||
`python -m pytest --cov=bumper tests/ --cov-report html:tests/report`
|
||||
|
||||
The report will be output into tests/report/index.html for further analysis.
|
||||
Loading…
Add table
Add a link
Reference in a new issue