Git status checks and more hacking
This commit is contained in:
11
test/test_settings.py
Normal file
11
test/test_settings.py
Normal file
@ -0,0 +1,11 @@
|
||||
from autonomic.settings import add, get, remove
|
||||
|
||||
|
||||
def test_add_get_remove():
|
||||
add({"foo": "bar"})
|
||||
|
||||
assert get("doesnt-exist") is None
|
||||
assert get("foo") == "bar"
|
||||
|
||||
remove("foo")
|
||||
assert get("foo") is None
|
58
test/test_utils.py
Normal file
58
test/test_utils.py
Normal file
@ -0,0 +1,58 @@
|
||||
from subprocess import STDOUT
|
||||
|
||||
from autonomic.utils import is_proc, qlist, run, yaml_dump, yaml_load
|
||||
|
||||
|
||||
def test_run_kwargs():
|
||||
assert run(["whoami"], stderr=STDOUT) is not None
|
||||
|
||||
|
||||
def test_run_cwd(tmp_path):
|
||||
directory = tmp_path / "test"
|
||||
directory.mkdir()
|
||||
|
||||
testfile = directory / "testfile.txt"
|
||||
testfile.write_text("hello, world")
|
||||
|
||||
output = run(["ls"], cwd=directory.absolute())
|
||||
assert "testfile.txt" in output.decode()
|
||||
|
||||
|
||||
def test_make_qlist():
|
||||
output = qlist("foo", "bar", ["bang"])
|
||||
|
||||
expected = {
|
||||
"type": "list",
|
||||
"name": "foo",
|
||||
"message": "bar",
|
||||
"choices": ["bang"],
|
||||
}
|
||||
|
||||
for key, val in expected.items():
|
||||
assert expected[key] == output[0][key]
|
||||
|
||||
|
||||
def test_yaml_load(tmp_path):
|
||||
directory = tmp_path / "test"
|
||||
directory.mkdir()
|
||||
|
||||
testfile = directory / "testfile.yml"
|
||||
testfile.write_text("---\nusername: foobar")
|
||||
|
||||
loaded = yaml_load(testfile.absolute())
|
||||
assert loaded["username"] == "foobar"
|
||||
|
||||
|
||||
def test_yaml_dump(tmp_path):
|
||||
directory = tmp_path / "test"
|
||||
directory.mkdir()
|
||||
|
||||
testfile = directory / "testfile.yml"
|
||||
yaml_dump(testfile.absolute(), {"username": "foobar"})
|
||||
|
||||
loaded = yaml_load(testfile.absolute())
|
||||
assert loaded["username"] == "foobar"
|
||||
|
||||
|
||||
def test_is_proc():
|
||||
assert is_proc("pytest") is True
|
@ -2,9 +2,9 @@
|
||||
|
||||
|
||||
def test_version_fails_gracefully(mocker):
|
||||
target = 'pkg_resources.get_distribution'
|
||||
target = "pkg_resources.get_distribution"
|
||||
mocker.patch(target, side_effect=Exception())
|
||||
|
||||
from autonomic.__init__ import __version__
|
||||
|
||||
assert __version__ == 'unknown'
|
||||
assert __version__ == "unknown"
|
||||
|
5
test/test_yaml.py
Normal file
5
test/test_yaml.py
Normal file
@ -0,0 +1,5 @@
|
||||
from autonomic.yaml import yaml
|
||||
|
||||
|
||||
def test_yaml_config():
|
||||
assert yaml.explicit_start is True
|
Reference in New Issue
Block a user