def test_CreateUserView_valid(default_user_data): view = CreateUserView.as_view() factory = APIRequestFactory() request = factory.post('/api/user/register', data=default_user_data) response = view(request) assert response.status_code == status.HTTP_201_CREATED
def test_CreateUserView_invalid_data(default_user_data): view = CreateUserView.as_view() factory = APIRequestFactory() data = { "full_name": default_user_data['full_name'], "password": default_user_data['password'] } request = factory.post('/api/user/register', data=data) response = view(request) assert response.status_code == status.HTTP_400_BAD_REQUEST
def test_CreateUserView_user_is_already_registered(django_user_model, default_user_data): view = CreateUserView.as_view() factory = APIRequestFactory() django_user_model.objects.create(email="*****@*****.**", password='******', full_name="test_user") request = factory.post('/api/user/register', data=default_user_data) response = view(request) assert response.status_code == status.HTTP_400_BAD_REQUEST assert response.data['message'] == 'Email is already registered'
from django.urls import path, include from rest_framework import routers from user.views import UserSessionView, UserProfileViewset, UserAccountListView, UserAccountDetailView, CreateUserView, MyTokenObtainPairView # from rest_framework_simplejwt.views import TokenObtainPairView, TokenRefreshView urlpatterns = [ # These paths are all admin paths only path('accounts/', UserAccountListView.as_view(), name='account-list'), path('accounts/<int:pk>', UserAccountDetailView.as_view(), name='account-detail'), # This path is used to check user session path('user/', UserSessionView.as_view(), name='user-session'), # These paths are public # path('profiles/', UserProfileView.as_view(), name='profile-list'), # path('profiles/<int:pk>/', UserProfileDetailView.as_view(), name='profile-detail'), path('register/', CreateUserView.as_view(), name='register'), path('token/', MyTokenObtainPairView.as_view(), name='token_obtain_pair'), # path('login/', api_login, name='login'), # path('token/refresh/', TokenRefreshView.as_view(), name='token_refresh'), ]
from django.urls import path from user.views import CreateUserView, CreateTokenView, ManageUserView app_name = 'user' urlpatterns = [ path('create/', CreateUserView.as_view(), name='create'), path('token/', CreateTokenView.as_view(), name='token'), path('me/', ManageUserView.as_view(), name='me'), ]
from django.urls import path, include from user.views import CreateUserView, login, UserDetailView urlpatterns = [ path( 'register/', CreateUserView.as_view(), ), path( 'login/', login ), path( '<int:pk>/', UserDetailView.as_view(), ) ]
from rest_framework_simplejwt.views import TokenRefreshView from django.conf.urls import url from user.views import UserActivityView, CreateUserView, TokenAuthenticationView urlpatterns = [ url('activity/', UserActivityView.as_view({'get': 'list'}), name='user-activity'), url('sing-up/', CreateUserView.as_view(), name='user-sing-up'), url('login/', TokenAuthenticationView.as_view(), name='token_obtain_pair'), url('token/refresh/', TokenRefreshView.as_view(), name='token_refresh'), ]
from rest_framework_simplejwt.views import ( TokenObtainPairView, TokenRefreshView, ) from user.views import get_current_user, CreateUserView from .views import index from trail.views import TrailViewSet from review.views import ReviewViewSet from django.conf.urls.static import static from django.conf import settings router = routers.DefaultRouter() router.register(r'trails', TrailViewSet) router.register(r'reviews', ReviewViewSet) urlpatterns = [ path('', index, name='index'), path('admin/doc/', include('django.contrib.admindocs.urls')), path('admin/', admin.site.urls), path('api/', include(router.urls)), path('api/token/', TokenObtainPairView.as_view(), name='token_obtain_pair'), path('api/token/refresh/', TokenRefreshView.as_view(), name='token_refresh'), path('current_user/', get_current_user), path('user/create/', CreateUserView.as_view()), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) \ + [re_path(r'^(?:.*)/?$', index, name='index')]
from django.urls import path from user.views import CreateUserView, CreateTokenView, \ UserLogin app_name = 'user' urlpatterns = [ path('signup/', CreateUserView.as_view(), name='create'), path('token/', CreateTokenView.as_view(), name='token'), path('login/', UserLogin.as_view(), name='login'), ]
path("sms_token_verify/<int:id>/", MobileOTP.as_view(), name="sms-token-verification"), path( "sms_otp_verify/<int:id>/", UpdateMobileOTP.as_view(), name="sms-otp-verification", ), path("get-user/<uuid:id>/", RetrieveUserView.as_view(), name="get-user"), path("delete-user/<uuid:id>/", DeleteUserView.as_view(), name="delete-user"), path("update-user/<uuid:id>/", UpdateUserView.as_view(), name="update-user"), path("create-user/", CreateUserView.as_view(), name="create-user"), path("create_neeri_user/", CreateNeeriUserView.as_view(), name="create-neeri-user"), path( "search_neeri_user/", NeeriUserSearchListView.as_view(), name="search-neeri-user", ), path("neeri_user/", NeeriUserListView.as_view(), name="neeri-user"), path("neeri_user/<uuid:id>/", CreateNeeriUserView.as_view(), name="neeri-user-api"), path("user-list/", UserListView.as_view(), name="user-list"), path("forgot_password/", ForgotPassword.as_view(), name="forgot-password"), path("reset_password/<uuid:token>/",
from django.urls import path from user.views import CreateUserView, CreateTokenView, ManageUserView app_name = "user" urlpatterns = [ path("create/", CreateUserView.as_view(), name="create"), path("token/", CreateTokenView.as_view(), name="token"), path("me/", ManageUserView.as_view(), name="me") ]