def it_does_not_create_symlink_on_windows(mocker: MagicMock, remote_dataset: RemoteDataset): stub_release_response = Release( "dataset-slug", "team-slug", "0.1.0", "release-name", "http://darwin-fake-url.com", datetime.now(), None, None, True, True, "json", ) def fake_download_zip(self, path): zip: Path = Path("tests/dataset.zip") shutil.copy(zip, path) return path latest: Path = remote_dataset.local_releases_path / "latest" with patch.object(RemoteDataset, "get_release", return_value=stub_release_response): with patch.object(Release, "download_zip", new=fake_download_zip): remote_dataset.pull() assert not latest.is_symlink()
def it_continues_if_symlink_creation_fails(system_mock: MagicMock, remote_dataset: RemoteDataset): stub_release_response = Release( "dataset-slug", "team-slug", "0.1.0", "release-name", "http://darwin-fake-url.com", datetime.now(), None, None, True, True, "json", ) def fake_download_zip(self, path): zip: Path = Path("tests/dataset.zip") shutil.copy(zip, path) return path latest: Path = remote_dataset.local_releases_path / "latest" with patch.object(Path, "symlink_to") as mock_symlink_to: with patch.object(RemoteDataset, "get_release", return_value=stub_release_response): with patch.object(Release, "download_zip", new=fake_download_zip): mock_symlink_to.side_effect = OSError() remote_dataset.pull() assert not latest.is_symlink()
def it_gets_latest_release_when_not_given_one( system_mock: MagicMock, remote_dataset: RemoteDataset): stub_release_response = Release( "dataset-slug", "team-slug", "0.1.0", "release-name", "http://darwin-fake-url.com", datetime.now(), None, None, True, True, "json", ) def fake_download_zip(self, path): zip: Path = Path("tests/dataset.zip") shutil.copy(zip, path) return path with patch.object( RemoteDataset, "get_release", return_value=stub_release_response) as get_release_stub: with patch.object(Release, "download_zip", new=fake_download_zip): remote_dataset.pull() get_release_stub.assert_called_once()
def it_raises_if_release_format_is_not_json(system_mock: MagicMock, remote_dataset: RemoteDataset): a_release = Release( remote_dataset.slug, remote_dataset.team, "0.1.0", "release-name", "http://darwin-fake-url.com", datetime.now(), None, None, True, True, "xml", ) with pytest.raises(UnsupportedExportFormat): remote_dataset.pull(release=a_release)