def test_open_config_wrong_json(mocker): test_dict = {'config': 'test'} fake_file_path = 'file/path/mock' open_mocker = mocker.patch("ie_serving.main.open", new=mock.mock_open(read_data=str(test_dict))) with pytest.raises(SystemExit): main.open_config(fake_file_path) open_mocker.assert_called_once_with(fake_file_path, 'r')
def test_open_config(mocker): test_dict = {'config': 'test'} test_json = json.dumps(test_dict) fake_file_path = 'file/path/mock' open_mocker = mocker.patch("ie_serving.main.open", new=mock.mock_open(read_data=test_json)) actual = main.open_config(fake_file_path) open_mocker.assert_called_once_with(fake_file_path, 'r') assert actual == test_dict