supervisor/tests/utils/test_json.py
Joakim Sørensen f35b6d0b00
Set permissions on JSON files ()
* Set 600 premissions on json files

* Add test

* Fix local tar tests

* Fix tar test in action

* Use pytest fixture for tmp_path in tests

* remove not needed things
2020-10-05 15:14:09 +02:00

21 lines
612 B
Python

"""test json."""
from supervisor.utils.json import write_json_file
def test_file_permissions(tmp_path):
"""Test file permissions."""
tempfile = tmp_path / "test.json"
write_json_file(tempfile, {"test": "data"})
assert tempfile.is_file()
assert oct(tempfile.stat().st_mode)[-3:] == "600"
def test_new_file_permissions(tmp_path):
"""Test file permissions."""
tempfile = tmp_path / "test.json"
tempfile.write_text("test")
assert oct(tempfile.stat().st_mode)[-3:] != "600"
write_json_file(tempfile, {"test": "data"})
assert oct(tempfile.stat().st_mode)[-3:] == "600"