-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from Transia-RnD/v1.0.2
v1.0.2
- Loading branch information
Showing
12 changed files
with
227 additions
and
290 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/usr/bin/env python | ||
# coding: utf-8 | ||
|
||
from testing_config import BaseTestConfig | ||
from unittest.mock import Mock, patch | ||
|
||
from xumm.resource.types import ( | ||
XummPushEventRequest, | ||
) | ||
|
||
import xumm | ||
|
||
class TestXapp(BaseTestConfig): | ||
|
||
token: str = '' | ||
|
||
@classmethod | ||
def setUp(cls): | ||
xumm.api_key = cls.json_fixtures['api']['key'] | ||
xumm.api_secret = cls.json_fixtures['api']['secret'] | ||
cls.sdk = xumm.XummSdk() | ||
|
||
@patch('xumm.client.requests.post') | ||
def test_push_event(cls, mock_post): | ||
print('should set push event') | ||
|
||
mock_post.return_value = Mock(status_code=200) | ||
mock_post.return_value.json.return_value = cls.json_fixtures['xApp']['event'] | ||
|
||
payload: XummPushEventRequest = XummPushEventRequest( | ||
user_token='', | ||
body='', | ||
) | ||
result = cls.sdk.push.event(payload) | ||
cls.assertEqual(result.to_dict(), cls.json_fixtures['xApp']['event']) | ||
|
||
@patch('xumm.client.requests.post') | ||
def test_push_push(cls, mock_post): | ||
print('should set push event') | ||
|
||
mock_post.return_value = Mock(status_code=200) | ||
mock_post.return_value.json.return_value = cls.json_fixtures['xApp']['push'] | ||
|
||
payload: XummPushEventRequest = XummPushEventRequest( | ||
user_token='', | ||
body='', | ||
) | ||
result = cls.sdk.push.push(payload) | ||
cls.assertEqual(result.to_dict(), cls.json_fixtures['xApp']['push']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/usr/bin/env python | ||
# coding: utf-8 | ||
|
||
from xumm import client | ||
from xumm.resource import XummResource | ||
|
||
from .types import ( | ||
PushEventResponse, | ||
PushPushResponse, | ||
XummPushEventRequest, | ||
) | ||
|
||
|
||
class PushResource(XummResource): | ||
|
||
@classmethod | ||
def event_url(cls) -> str: | ||
""" | ||
Gets the POST url of this PushResource | ||
:return: The POST url of this PushResource. | ||
:rtype: str | ||
""" | ||
return super(PushResource, cls).platform_url() + 'xapp/event' + '/' # noqa: E501 | ||
|
||
@classmethod | ||
def push_url(cls) -> str: | ||
""" | ||
Gets the POST url of this PushResource | ||
:return: The POST url of this PushResource. | ||
:rtype: str | ||
""" | ||
return super(PushResource, cls).platform_url() + 'xapp/push' + '/' # noqa: E501 | ||
|
||
def refresh_from(cls, **kwargs) -> 'PushResource': | ||
return cls | ||
|
||
def event(cls, payload: XummPushEventRequest) -> PushEventResponse: | ||
"""Returns the dict as a model | ||
:return: The PushEventResponse of this PushEventResponse. # noqa: E501 | ||
:rtype: PushEventResponse | ||
""" | ||
|
||
res = client.post(cls.event_url(), payload.to_dict()) | ||
return PushEventResponse(**res) | ||
|
||
def push(cls, payload: XummPushEventRequest) -> PushPushResponse: | ||
"""Returns the dict as a model | ||
:return: The PushPushResponse of this PushPushResponse. # noqa: E501 | ||
:rtype: PushPushResponse | ||
""" | ||
|
||
res = client.post(cls.push_url(), payload.to_dict()) | ||
return PushPushResponse(**res) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.