"""Test utils.""" from unittest.mock import MagicMock, patch from backfill.utils import generate_local_filepath @patch("backfill.utils.uuid4") def test_generate_local_filepath( mock_uuid4: MagicMock, ) -> None: """Test generate_local_filepath.""" mock_uuid4.return_value = "uuid4here" actual = generate_local_filepath("some/folder/users.csv") assert actual == "/mnt/pdp-backfill/uuid4here.csv" mock_uuid4.assert_called_once() @patch("backfill.utils.uuid4") def test_generate_local_filepath_when_key_has_no_extension( mock_uuid4: MagicMock, ) -> None: """Test generate_local_filepath, when key has no extension.""" mock_uuid4.return_value = "uuid4here" actual = generate_local_filepath("some/folder/users", default_extension=".dogs") assert actual == "/mnt/pdp-backfill/uuid4here.dogs" mock_uuid4.assert_called_once() @patch("backfill.utils.uuid4") def test_generate_local_filepath_uses_default_extension( mock_uuid4: MagicMock, ) -> None: """Test generate_local_filepath, when key has no extension will use the default.""" mock_uuid4.return_value = "uuid4here" actual = generate_local_filepath("some/folder/users") assert actual == "/mnt/pdp-backfill/uuid4here.csv" mock_uuid4.assert_called_once()