Skip to content

Commit

Permalink
style: Lint testing folders (#326)
Browse files Browse the repository at this point in the history
  • Loading branch information
schloerke authored Nov 8, 2024
1 parent 222130e commit 7236487
Show file tree
Hide file tree
Showing 18 changed files with 328 additions and 285 deletions.
4 changes: 3 additions & 1 deletion integration/tests/posit/connect/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
from posit import connect

client = connect.Client()
CONNECT_VERSION = version.parse(client.version)
client_version = client.version
assert client_version is not None
CONNECT_VERSION = version.parse(client_version)
2 changes: 1 addition & 1 deletion integration/tests/posit/connect/test_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def test_find(self):
assert self.client.content.find()

def test_find_by(self):
assert self.client.content.find_by(guid=self.content["guid"]) == self.content
assert self.client.content.find_by(name=self.content["name"]) == self.content

def test_find_one(self):
assert self.client.content.find_one()
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Source = "https://github.com/posit-dev/posit-sdk-py"
Issues = "https://github.com/posit-dev/posit-sdk-py/issues"

[tool.pyright]
include = ["src"]
include = ["src", "tests", "integration/tests"]

[tool.pytest.ini_options]
testpaths = ["tests"]
Expand Down
4 changes: 2 additions & 2 deletions src/posit/connect/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def __init__(
The context object containing the session and URL for API interactions.
content_guid : str
The unique identifier of the content item.
**attrs : _V1Attrs
**attrs : ContentItemRepository._Attrs
Attributes for the content item repository. If not supplied, the attributes will be
retrieved from the API upon initialization
"""
Expand Down Expand Up @@ -690,7 +690,7 @@ def find(self, include: Optional[str | list[Any]] = None, **conditions) -> List[

def find_by(
self,
**attrs: Unpack[ContentItem._Attrs],
**attrs: Unpack[ContentItem._AttrsNotRequired],
) -> Optional[ContentItem]:
"""Find the first content record matching the specified attributes.
Expand Down
3 changes: 2 additions & 1 deletion tests/posit/connect/external/test_databricks.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
from posit.connect import Client
from posit.connect.external.databricks import (
CredentialsProvider,
CredentialsStrategy,
PositCredentialsProvider,
PositCredentialsStrategy,
)


class mock_strategy:
class mock_strategy(CredentialsStrategy):
def auth_type(self) -> str:
return "local"

Expand Down
112 changes: 58 additions & 54 deletions tests/posit/connect/metrics/test_shiny_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@

from posit.connect.metrics import shiny_usage
from posit.connect.resources import ResourceParameters
from posit.connect.urls import Url

from ..api import load_mock
from ..api import load_mock, load_mock_dict


class TestShinyUsageEventAttributes:
@classmethod
def setup_class(cls):
results = load_mock_dict("v1/instrumentation/shiny/usage?limit=500.json")["results"]
assert isinstance(results, list)
cls.event = shiny_usage.ShinyUsageEvent(
mock.Mock(),
**load_mock("v1/instrumentation/shiny/usage?limit=500.json")["results"][0],
**results[0],
)

def test_content_guid(self):
Expand All @@ -37,34 +41,34 @@ class TestShinyUsageFind:
@responses.activate
def test(self):
# behavior
mock_get = [None] * 2
mock_get[0] = responses.get(
"https://connect.example/__api__/v1/instrumentation/shiny/usage",
json=load_mock("v1/instrumentation/shiny/usage?limit=500.json"),
match=[
matchers.query_param_matcher(
{
"limit": 500,
},
),
],
)

mock_get[1] = responses.get(
"https://connect.example/__api__/v1/instrumentation/shiny/usage",
json=load_mock("v1/instrumentation/shiny/usage?limit=500&next=23948901087.json"),
match=[
matchers.query_param_matcher(
{
"next": "23948901087",
"limit": 500,
},
),
],
)
mock_get = [
responses.get(
"https://connect.example/__api__/v1/instrumentation/shiny/usage",
json=load_mock("v1/instrumentation/shiny/usage?limit=500.json"),
match=[
matchers.query_param_matcher(
{
"limit": 500,
},
),
],
),
responses.get(
"https://connect.example/__api__/v1/instrumentation/shiny/usage",
json=load_mock("v1/instrumentation/shiny/usage?limit=500&next=23948901087.json"),
match=[
matchers.query_param_matcher(
{
"next": "23948901087",
"limit": 500,
},
),
],
),
]

# setup
params = ResourceParameters(requests.Session(), "https://connect.example/__api__")
params = ResourceParameters(requests.Session(), Url("https://connect.example/__api__"))

# invoke
events = shiny_usage.ShinyUsage(params).find()
Expand All @@ -79,34 +83,34 @@ class TestShinyUsageFindOne:
@responses.activate
def test(self):
# behavior
mock_get = [None] * 2
mock_get[0] = responses.get(
"https://connect.example/__api__/v1/instrumentation/shiny/usage",
json=load_mock("v1/instrumentation/shiny/usage?limit=500.json"),
match=[
matchers.query_param_matcher(
{
"limit": 500,
},
),
],
)

mock_get[1] = responses.get(
"https://connect.example/__api__/v1/instrumentation/shiny/usage",
json=load_mock("v1/instrumentation/shiny/usage?limit=500&next=23948901087.json"),
match=[
matchers.query_param_matcher(
{
"next": "23948901087",
"limit": 500,
},
),
],
)
mock_get = [
responses.get(
"https://connect.example/__api__/v1/instrumentation/shiny/usage",
json=load_mock("v1/instrumentation/shiny/usage?limit=500.json"),
match=[
matchers.query_param_matcher(
{
"limit": 500,
},
),
],
),
responses.get(
"https://connect.example/__api__/v1/instrumentation/shiny/usage",
json=load_mock("v1/instrumentation/shiny/usage?limit=500&next=23948901087.json"),
match=[
matchers.query_param_matcher(
{
"next": "23948901087",
"limit": 500,
},
),
],
),
]

# setup
params = ResourceParameters(requests.Session(), "https://connect.example/__api__")
params = ResourceParameters(requests.Session(), Url("https://connect.example/__api__"))

# invoke
event = shiny_usage.ShinyUsage(params).find_one()
Expand Down
Loading

0 comments on commit 7236487

Please sign in to comment.