Skip to content

Commit 849ab75

Browse files
committed
Create test_api_endpoint.py
1 parent cb7af36 commit 849ab75

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import pytest
2+
import requests
3+
4+
from posit.connect._api import ApiDictEndpoint, ReadOnlyDict
5+
from posit.connect.context import Context
6+
from posit.connect.urls import Url
7+
8+
9+
class TestApiEndpoint:
10+
def test_read_only(self):
11+
obj = ReadOnlyDict({})
12+
13+
assert len(obj) == 0
14+
15+
assert obj.get("foo", "bar") == "bar"
16+
17+
with pytest.raises(AttributeError):
18+
obj["foo"] = "baz"
19+
20+
obj._set_attrs(foo="qux", a="b")
21+
assert len(obj) == 2
22+
assert obj["foo"] == "qux"
23+
assert obj["a"] == "b"
24+
25+
def test_api_dict_endpoint(self):
26+
session = requests.Session()
27+
ctx = Context(session, Url("http://connect.example"))
28+
29+
end = ApiDictEndpoint(ctx=ctx, path="/some/sub/path", attrs={"uid_key": "guid"})

0 commit comments

Comments
 (0)