Skip to content

Commit 3da6bb3

Browse files
committed
add support and tests for upload/version_delete
1 parent 37614a4 commit 3da6bb3

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

pins/boards.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,10 @@ def pin_versions(self, name: str, as_df: bool = True) -> Sequence[VersionRaw]:
8989
Pin name.
9090
9191
"""
92-
if self.versioned is False:
93-
raise NotImplementedError()
92+
if not self.versioned:
93+
raise NotImplementedError(
94+
"Cannot show versions for a board type that does not support versioning."
95+
)
9496

9597
if not self.pin_exists(name):
9698
raise PinsError("Cannot check version, since pin %s does not exist" % name)
@@ -236,6 +238,11 @@ def _pin_store(
236238
created: Optional[datetime] = None,
237239
) -> Meta:
238240

241+
if not self.versioned:
242+
raise NotImplementedError(
243+
"Can only write pins with boards that support versioning."
244+
)
245+
239246
if type == "feather":
240247
warn_deprecated(
241248
'Writing pin type "feather" is unsupported. Switching type to "arrow".'
@@ -453,6 +460,10 @@ def pin_version_delete(self, name: str, version: str):
453460
version:
454461
Version identifier.
455462
"""
463+
if not self.versioned:
464+
raise NotImplementedError(
465+
"Can only write pins with boards that support versioning."
466+
)
456467

457468
pin_name = self.path_to_pin(name)
458469

pins/tests/test_constructors.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ def test_constructor_board_url_data(tmp_cache, http_example_board_path, df_csv):
7373

7474
@pytest.mark.xfail
7575
@pytest.mark.skip_on_github
76-
def test_constructor_board_url_cache(tmp_cache, http_example_board_path, df_csv):
76+
def test_constructor_board_url_cache(
77+
tmp_cache, http_example_board_path, df_csv, tmp_path
78+
):
7779
# TODO: downloading a pin does not put files in the same directory, since
7880
# in this case we are hashing on the full url.
7981

@@ -85,12 +87,19 @@ def test_constructor_board_url_cache(tmp_cache, http_example_board_path, df_csv)
8587

8688
board.pin_read("df_csv")
8789

88-
# cannot read or view pin versions
90+
# cannot write or view pin versions
8991

9092
with pytest.raises(NotImplementedError):
9193
board.pin_write(df_csv)
9294
with pytest.raises(NotImplementedError):
9395
board.pin_versions("df_csv")
96+
with pytest.raises(NotImplementedError):
97+
board.pin_version_delete(name="df_csv", version="20220214T163718Z")
98+
with pytest.raises(NotImplementedError):
99+
df = pd.DataFrame({"x": [1, 2, 3]})
100+
path = tmp_path / "data.csv"
101+
df.to_csv(path, index=False)
102+
board.pin_upload(path, "cool_pin")
94103

95104
# check cache ----
96105
http_dirs = list(tmp_cache.glob("http_*"))

0 commit comments

Comments
 (0)