Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
library-app-django
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ilham Maulana
library-app-django
Commits
3d322bb0
Commit
3d322bb0
authored
Jul 08, 2024
by
impfundev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
deactivated django debug tool and try setup test
parent
b64fcdc9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
6 deletions
+24
-6
tests.py
api/tests.py
+16
-2
urls.py
api/urls.py
+1
-1
settings.py
config/settings.py
+1
-1
urls.py
config/urls.py
+6
-2
No files found.
api/tests.py
View file @
3d322bb0
from
django.test
import
TestCase
from
django.urls
import
include
,
path
,
reverse
from
rest_framework.test
import
APITestCase
,
URLPatternsTestCase
# Create your tests here.
class
AccountTests
(
APITestCase
,
URLPatternsTestCase
):
urlpatterns
=
[
path
(
"api/"
,
include
(
"api.urls"
)),
]
def
test_create_account
(
self
):
"""
Ensure can create a new account object.
"""
url
=
reverse
(
"users"
)
response
=
self
.
client
.
get
(
url
,
format
=
"json"
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
len
(
response
.
data
),
1
)
api/urls.py
View file @
3d322bb0
...
...
@@ -9,7 +9,7 @@ from api.views import (
)
router
=
routers
.
DefaultRouter
()
router
.
register
(
r"users"
,
UserViewSet
,
basename
=
"user"
)
router
.
register
(
r"users"
,
UserViewSet
,
basename
=
"user
s
"
)
router
.
register
(
r"books"
,
BookViewSet
,
basename
=
"books"
)
router
.
register
(
r"members"
,
MemberViewSet
,
basename
=
"members"
)
router
.
register
(
r"librarians"
,
LibrarianViewSet
,
basename
=
"librarians"
)
...
...
config/settings.py
View file @
3d322bb0
...
...
@@ -61,7 +61,7 @@ INSTALLED_APPS = [
"django.contrib.messages"
,
"django.contrib.staticfiles"
,
# 3rd party
"debug_toolbar"
,
#
"debug_toolbar",
"rest_framework"
,
"rest_framework.authtoken"
,
"django_filters"
,
...
...
config/urls.py
View file @
3d322bb0
...
...
@@ -25,10 +25,14 @@ urlpatterns = [
path
(
"dashboard/"
,
include
(
"dashboards.urls"
)),
path
(
"admin/"
,
admin
.
site
.
urls
),
path
(
"auth/"
,
include
(
"authentications.urls"
)),
path
(
"__debug__/"
,
include
(
"debug_toolbar.urls"
)),
#
path("__debug__/", include("debug_toolbar.urls")),
# API
path
(
"api/v1/"
,
include
(
"api.urls"
)),
path
(
"api/v1/auth/"
,
include
(
"dj_rest_auth.urls"
)),
path
(
"api/v1/auth/registration/"
,
include
(
"dj_rest_auth.registration.urls"
)),
path
(
"api/v1/auth/registration/"
,
include
(
"dj_rest_auth.registration.urls"
),
name
=
"register"
,
),
path
(
"api-auth/"
,
include
(
"rest_framework.urls"
)),
]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment