예제 #1
0
    def test_create_custom_user_agent_to_valid_skill_initialization(self):
        SkillAdapter(skill=self.mock_skill, verify_signature=False,
                     verify_timestamp=False)

        self.assertEqual(
            "ask-webservice django-ask-sdk", self.mock_skill.custom_user_agent,
            "SkillAdapter didn't update custom user agent "
            "for a valid custom skill without a user agent set")
예제 #2
0
 def test_unset_verify_signature_on_init(self):
     test_skill_adapter = SkillAdapter(
         skill=self.mock_skill, verify_signature=False)
     
     self.assertEqual(
         len(test_skill_adapter._verifiers), 0,
         "SkillAdapter constructor set incorrect verifiers when "
         "request_signature value is provided as False")
예제 #3
0
    def test_invalid_skill_instance_throw_exception(self):
        with self.assertRaises(TypeError) as exc:
            SkillAdapter(skill=None)

        self.assertIn(
            "Invalid skill instance provided", str(exc.exception),
            "SkillAdapter constructor didn't throw exception for "
            "invalid skill input")
예제 #4
0
    def test_add_custom_user_agent_to_valid_skill_initialization(self):
        SkillAdapter(skill=self.mock_skill,
                     verify_signature=False,
                     verify_timestamp=False)

        self.assertIn(
            "django-ask-sdk", self.mock_skill.custom_user_agent,
            "SkillAdapter didn't update custom user agent "
            "for a valid custom skill")
예제 #5
0
    def test_request_dispatch_http_get_throw_method_not_allowed(self):
        self.mock_http_request.method = "GET"

        test_http_response = SkillAdapter.as_view(
            skill=self.mock_skill)(self.mock_http_request)

        self.assertEqual(
            test_http_response.status_code, 405,
            "SkillAdapter view didn't raise method not allowed exception "
            "when a HTTP GET request is passed to it.")
예제 #6
0
    def test_request_dispatch_verification_failure_throw_exception(self):
        mocked_handler = mock.MagicMock(spec=WebserviceSkillHandler)
        mocked_handler.verify_request_and_dispatch.side_effect = \
            VerificationException("test")
        with mock.patch("django_ask_sdk.skill_adapter.WebserviceSkillHandler",
                        return_value=mocked_handler):
            test_http_response = SkillAdapter.as_view(skill=self.mock_skill)(
                self.mock_http_request)

            self.assertEqual(
                test_http_response.status_code, 400,
                "SkillAdapter didn't raise bad request when input "
                "verification failed")
예제 #7
0
    def test_request_dispatch(self):
        mocked_handler = mock.MagicMock(spec=WebserviceSkillHandler)
        expected_response = ResponseEnvelope().to_dict()
        mocked_handler.verify_request_and_dispatch.return_value = \
            expected_response
        expected_json_response = JsonResponse(data=expected_response)
        with mock.patch("django_ask_sdk.skill_adapter.WebserviceSkillHandler",
                        return_value=mocked_handler):
            actual_response = SkillAdapter.as_view(skill=self.mock_skill)(
                self.mock_http_request)

            self.assertEqual(
                actual_response.status_code, 200,
                "SkillAdapter didn't return valid status code "
                "during successful skill dispatch")
            self.assertEqual(
                actual_response.content, expected_json_response.content,
                "SkillAdapter didn't return correct response on "
                "successful skill dispatch")
예제 #8
0
"""car URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/2.0/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from django_ask_sdk.skill_adapter import SkillAdapter
from alexa.skill_handlers.skill_builder import skill_builder
from django.conf import settings

skill_view = SkillAdapter.as_view(skill=skill_builder.create(),
                                  verify_signature=settings.ALEXA_VERIFY,
                                  verify_timestamp=settings.ALEXA_VERIFY,
                                  verifiers=[])

urlpatterns = [
    path('admin/', admin.site.urls),
    path('alexa/', skill_view, name='alexa_skill'),
]
예제 #9
0
from django.urls import path
from django_ask_sdk.skill_adapter import SkillAdapter

from alexa.skill import skill

view = SkillAdapter.as_view(skill=skill, verify_signature=False)

urlpatterns = [path("", view, name="index")]
예제 #10
0
"""mysite URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/3.0/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import include, path
from skill.skill001 import myskill001

from django_ask_sdk.skill_adapter import SkillAdapter

my_skill_view = SkillAdapter.as_view(skill=myskill001)

urlpatterns = [
    path('skillentry/', my_skill_view, name='index'),
    path('polls/', include('polls.urls')),
    path('admin/', admin.site.urls),
]
from django.urls import path
from backend.alexa.api import skill
from django_ask_sdk.skill_adapter import SkillAdapter

my_skill_view = SkillAdapter.as_view(skill=skill.sb.create())

urlpatterns = [
    path('', my_skill_view, name='index'),
]
예제 #12
0
from .alexa_skills import skill
from django_ask_sdk.skill_adapter import SkillAdapter
from django.urls import path

my_skill_view = SkillAdapter.as_view(skill=skill)

urlpatterns = [
    path('', my_skill_view, name='alexa-skill'),
]
예제 #13
0
from django.contrib import admin
from django.urls import path
from intervals import views
from django_ask_sdk.skill_adapter import SkillAdapter

interval_training = SkillAdapter.as_view(skill=views.skill)
# ToDo Make a default index view. Dont want root url to hit alexa skill
# create homepage view
urlpatterns = [
    path('', views.home_page, name='home_page'),
    path('alexa', interval_training, name='alexa'),
    path('admin/', admin.site.urls),
    path('intervals/progress_details',
         views.progress_details,
         name='progress_details'),
    path('intervals/chartdata', views.ChartData.as_view(), name='chart_data'),
]
예제 #14
0
from django.contrib import admin
from django.urls import path, include
from core.views import PessoaViewSet
from rest_framework import routers
from django_ask_sdk.skill_adapter import SkillAdapter
import Deficientes_alexa

router = routers.DefaultRouter()
router.register(r'pessoas', PessoaViewSet)
view = SkillAdapter.as_view(skill=Deficientes_alexa.sb.create())
# router.register(r'helloworld', LaunchRequestHandler)

urlpatterns = [
    path('', include(router.urls)),
    path('admin/', admin.site.urls),
    path('api-auth/', include('rest_framework.urls')),
    path('lugar', view, name='index')
]
예제 #15
0
    https://docs.djangoproject.com/en/3.1/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
from MarApp.views import LugarViewSet
from rest_framework import routers
from django_ask_sdk.skill_adapter import SkillAdapter
import Mar

router = routers.DefaultRouter()
router.register(r'lugares', LugarViewSet)
view = SkillAdapter.as_view(skill=Mar.sb.create())

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include(router.urls)),
    path('api-auth/', include('rest_framework.urls')),
    path('lugar', view, name='index'),
    path('politica', include('MarApp.urls'))
]