def test_data_is_written_with_open_file(self): save('file.json', [{'name': 1}]) open_context_mock = self.open_mock.return_value \ .__enter__.return_value self.json_mock.dump.assert_called_once_with(ANY, open_context_mock, indent=ANY)
def use(part): existing_parts = load_all() all_parts = use_part(existing_parts, part) files.save('data/parts.json', all_parts)
def test_save_opens_file_with_write_access(self): save('file.json', [{'name': 1}]) self.open_mock.assert_called_once_with(ANY, 'w+')
def test_data_is_written_as_json(self): data = [{'name': 1}] save('file.json', data) self.json_mock.dump.assert_called_once_with(data, ANY, indent=2)
def test_save_sets_path_of_file_to_save(self): save('file.json', [{'name': 1}]) self.open_mock.assert_called_once_with('file.json', ANY)