Skip to content

Commit

Permalink
Fix lints
Browse files Browse the repository at this point in the history
  • Loading branch information
schloerke committed Nov 8, 2024
1 parent 8bf414d commit ca94ffd
Show file tree
Hide file tree
Showing 14 changed files with 321 additions and 280 deletions.
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 ca94ffd

Please sign in to comment.