Skip to content

Commit

Permalink
Remove resources file
Browse files Browse the repository at this point in the history
  • Loading branch information
schloerke committed Nov 14, 2024
1 parent e948f55 commit a1b4440
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 244 deletions.
6 changes: 6 additions & 0 deletions src/posit/connect/_active.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ def __setitem__(self, key: str, value: Any) -> None:
"To retrieve updated values, please retrieve the parent object again."
)

def __delitem__(self, key: str) -> None:
raise NotImplementedError(
"Attributes are locked. "
"To retrieve updated values, please retrieve the parent object again."
)

def __len__(self) -> int:
return self._dict.__len__()

Expand Down
235 changes: 0 additions & 235 deletions src/posit/connect/resources.py

This file was deleted.

20 changes: 11 additions & 9 deletions tests/posit/connect/test_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,28 @@
from unittest import mock
from unittest.mock import Mock

from posit.connect.resources import Resource
import pytest

from posit.connect._active import ResourceDict

config = Mock()
session = Mock()


class FakeResource(Resource):
class FakeResource(ResourceDict):
@property
def foo(self) -> Optional[str]:
return self.get("foo")


class TestResource:
def test_init(self):
p = mock.Mock()
ctx = mock.Mock()
k = "foo"
v = "bar"
d = {k: v}
r = FakeResource(p, **d)
assert r.params == p
r = FakeResource(ctx, **d)
assert r._ctx == ctx

def test__getitem__(self):
warnings.filterwarnings("ignore", category=FutureWarning)
Expand All @@ -41,8 +43,8 @@ def test__setitem__(self):
d = {k: v1}
r = FakeResource(mock.Mock(), **d)
assert r[k] == v1
r[k] = v2
assert r[k] == v2
with pytest.raises(NotImplementedError):
r[k] = v2

def test__delitem__(self):
warnings.filterwarnings("ignore", category=FutureWarning)
Expand All @@ -52,8 +54,8 @@ def test__delitem__(self):
r = FakeResource(mock.Mock(), **d)
assert k in r
assert r[k] == v
del r[k]
assert k not in r
with pytest.raises(NotImplementedError):
del r[k]

def test_foo(self):
k = "foo"
Expand Down

0 comments on commit a1b4440

Please sign in to comment.