def test_when_we_request_orders_by_user_id_then_list_of_orders_returned( self, mock_get): mock_get.return_value = ['Mocked', 'List'] view = OrdersView() request = MockRequest() user = {} user['user_id'] = AUTH_USER_ID request.GET = user returned_value = view.get(request, AUTH_USER_ID) self.assertEqual( returned_value.data, mock_get.return_value, 'Error, returned value was {returned} and should be {value}'. format(returned=returned_value.data, value=mock_get.return_value))
def test_when_get_order_price_url_is_requested_then_get_order_price_use_case_is_called( self, mock_run): mock_run.return_value = ['Mocked', 'List'] ordersview = OrdersView() request = MockRequest() order = {} element = {} order['id'] = 1 element['id'] = 1 element['amount'] = 2 element['product'] = 'mocked_product' order['elements'] = [ element, ] request.data = {} request.data['order'] = json.dumps(order) request.POST = order ordersview.post(request, AUTH_USER_ID) mock_run.assert_called_once()
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) """ from django.conf.urls import url, include from django.contrib import admin from django.views.generic import TemplateView import xadmin from users.views import LoginView, RegisterView, ActiveUserView, LogoutView, RefereeView, ForgetPwdView, ResetView, ModifyPwdView, IndexView from goods.views import GoodsView, SuccessView from orders.views import OrdersView urlpatterns = [ url(r'^$', IndexView.as_view(), name='index'), url(r'^admin/', xadmin.site.urls), url(r'^login/', LoginView.as_view(), name='login'), url(r'^logout/', LogoutView.as_view(), name='logout'), url(r'^captcha/', include('captcha.urls')), url(r'^register/', RegisterView.as_view(), name='register'), url(r'^active/(?P<active_code>.*)/$', ActiveUserView.as_view(), name='user_active'), url(r'^goods/', GoodsView.as_view(), name='goods'), url(r'^success/', SuccessView.as_view(), name='success'), url(r'^home/', OrdersView.as_view(), name='home'), url(r'^referee/', RefereeView.as_view(), name='referee'), url(r'^forget/', ForgetPwdView.as_view(), name='forget'), url(r'^reset/(?P<active_code>.*)/$', ResetView.as_view(), name='reset_pwd'), url(r'^reset/$', ModifyPwdView.as_view(), name='reset'), ]
from django.conf.urls import url, include from rest_framework import routers from inventory.views import InventoryView from orders.views import OrdersView router = routers.DefaultRouter() # router.register(r'myproject', views.TransactionsViewSet) # Wire up our API using automatic URL routing. # Additionally, we include login URLs for the browsable API. urlpatterns = [ url(r'^', include(router.urls)), url(r'^order/$', OrdersView.as_view(), name='order'), url(r'^staffmember/(?P<user_id>\d+)/orders/$', OrdersView.as_view(), name='orders'), url(r'^inventory/(?P<user_id>\d+)/$', InventoryView.as_view(), name='inventory'), url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')) ]
from django.conf.urls.defaults import * from orders.views import OrdersView, OrderDetailView from django.contrib.auth.decorators import login_required urlpatterns = patterns( '', url( r'(\d+)', login_required( OrderDetailView.as_view() ) ), url( r'(\w)', login_required( OrdersView.as_view() ) ), )
from django.urls import path from orders.views import OrdersView, OrderList, OrderDetail urlpatterns = [ path('', OrdersView.as_view(), name='orders-index'), path('api/orders/', OrderList.as_view(), name='order-list'), path('api/orders/<int:pk>/', OrderDetail.as_view(), name='order-detail'), ]
"""first_project URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/2.2/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 orders.views import OrdersView from shop.views import CategoryView, ShopView, ProductView urlpatterns = [ path('admin/', admin.site.urls), path('categories', CategoryView.as_view(), name='categories'), path('shops', ShopView.as_view(), name='shops'), path('products', ProductView.as_view(), name='products'), path('orders', OrdersView.as_view(), name='orders'), ]