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")
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")
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")
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")
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.")
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")
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")
"""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'), ]
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")]
"""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'), ]
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'), ]
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'), ]
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') ]
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')) ]