commit 07140b3433e32906bdeab75a669ded41356ff216 Author: juga0 juga@riseup.net Date: Sun Jul 15 20:35:58 2018 +0000
Add unit tests for disk space functions --- tests/unit/util/test_fs.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
diff --git a/tests/unit/util/test_fs.py b/tests/unit/util/test_fs.py new file mode 100644 index 0000000..0f4c35a --- /dev/null +++ b/tests/unit/util/test_fs.py @@ -0,0 +1,23 @@ +"""Unit tests for fs module""" +from unittest.mock import patch + +from sbws.util import fs + + +def mock_df_zero(path): + return 0 + + +def mock_df_enough(path): + return 32 + + +@patch('sbws.util.fs.df', mock_df_zero) +def test_is_low_space_true(caplog, conf): + assert fs.is_low_space(conf) is True + assert ' is less than ' in caplog.records[-1].getMessage() + + +@patch('sbws.util.fs.df', mock_df_enough) +def test_is_low_space_false(conf): + assert fs.is_low_space(conf) is False