Skip to content

Commit 7236487

Browse files
authored
style: Lint testing folders (#326)
1 parent 222130e commit 7236487

File tree

18 files changed

+328
-285
lines changed

18 files changed

+328
-285
lines changed

integration/tests/posit/connect/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@
33
from posit import connect
44

55
client = connect.Client()
6-
CONNECT_VERSION = version.parse(client.version)
6+
client_version = client.version
7+
assert client_version is not None
8+
CONNECT_VERSION = version.parse(client_version)

integration/tests/posit/connect/test_content.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def test_find(self):
2929
assert self.client.content.find()
3030

3131
def test_find_by(self):
32-
assert self.client.content.find_by(guid=self.content["guid"]) == self.content
32+
assert self.client.content.find_by(name=self.content["name"]) == self.content
3333

3434
def test_find_one(self):
3535
assert self.client.content.find_one()

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Source = "https://github.com/posit-dev/posit-sdk-py"
2626
Issues = "https://github.com/posit-dev/posit-sdk-py/issues"
2727

2828
[tool.pyright]
29-
include = ["src"]
29+
include = ["src", "tests", "integration/tests"]
3030

3131
[tool.pytest.ini_options]
3232
testpaths = ["tests"]

src/posit/connect/content.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def __init__(
8181
The context object containing the session and URL for API interactions.
8282
content_guid : str
8383
The unique identifier of the content item.
84-
**attrs : _V1Attrs
84+
**attrs : ContentItemRepository._Attrs
8585
Attributes for the content item repository. If not supplied, the attributes will be
8686
retrieved from the API upon initialization
8787
"""
@@ -690,7 +690,7 @@ def find(self, include: Optional[str | list[Any]] = None, **conditions) -> List[
690690

691691
def find_by(
692692
self,
693-
**attrs: Unpack[ContentItem._Attrs],
693+
**attrs: Unpack[ContentItem._AttrsNotRequired],
694694
) -> Optional[ContentItem]:
695695
"""Find the first content record matching the specified attributes.
696696

tests/posit/connect/external/test_databricks.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
from posit.connect import Client
77
from posit.connect.external.databricks import (
88
CredentialsProvider,
9+
CredentialsStrategy,
910
PositCredentialsProvider,
1011
PositCredentialsStrategy,
1112
)
1213

1314

14-
class mock_strategy:
15+
class mock_strategy(CredentialsStrategy):
1516
def auth_type(self) -> str:
1617
return "local"
1718

tests/posit/connect/metrics/test_shiny_usage.py

Lines changed: 58 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,19 @@
66

77
from posit.connect.metrics import shiny_usage
88
from posit.connect.resources import ResourceParameters
9+
from posit.connect.urls import Url
910

10-
from ..api import load_mock
11+
from ..api import load_mock, load_mock_dict
1112

1213

1314
class TestShinyUsageEventAttributes:
15+
@classmethod
1416
def setup_class(cls):
17+
results = load_mock_dict("v1/instrumentation/shiny/usage?limit=500.json")["results"]
18+
assert isinstance(results, list)
1519
cls.event = shiny_usage.ShinyUsageEvent(
1620
mock.Mock(),
17-
**load_mock("v1/instrumentation/shiny/usage?limit=500.json")["results"][0],
21+
**results[0],
1822
)
1923

2024
def test_content_guid(self):
@@ -37,34 +41,34 @@ class TestShinyUsageFind:
3741
@responses.activate
3842
def test(self):
3943
# behavior
40-
mock_get = [None] * 2
41-
mock_get[0] = responses.get(
42-
"https://connect.example/__api__/v1/instrumentation/shiny/usage",
43-
json=load_mock("v1/instrumentation/shiny/usage?limit=500.json"),
44-
match=[
45-
matchers.query_param_matcher(
46-
{
47-
"limit": 500,
48-
},
49-
),
50-
],
51-
)
52-
53-
mock_get[1] = responses.get(
54-
"https://connect.example/__api__/v1/instrumentation/shiny/usage",
55-
json=load_mock("v1/instrumentation/shiny/usage?limit=500&next=23948901087.json"),
56-
match=[
57-
matchers.query_param_matcher(
58-
{
59-
"next": "23948901087",
60-
"limit": 500,
61-
},
62-
),
63-
],
64-
)
44+
mock_get = [
45+
responses.get(
46+
"https://connect.example/__api__/v1/instrumentation/shiny/usage",
47+
json=load_mock("v1/instrumentation/shiny/usage?limit=500.json"),
48+
match=[
49+
matchers.query_param_matcher(
50+
{
51+
"limit": 500,
52+
},
53+
),
54+
],
55+
),
56+
responses.get(
57+
"https://connect.example/__api__/v1/instrumentation/shiny/usage",
58+
json=load_mock("v1/instrumentation/shiny/usage?limit=500&next=23948901087.json"),
59+
match=[
60+
matchers.query_param_matcher(
61+
{
62+
"next": "23948901087",
63+
"limit": 500,
64+
},
65+
),
66+
],
67+
),
68+
]
6569

6670
# setup
67-
params = ResourceParameters(requests.Session(), "https://connect.example/__api__")
71+
params = ResourceParameters(requests.Session(), Url("https://connect.example/__api__"))
6872

6973
# invoke
7074
events = shiny_usage.ShinyUsage(params).find()
@@ -79,34 +83,34 @@ class TestShinyUsageFindOne:
7983
@responses.activate
8084
def test(self):
8185
# behavior
82-
mock_get = [None] * 2
83-
mock_get[0] = responses.get(
84-
"https://connect.example/__api__/v1/instrumentation/shiny/usage",
85-
json=load_mock("v1/instrumentation/shiny/usage?limit=500.json"),
86-
match=[
87-
matchers.query_param_matcher(
88-
{
89-
"limit": 500,
90-
},
91-
),
92-
],
93-
)
94-
95-
mock_get[1] = responses.get(
96-
"https://connect.example/__api__/v1/instrumentation/shiny/usage",
97-
json=load_mock("v1/instrumentation/shiny/usage?limit=500&next=23948901087.json"),
98-
match=[
99-
matchers.query_param_matcher(
100-
{
101-
"next": "23948901087",
102-
"limit": 500,
103-
},
104-
),
105-
],
106-
)
86+
mock_get = [
87+
responses.get(
88+
"https://connect.example/__api__/v1/instrumentation/shiny/usage",
89+
json=load_mock("v1/instrumentation/shiny/usage?limit=500.json"),
90+
match=[
91+
matchers.query_param_matcher(
92+
{
93+
"limit": 500,
94+
},
95+
),
96+
],
97+
),
98+
responses.get(
99+
"https://connect.example/__api__/v1/instrumentation/shiny/usage",
100+
json=load_mock("v1/instrumentation/shiny/usage?limit=500&next=23948901087.json"),
101+
match=[
102+
matchers.query_param_matcher(
103+
{
104+
"next": "23948901087",
105+
"limit": 500,
106+
},
107+
),
108+
],
109+
),
110+
]
107111

108112
# setup
109-
params = ResourceParameters(requests.Session(), "https://connect.example/__api__")
113+
params = ResourceParameters(requests.Session(), Url("https://connect.example/__api__"))
110114

111115
# invoke
112116
event = shiny_usage.ShinyUsage(params).find_one()

0 commit comments

Comments
 (0)