def test_run_calls_pytest(self): """This should just return from pytest.main()""" with patch("tavern.core.pytest.main") as pmock: run("abc") assert pmock.called
def test_normal_args(self): with patch("tavern.core.pytest.main") as pmock: run(**{ 'tavern_global_cfg': None, 'in_file': "kfdoskdof", 'tavern_http_backend': 'requests', 'tavern_mqtt_backend': 'paho-mqtt', 'tavern_strict': True, }) assert pmock.called
def test_normal_args(self): with patch("tavern.core.pytest.main") as pmock: run( **{ "tavern_global_cfg": None, "in_file": "kfdoskdof", "tavern_http_backend": "requests", "tavern_mqtt_backend": "paho-mqtt", "tavern_strict": True, }) assert pmock.called
def test_extra_args(self): with pytest.warns(FutureWarning): with patch("tavern.core.pytest.main") as pmock: run(**{ 'tavern_global_cfg': None, 'in_file': "kfdoskdof", 'tavern_http_backend': 'requests', 'tavern_mqtt_backend': 'paho-mqtt', 'tavern_strict': True, 'gfg': '2efsf', }) assert pmock.called
def test_extra_args(self): with pytest.raises(TypeError): with patch("tavern.core.pytest.main") as pmock: run( **{ "tavern_global_cfg": None, "in_file": "kfdoskdof", "tavern_http_backend": "requests", "tavern_mqtt_backend": "paho-mqtt", "tavern_strict": True, "gfg": "2efsf", }) assert not pmock.called
def pytest_tavern_beta_before_every_test_run(test_dict, variables): run("test_deleteAll.tavern.yaml")
from tavern.core import run run('.') def pytest_tavern_beta_before_every_test_run(test_dict, variables): run("test_deleteAll.tavern.yaml")
""" Project's entry-point """ import logging.config import os import json import yaml from tavern.core import run token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE1MzI4MDU4MjYsImlzcyI6Ik9ueXhwcmV2IiwiZXhwIjoxNTMyODQ5MDI2LCJuYmYiOjE1MzI4MDU4MjUsImRhdGEiOnsiYXBwIjp7ImFwaUlkIjoiODNjYzEyYTVmY2M1IiwiYXBwQ29kIjoxMiwiYXBwT3NDb2QiOjEsIm5hbWUiOiJSZWNhZCIsImFwaWtleSI6IjgzY2MxMmE1ZmNjNSIsInNlY3VyaXR5IjoiSSIsImxhdW5jaGVySWdub3JlIjoiTiIsImNhY2hlIjoiSSIsInZlcnNpb24iOiIxLjAuMCJ9LCJ1c2VyIjp7InBmQ29kIjoxLCJ1c3VhcmlvQ29kIjoxLCJvcmdhb0NvZCI6MSwib3JnYW9FbnRpZGFkZUNvZCI6MSwicHJpdkNvZCI6MTUsInN1cGVyVXN1YXJpbyI6IlMiLCJub21lIjoiRkVMSVBIRSBBVUdVU1RPIEJVRU5PIiwidXVpZCI6IjQxNDhkOTM4NWUyMTgxMTQzNmMxZDBmNjQ3NjE5MyIsImxvZ2luIjoiMDI0MDE2MjcxNDYiLCJmb3RvIjoiaHR0cHM6XC9cL3N0b3JhZ2Uub255eGVycC5jb20uYnJcLzhkOTBkNmY1ZDM1YjQ3NzlmMjM1NTY2NDNhM2YyZS5wbmciLCJjZWx1bGFyIjpudWxsLCJlbWFpbCI6bnVsbCwidXNlci1sZW5ndGgiOjgsInBmaWQiOiI0Nzc5MDU1OTMzMDg3MzAyODA5Iiwib2lkIjoiM2E5NWMzZTI0NGUzOTBlN2NhOGNlZDZkM2FiYzBiIiwib2VpZCI6IjVlOTU3NjdmMWFjNTVmODFjNWM0ZGQ5YWUyMTBlMyIsImZ1c29Ib3JhcmlvIjoiLTMiLCJtb2VkYSI6ImJyYXppbGlhbl9yZWFsIiwiaWRpb21hIjoicHQtYnIiLCJkYXRhIjoiYnJhemlsaWFuX2RhdGVfZm9ybWF0IiwibGF1bmNoZXIiOiJfYmxhbmsifX19.dSfTOXt9HDVeqEf4xTER0sN6EXIez2etB1ajZoPRbtY' # Carrega os JWTs(app and user) os.environ.update({ "APP_TOKEN": token, "USER_TOKEN": token, "USER_TOKEN_NO_AUTH": token, "URL_API": "https://protokol-api.onyxapis.com" }) with open("tests/logging.yaml", "r") as spec_file: settings = yaml.load(spec_file) logging.config.dictConfig(settings) test_info = run('tests/main.tavern.yaml') pass print(json.dumps(test_info)) exit(int(test_info['all_passed'] is False))
from tavern.core import run from subprocess import Popen, PIPE #process = Popen(['python','server.py'],stdout=PIPE,stderr=PIPE) print('spawned server') success = run("test.tavern.yaml",{})
def test_run_with_empty_cfg(self): run("", {})
def test_warns_about_extra_kwargs(self): with pytest.warns(FutureWarning): run("", a=123)
def test_bad_type(self): with pytest.raises(exceptions.InvalidSettingsError): run("", tavern_global_cfg=["a", "b", "c"])
# It runs all tests. from tavern.core import run failure = run('tests-broadcast_raw.tavern.yaml', pytest_args=["-x"]) failure |= run('tests-node0_coordinator.tavern.yaml', pytest_args=["-x"]) failure |= run('tests-node0_leds.tavern.yaml', pytest_args=["-x"]) failure |= run('tests-node0_os.tavern.yaml', pytest_args=["-x"]) failure |= run('tests-node0_sfrc.tavern.yaml', pytest_args=["-x"]) failure |= run('tests-node0_dfrc.tavern.yaml', pytest_args=["-x"]) failure |= run('tests-daemon_cfg-meta-on.tavern.yaml', pytest_args=["-x"]) failure |= run('tests-node0_sfrc-meta.tavern.yaml', pytest_args=["-x"]) failure |= run('tests-daemon_cfg-meta-off.tavern.yaml', pytest_args=["-x"]) failure |= run('tests-node1_explore.tavern.yaml', pytest_args=["-x"]) failure |= run('tests-node1_iqmesh.tavern.yaml', pytest_args=["-x"]) failure |= run('tests-node1_sensor.tavern.yaml', pytest_args=["-x"]) failure |= run('tests-node2_bo.tavern.yaml', pytest_args=["-x"]) failure |= run('tests-node2_iqmesh.tavern.yaml', pytest_args=["-x"]) failure |= run('tests-node2_sensor.tavern.yaml', pytest_args=["-x"]) failure |= run('tests-node3_light.tavern.yaml', pytest_args=["-x"]) failure |= run('tests-node4_dali.tavern.yaml', pytest_args=["-x"]) if failure: print("Error running tests.")
def test_path_nonexistent(self): with pytest.raises(exceptions.InvalidSettingsError): run("", tavern_global_cfg="sdfsdd")
def test_pass_dict(self): run("", tavern_global_cfg={"variables": {"a": 1}})
def test_path_correct(self): run("", tavern_global_cfg=__file__)
def test_conf(list_config): for _ in list_config: success = run(in_file="test.tavern.yaml", tavern_global_cfg=_) if not success: print("Error running tests")
from tavern.core import run success = run("test_simple.tavern.yaml", {}) if not success: print("Error running tests")
def test_run_with_cfg(self): run("", {"a": 2})
def test_doesnt_warn_about_expected_kwargs(self, expected_kwarg): kw = {expected_kwarg: 123} with pytest.warns(None) as warn_rec: run("", **kw) assert not len(warn_rec)
def test_run(self): run("")
from tavern.core import run from glob import glob for test in glob("test_*.yaml"): run(test)