Example #1
0
    def test_move_chart_save_folder_path_called_on_correct_argument(self,
                                                                    mocked_path,
                                                                    ):
        """Mocking call to path and mkdir method on Path class didn't work."""
        assert move_chart_save_folder(self.test_original_location,
                                      self.test_new_location) is None

        mocked_path.assert_called_once_with(self.test_original_location)
Example #2
0
    def test_move_chart_save_folder_original_nonexistent(self,
                                                         mocked_path_exists,
                                                         mocked_move_file,
                                                         ):
        mocked_path_exists.return_value = False

        assert move_chart_save_folder(self.test_original_location,
                                      self.test_new_location) is None

        mocked_move_file.assert_not_called()
    def test_move_chart_save_folder(self, monkeypatch,
                                    original_location_exists):
        test_original_save_folder_path = Path('somewhere')
        test_new_save_folder_path = Path('somewhere else')
        move_file_mock = {'called': False}

        def mocked_move_file(original_location, new_location):
            assert (original_location,
                    new_location) == (test_original_save_folder_path,
                                      test_new_save_folder_path)
            move_file_mock['called'] = True

        monkeypatch.setattr(settings_functions.Path, 'exists',
                            lambda path: original_location_exists)
        monkeypatch.setattr(settings_functions, 'move_file', mocked_move_file)

        assert move_chart_save_folder(test_original_save_folder_path,
                                      test_new_save_folder_path) is None

        assert move_file_mock['called'] == original_location_exists