Commit d597be27 authored by Marcel Hellkamp's avatar Marcel Hellkamp
Browse files

Also enforce black formatting on tests/ and setup.py

parent d8626719
......@@ -13,10 +13,10 @@ stages:
- release
.test: &common-test
stage: test
before_script:
- python -V
- pip install tox pytest
stage: test
script: tox -e py
test-py35:
......@@ -40,7 +40,7 @@ linters:
script:
- pip install flake8 black
- flake8 src/
- black --check src/
- black --check src/ tests/ setup.py
allow_failure: true
build:
......
......@@ -16,10 +16,10 @@ dist: venv $(SRC_ALL)
lint: venv
venv/bin/flake8 src/
venv/bin/black --check src/
venv/bin/black --check src/ tests/ setup.py
format: venv
venv/bin/black src/
venv/bin/black src/ tests/ setup.py
test: venv
venv/bin/tox
......
......@@ -24,7 +24,7 @@ def test_service_info(client, restmock):
def test_vault_info(client, restmock):
restmock.add("GET", SERVER + "test", json={"public": True})
assert client.vault_info('test').public is True
assert client.vault_info("test").public is True
def test_tx(client, restmock):
......@@ -36,11 +36,17 @@ def test_tx(client, restmock):
# Cant't call keepalive without transaction!
client.keepalive()
txjson = {"id": "123", "ttl": 60, "timeout": 60, "isolation": "snapshot", "readonly": False}
txjson = {
"id": "123",
"ttl": 60,
"timeout": 60,
"isolation": "snapshot",
"readonly": False,
}
restmock.add("POST", SERVER + "_tx", json=txjson)
with client.begin():
assert client.tx.id == '123'
assert client.tx.id == "123"
restmock.add("POST", SERVER + "_tx/123?renew=True", json=txjson)
client.keepalive()
......@@ -56,12 +62,12 @@ def test_tx(client, restmock):
with client.begin():
pass
assert restmock.calls[-1].request.method == 'DELETE'
assert restmock.calls[-1].request.method == "DELETE"
assert restmock.calls[-1].request.url == SERVER + "_tx/123"
with client.begin(autocommit=True):
pass
assert restmock.calls[-1].request.method == 'POST'
assert restmock.calls[-1].request.method == "POST"
assert restmock.calls[-1].request.url == SERVER + "_tx/123"
with pytest.raises(RuntimeError):
......@@ -71,15 +77,18 @@ def test_tx(client, restmock):
def test_error(client, restmock):
with pytest.raises(ApiError) as e:
restmock.add("GET", SERVER + "missing", status=404, json={
"status": 404,
"error": "VaultNotFound",
"message": "Vault not found",
"detail": {
"vault": "bad"
}
})
client.rest('GET', 'missing')
restmock.add(
"GET",
SERVER + "missing",
status=404,
json={
"status": 404,
"error": "VaultNotFound",
"message": "Vault not found",
"detail": {"vault": "bad"},
},
)
client.rest("GET", "missing")
assert e.value.status == 404
assert e.value.error == "VaultNotFound"
......@@ -21,16 +21,16 @@ pytestmark = pytest.mark.skipif(not SERVER, reason="No TEST_SERVER configured")
def test_service_info(): # pragma: no cover
c = CDStar(SERVER)
si = c.service_info()
assert si['version']['api'] == "3.0"
assert si["version"]["api"] == "3.0"
def test_tx(): # pragma: no cover
c = CDStar(SERVER)
with c.begin():
assert 'id' in c.tx
assert c.tx['isolation'] == 'snapshot'
assert c.tx['readonly'] is False
assert c.tx['timeout'] > 0
assert "id" in c.tx
assert c.tx["isolation"] == "snapshot"
assert c.tx["readonly"] is False
assert c.tx["timeout"] > 0
assert c.tx is None
......@@ -45,7 +45,7 @@ def test_tx_commit(): # pragma: no cover
def test_vault_info(): # pragma: no cover
c = CDStar(SERVER)
vi = c.vault_info(VAULT)
assert 'public' in vi
assert "public" in vi
def test_crud_file(): # pragma: no cover
......@@ -53,16 +53,16 @@ def test_crud_file(): # pragma: no cover
with c.begin():
a = c.create_archive(VAULT)
with open(__file__, 'rb') as fp:
with open(__file__, "rb") as fp:
hash = hashlib.md5(fp.read()).hexdigest()
fp.seek(0)
r = c.put_file(VAULT, a['id'], "test.py", fp, type="text/x-python")
assert r['digests']['md5'] == hash
r = c.put_file(VAULT, a["id"], "test.py", fp, type="text/x-python")
assert r["digests"]["md5"] == hash
assert r == c.file_info(VAULT, a['id'], "/test.py", meta=False)
assert "test.py" == next(c.iter_files(VAULT, a['id']))['name']
assert r == c.file_info(VAULT, a["id"], "/test.py", meta=False)
assert "test.py" == next(c.iter_files(VAULT, a["id"]))["name"]
fget = c.get_file(VAULT, a['id'], "test.py")
fget = c.get_file(VAULT, a["id"], "test.py")
fp.seek(0)
assert fp.read() == fget.readall()
assert "text/x-python" == fget.type
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment