コード例 #1
0
    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)
コード例 #2
0
def use(part):
    existing_parts = load_all()
    all_parts = use_part(existing_parts, part)
    files.save('data/parts.json', all_parts)
コード例 #3
0
    def test_save_opens_file_with_write_access(self):
        save('file.json', [{'name': 1}])

        self.open_mock.assert_called_once_with(ANY, 'w+')
コード例 #4
0
    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)
コード例 #5
0
    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)