Skip to content

Commit

Permalink
Removed some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
geirawsm committed Oct 7, 2023
1 parent ed09383 commit dcc7d36
Showing 1 changed file with 0 additions and 44 deletions.
44 changes: 0 additions & 44 deletions sausage_bot/test/file_io_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit dcc7d36

Please sign in to comment.