diff --git a/sausage_bot/test/file_io_test.py b/sausage_bot/test/file_io_test.py index 7558fd4..ae26271 100755 --- a/sausage_bot/test/file_io_test.py +++ b/sausage_bot/test/file_io_test.py @@ -15,50 +15,6 @@ def test_write_file_input(): 'sausage_bot/test/out/testfile', 1234) is True -def test_import_file_as_list(mocker): - mocker_ensure_file = mocker.patch('os.path.exists') - mocker_ensure_file.return_value.ok = True - mocker_file_size = mocker.patch('os.stat') - mocker_file_size.return_value.ok = 500 - # Valid list - with mock.patch( - 'sausage_bot.util.file_io.open', - new=mock.mock_open(read_data="['one', 'two']")) as _file: - assert file_io.import_file_as_list(_file) == ['one', 'two'] - # Invalid list - with mock.patch( - 'sausage_bot.util.file_io.open', - new=mock.mock_open(read_data="['one', 'two")) as _file: - pytest.raises(SyntaxError) - - -def test_add_to_list(mocker): - mocker_ensure_file = mocker.patch('os.path.exists') - mocker_ensure_file.return_value.ok = True - mocker_file_size = mocker.patch('os.stat') - mocker_file_size.return_value.ok = 500 - # Normal text should be added to the list - with mock.patch( - 'sausage_bot.util.file_io.open', - new=mock.mock_open(read_data="['one', 'two']") - ) as _file: - assert file_io.add_to_list(_file, 'three')\ - == ['one', 'two', 'three'] - - -def test_read_json(mocker): - mocker_ensure_file = mocker.patch('os.path.exists') - mocker_ensure_file.return_value.ok = True - mocker_file_size = mocker.patch('os.stat') - mocker_file_size.return_value.ok = 500 - # Valid dict - with mock.patch('sausage_bot.util.file_io.open', new=mock.mock_open(read_data='{"one": "", "two": []}')) as _file: - assert file_io.read_json(_file) == {'one': '', 'two': []} - # Invalid dict - with mock.patch('sausage_bot.util.file_io.open', new=mock.mock_open(read_data='{"one": "", "two": [')) as _file: - assert file_io.read_json(_file) is None - - def test_file_size(): actual_file = envs.ROOT_DIR / '__main__.py' non_file = envs.ROOT_DIR / 'main.py'