| Total Complexity | 11 |
| Total Lines | 55 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | from yfrake.config import utils |
||
| 2 | from yfrake import client, config |
||
| 3 | import pytest |
||
| 4 | import os |
||
| 5 | |||
| 6 | |||
| 7 | def test_config_1(): |
||
| 8 | path = config.file |
||
| 9 | assert path == utils.get_default_config_path() |
||
| 10 | with pytest.raises(TypeError): |
||
| 11 | del config.file |
||
| 12 | config.file = path |
||
| 13 | |||
| 14 | |||
| 15 | def test_config_2(): |
||
| 16 | assert config.is_locked() is False |
||
| 17 | |||
| 18 | @client.session |
||
| 19 | def main(): |
||
| 20 | with pytest.raises(RuntimeError): |
||
| 21 | config.file = 'asdfg' |
||
| 22 | assert config.is_locked() is True |
||
| 23 | main() |
||
| 24 | |||
| 25 | assert config.is_locked() is False |
||
| 26 | |||
| 27 | |||
| 28 | def test_config_3(): |
||
| 29 | assert not config.HERE.exists() |
||
| 30 | config.file = config.HERE |
||
| 31 | assert config.HERE.exists() |
||
| 32 | |||
| 33 | @client.session |
||
| 34 | def main(): |
||
| 35 | with pytest.raises(RuntimeError): |
||
| 36 | config.file = config.HERE |
||
| 37 | main() |
||
| 38 | |||
| 39 | assert config.HERE.exists() |
||
| 40 | os.remove(config.HERE) |
||
| 41 | assert not config.HERE.exists() |
||
| 42 | |||
| 43 | |||
| 44 | def test_config_4(): |
||
| 45 | assert isinstance(config.settings, dict) |
||
| 46 | with pytest.raises(TypeError): |
||
| 47 | config.settings = dict() |
||
| 48 | with pytest.raises(TypeError): |
||
| 49 | del config.settings |
||
| 50 | |||
| 51 | |||
| 52 | def test_config_5(): |
||
| 53 | with pytest.raises(RuntimeError): |
||
| 54 | config.file = 'bad/path' |
||
| 55 |