-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Topic subscriber models #451
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #451 +/- ##
========================================
Coverage 15.29% 15.30%
========================================
Files 28 28
Lines 3819 3908 +89
========================================
+ Hits 584 598 +14
- Misses 3235 3310 +75 ☔ View full report in Codecov by Sentry. |
brewtils/test/fixtures.py
Outdated
@pytest.fixture | ||
def subscriber_dict(): | ||
"""Subscribers as a dictionary.""" | ||
return { | ||
"garden": "garden", | ||
"namespace": "ns", | ||
"system": "system", | ||
"version": "1.0.0", | ||
"instance": None, | ||
"command": None, | ||
} | ||
|
||
|
||
@pytest.fixture | ||
def topic_subscriber_dict(subscriber_dict): | ||
"""Topic subscribers as dict""" | ||
return {"topic": "foo", "subscribers": [subscriber_dict]} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need both the dict and bg_models for these objects. That way it can also be evaluated in the test/schema_parser_test.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. Added tests in test/schema_parser_test.py.
brewtils/models.py
Outdated
|
||
def __init__(self, topic=None, subscribers=[]): | ||
self.topic = topic | ||
self.subscribers = subscribers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Purely a style comment, in our other models if there is a list, we set the default to None. Then on the assign we do:
self.subscribers = subscribers or []
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
brewtils/rest/client.py
Outdated
return self.session.get(self.topic_url + quote(topic_name), params=kwargs) | ||
|
||
@enable_auth | ||
def get_topics(self, **kwargs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the API going to support kwargs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not at this time. Removed kwargs from get_topics.
Only minor comment is we need to stub out the change log for this. This will be released in 3.25.1, and will have a dependency of Beer Garden being 3.25 or newer |
brewtils/rest/client.py
Outdated
@@ -943,3 +944,71 @@ def get_tokens(self, username=None, password=None): | |||
self.session.headers["Authorization"] = "Bearer " + self.access_token | |||
|
|||
return response | |||
|
|||
@enable_auth | |||
def get_topic(self, topic_id, **kwargs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure you need the **kwargs
here. Only the topic_id
is passed forward and the API doesn't access additional parameters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed kwargs
@wrap_response(parse_method="parse_topic", parse_many=False, default_exc=SaveError) | ||
def create_topic(self, topic): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a patch_topic
in the client.py and no here. Take a look at update_request
in this file for an example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added update_topic to easy client and related tests.
No description provided.