diff --git a/aioalice/__init__.py b/aioalice/__init__.py index 898bcce..6551fc3 100644 --- a/aioalice/__init__.py +++ b/aioalice/__init__.py @@ -11,4 +11,4 @@ asyncio.set_event_loop_policy(uvloop.EventLoopPolicy()) -__version__ = '1.1.6' +__version__ = '1.1.7' diff --git a/aioalice/types/meta.py b/aioalice/types/meta.py index abb0284..b7f02db 100644 --- a/aioalice/types/meta.py +++ b/aioalice/types/meta.py @@ -8,3 +8,4 @@ class Meta(AliceObject): locale = attrib(type=str) timezone = attrib(type=str) client_id = attrib(type=str) + flags = attrib(factory=list) diff --git a/setup.py b/setup.py index 9ae3733..e1993a5 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ if sys.version_info < MINIMAL_PY_VERSION: raise RuntimeError('aioAlice works only with Python {}+'.format('.'.join(map(str, MINIMAL_PY_VERSION)))) -__version__ = '1.1.6' +__version__ = '1.1.7' def get_description(): diff --git a/tests/_dataset.py b/tests/_dataset.py index 6702a70..efe9265 100644 --- a/tests/_dataset.py +++ b/tests/_dataset.py @@ -169,7 +169,6 @@ "title": CARD_TITLE, "description": CARD_DESCR, "button": deepcopy(MEDIA_BUTTON), - "footer": deepcopy(FOOTER) } @@ -202,3 +201,28 @@ "session": BASE_SESSION, "version": "1.0" } + + +DATA_FROM_STATION = { + 'meta': { + 'client_id': 'ru.yandex.quasar.services/1.0 (Yandex Station; android 6.0.1)', + 'flags': [ + 'no_cards_support' + ], + 'locale': 'ru-RU', + 'timezone': 'Europe/Moscow' + }, + 'request': { + 'command': '', + 'original_utterance': 'запусти навык qwerty', + 'type': 'SimpleUtterance' + }, + 'session': { + 'message_id': 0, + 'new': True, + 'session_id': '618709-bb99dd92-82c4f626-442a4', + 'skill_id': '94d16-a32f-4932-9f5e-354d31f71998', + 'user_id': 'CFC516B0EC123B86C78532BCEC1C33CBF05D54EF15C8001B52628EF49F580' + }, + 'version': '1.0' +} diff --git a/tests/test_types.py b/tests/test_types.py index 0d72826..9efe745 100644 --- a/tests/test_types.py +++ b/tests/test_types.py @@ -15,7 +15,8 @@ EXPECTED_CARD_ITEMS_LIST_JSON, RESPONSE_TEXT, \ RESPONSE_BUTTON, \ EXPECTED_ALICE_RESPONSE_BIG_IMAGE_WITH_BUTTON, \ - EXPECTED_ALICE_RESPONSE_ITEMS_LIST_WITH_BUTTON + EXPECTED_ALICE_RESPONSE_ITEMS_LIST_WITH_BUTTON, \ + DATA_FROM_STATION class TestAliceTypes(unittest.TestCase): @@ -28,6 +29,8 @@ def _test_meta(self, meta, dct): self.assertEqual(meta.locale, dct['locale']) self.assertEqual(meta.timezone, dct['timezone']) self.assertEqual(meta.client_id, dct['client_id']) + if 'flags' in dct: + self.assertEqual(meta.flags, dct['flags']) def test_meta(self): meta = types.Meta(**META) @@ -44,7 +47,8 @@ def _test_request(self, req, dct): self.assertEqual(req.command, dct['command']) self.assertEqual(req.original_utterance, dct['original_utterance']) self.assertEqual(req.type, dct['type']) - self.assertEqual(req.payload, dct['payload']) + if 'payload' in dct: + self.assertEqual(req.payload, dct['payload']) if 'markup' in dct: self._test_markup(req.markup, dct['markup']) @@ -123,10 +127,15 @@ def _test_alice_request(self, arq, dct): self._test_request(arq.request, dct['request']) self._test_meta(arq.meta, dct['meta']) + def _test_alice_request_from_dct(self, dct): + alice_request = types.AliceRequest(**dct) + self._test_alice_request(alice_request, dct) + def test_alice_request(self): - alice_request = types.AliceRequest(**ALICE_REQUEST) - self.assertEqual(alice_request.to_json(), ALICE_REQUEST) - self._test_alice_request(alice_request, ALICE_REQUEST) + self._test_alice_request_from_dct(ALICE_REQUEST) + + def test_alice_request_from_station(self): + self._test_alice_request_from_dct(DATA_FROM_STATION) def _test_alice_response(self, arp, dct): self.assertEqual(arp.version, dct['version']) @@ -159,7 +168,6 @@ def test_response_big_image_from_request(self): alice_response = alice_request.response_big_image( RESPONSE_TEXT, IMAGE_ID, CARD_TITLE, CARD_DESCR, types.MediaButton(BUTTON_TEXT, URL, MB_PAYLOAD), - types.CardFooter(FOOTER_TEXT, MEDIA_BUTTON), buttons=[RESPONSE_BUTTON] ) self._assert_payload(alice_response, EXPECTED_ALICE_RESPONSE_BIG_IMAGE_WITH_BUTTON) @@ -225,7 +233,6 @@ def test_card_big_image(self): title=CARD_TITLE, description=CARD_DESCR, button=types.MediaButton(BUTTON_TEXT, URL, MB_PAYLOAD), - footer=types.CardFooter(FOOTER_TEXT, MEDIA_BUTTON) ) self._assert_payload(card_big_image, EXPECTED_CARD_BIG_IMAGE_JSON) @@ -233,7 +240,6 @@ def test_card_big_image_card_method(self): card_big_image = types.Card.big_image( IMAGE_ID, CARD_TITLE, CARD_DESCR, types.MediaButton(BUTTON_TEXT, URL, MB_PAYLOAD), - types.CardFooter(FOOTER_TEXT, MEDIA_BUTTON) ) self._assert_payload(card_big_image, EXPECTED_CARD_BIG_IMAGE_JSON)