Skip to content

Commit

Permalink
Merge pull request #38 from Transia-RnD/v1.0.2
Browse files Browse the repository at this point in the history
v1.0.2
  • Loading branch information
dangell7 authored Jan 17, 2023
2 parents bcaef74 + 24e5ebd commit 1fc493e
Show file tree
Hide file tree
Showing 12 changed files with 227 additions and 290 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.6, 3.7, 3.8, 3.9]
python-version: [3.7, 3.8, 3.9]
runs-on: ${{ matrix.os }}
steps:
- name: Fix Windows Git autocrlf
Expand Down
22 changes: 8 additions & 14 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,14 @@
The full process for cutting a release is as follows:

0. Checkout a new branch:
`git checkout -b 1.0.0` # 1.0.0-release

1. Python / Pip Bumpversion

`pip3 install bumpversion`

`bumpversion --current-version 1.0.0 minor setup.py xumm/__init__.py`
`git checkout -b v1.0.2` # 1.0.2-release

2. Change the version in the setup.py file:
`VERSION = "1.0.0"`
`VERSION = "1.0.2"`

3. Add, and commit the changes, push up the branch, and open a PR:
`git add .`
`git commit -m 'RELEASE 1.0.0'`
`git commit -m 'RELEASE v1.0.2'`
`git push --set-upstream origin HEAD`

4. Open PR request
Expand All @@ -29,13 +23,13 @@ The full process for cutting a release is as follows:
`git checkout main`

6. Delete `main` branch (Optional):
`git branch -d 1.0.0`
`git branch -d v1.0.2`

7. Make a new Git tag that matches the new version (make sure it is associated with the right commit SHA): FIXUP
`git tag -a 1.0.0 -m "cut 1.0.0"`
`git tag -a v1.0.2 -m "cut v1.0.2"`

8. Push up the tag from `main`:
`git push origin 1.0.0`
`git push origin v1.0.2`

## Packaging & Releasing

Expand All @@ -49,8 +43,8 @@ Build Repo

```
dist/
xumm-sdk-py-1.0.0-py3-none-any.whl
xumm-sdk-py-1.0.0.tar.gz
xumm-sdk-py-1.0.2-py3-none-any.whl
xumm-sdk-py-1.0.2.tar.gz
```

Install Twine
Expand Down
49 changes: 49 additions & 0 deletions tests/test_push.py
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'])
33 changes: 0 additions & 33 deletions tests/test_xapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@
from testing_config import BaseTestConfig
from unittest.mock import Mock, patch

from xumm.resource.types import (
XummXappEventRequest,
XummXappPushRequest,
)

import xumm

class TestXapp(BaseTestConfig):
Expand All @@ -28,31 +23,3 @@ def test_xapp_ott(cls, mock_get):
mock_get.return_value = Mock(status_code=200)
mock_get.return_value.json.return_value = cls.json_fixtures['xApp']['get']
cls.assertEqual(cls.sdk.xapp.ott(cls.token).to_dict(), cls.json_fixtures['xApp']['get'])

@patch('xumm.client.requests.post')
def test_xapp_event(cls, mock_post):
print('should set xapp event')

mock_post.return_value = Mock(status_code=200)
mock_post.return_value.json.return_value = cls.json_fixtures['xApp']['event']

payload: XummXappEventRequest = XummXappEventRequest(
user_token='',
body='',
)
result = cls.sdk.xapp.event(payload)
cls.assertEqual(result.to_dict(), cls.json_fixtures['xApp']['event'])

@patch('xumm.client.requests.post')
def test_xapp_push(cls, mock_post):
print('should set xapp event')

mock_post.return_value = Mock(status_code=200)
mock_post.return_value.json.return_value = cls.json_fixtures['xApp']['push']

payload: XummXappPushRequest = XummXappPushRequest(
user_token='',
body='',
)
result = cls.sdk.xapp.push(payload)
cls.assertEqual(result.to_dict(), cls.json_fixtures['xApp']['push'])
2 changes: 2 additions & 0 deletions xumm/resource/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from xumm.resource.storage import StorageResource
from xumm.resource.user_tokens import UserTokensResource
from xumm.resource.xapp import XappResource
from xumm.resource.push import PushResource


class XummSdk(XummResource):
Expand Down Expand Up @@ -64,6 +65,7 @@ def __init__(cls, *args) -> 'XummSdk':
cls.payload = PayloadResource()
cls.storage = StorageResource()
cls.xapp = XappResource()
cls.push = PushResource()

def refresh_from(cls, **kwargs):
return super().refresh_from(**kwargs)
Expand Down
57 changes: 57 additions & 0 deletions xumm/resource/push.py
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)
8 changes: 4 additions & 4 deletions xumm/resource/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
from .storage.storage_set_response import StorageSetResponse # noqa: F401

from .xapp.xapp_ott_response import XappOttResponse # noqa: F401
from .xapp.xapp_event_response import XappEventResponse # noqa: F401
from .xapp.xapp_push_response import XappPushResponse # noqa: F401

from .push.push_event_response import PushEventResponse # noqa: F401
from .push.push_push_response import PushPushResponse # noqa: F401

from .meta.user_tokens import ( # noqa: F401
UserTokenValidity,
Expand All @@ -43,6 +44,5 @@
XummDeletePayloadResponse as DeletedPayload,
XummGetPayloadResponse as XummPayload,
XummWebhookBody,
XummXappEventRequest,
XummXappPushRequest,
XummPushEventRequest,
)
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from xumm.resource import XummResource


class XappEventResponse(XummResource):
class PushEventResponse(XummResource):
"""
Attributes:
model_types (dict): The key is attribute name
Expand Down Expand Up @@ -32,8 +32,8 @@ def refresh_from(cls, **kwargs):
:param kwargs: A dict.
:type: dict
:return: The XappEventResponse of this XappEventResponse. # noqa: E501
:rtype: XappEventResponse
:return: The PushEventResponse of this PushEventResponse. # noqa: E501
:rtype: PushEventResponse
"""
cls.sanity_check(kwargs)
cls._pushed = None
Expand All @@ -43,40 +43,40 @@ def refresh_from(cls, **kwargs):

@property
def pushed(self) -> bool:
"""Gets the pushed of this XappEventResponse.
"""Gets the pushed of this PushEventResponse.
:return: The pushed of this XappEventResponse.
:return: The pushed of this PushEventResponse.
:rtype: bool
"""
return self._pushed

@pushed.setter
def pushed(self, pushed: bool):
"""Sets the pushed of this XappEventResponse.
"""Sets the pushed of this PushEventResponse.
:param pushed: The pushed of this XappEventResponse.
:param pushed: The pushed of this PushEventResponse.
:type pushed: bool
"""
self._pushed = pushed

@property
def uuid(self) -> str:
"""Gets the uuid of this XappEventResponse.
"""Gets the uuid of this PushEventResponse.
:return: The uuid of this XappEventResponse.
:return: The uuid of this PushEventResponse.
:rtype: str
"""
return self._uuid

@uuid.setter
def uuid(self, uuid: str):
"""Sets the uuid of this XappEventResponse.
"""Sets the uuid of this PushEventResponse.
:param uuid: The uuid of this XappEventResponse.
:param uuid: The uuid of this PushEventResponse.
:type uuid: str
"""
self._uuid = uuid
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from xumm.resource import XummResource


class XappPushResponse(XummResource):
class PushPushResponse(XummResource):
"""
Attributes:
model_types (dict): The key is attribute name
Expand All @@ -29,29 +29,29 @@ def refresh_from(cls, **kwargs):
:param kwargs: A dict.
:type: dict
:return: The XappPushResponse of this XappPushResponse. # noqa: E501
:rtype: XappPushResponse
:return: The PushPushResponse of this PushPushResponse. # noqa: E501
:rtype: PushPushResponse
"""
cls.sanity_check(kwargs)
cls._pushed = None
cls.pushed = kwargs['pushed']

@property
def pushed(self) -> bool:
"""Gets the pushed of this XappPushResponse.
"""Gets the pushed of this PushPushResponse.
:return: The pushed of this XappPushResponse.
:return: The pushed of this PushPushResponse.
:rtype: bool
"""
return self._pushed

@pushed.setter
def pushed(self, pushed: bool):
"""Sets the pushed of this XappPushResponse.
"""Sets the pushed of this PushPushResponse.
:param pushed: The pushed of this XappPushResponse.
:param pushed: The pushed of this PushPushResponse.
:type pushed: bool
"""
self._pushed = pushed
Loading

0 comments on commit 1fc493e

Please sign in to comment.