Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
D
DocuSign_test_project
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
Volkov Gherman
DocuSign_test_project
Commits
485af427
Commit
485af427
authored
May 31, 2023
by
Volkov Gherman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests on api app, with pytest lib
parent
6b0324d0
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
3 deletions
+59
-3
tests.py
api/tests.py
+51
-2
settings.py
core/settings.py
+1
-1
entrypoint.sh
entrypoint.sh
+1
-0
pytest.ini
pytest.ini
+3
-0
base.txt
requirements/base.txt
+3
-0
No files found.
api/tests.py
View file @
485af427
from
django.
test
import
TestCa
se
from
django.
urls
import
rever
se
# Create your tests here.
import
pytest
from
rest_framework.test
import
APIClient
from
rest_framework
import
status
@
pytest
.
fixture
def
client
():
return
APIClient
()
@
pytest
.
fixture
def
valid_data
():
return
{
'signer_name'
:
'Гвидыч'
,
'signer_surname'
:
'Ванросыч'
,
'signer_email'
:
'robogop2510@gmail.com'
}
@
pytest
.
fixture
def
invalid_data
():
return
{
'signer_name'
:
'Чебурашка'
,
'signer_surname'
:
'Генадьева'
}
@
pytest
.
fixture
def
expected_data
():
return
{
'id'
:
1
,
'signer_name'
:
'Гвидыч'
,
'signer_surname'
:
'Ванросыч'
,
'signer_email'
:
'robogop2510@gmail.com'
,
'status'
:
'Документ отправлен на подпись, проверьте Вашу почту'
}
def
test_index_view_redirects_to_send_email
(
client
):
response
=
client
.
get
(
reverse
(
'index'
))
assert
response
.
status_code
==
status
.
HTTP_302_FOUND
assert
response
.
url
==
reverse
(
'send_email'
)
def
test_get_send_document_view
(
client
):
response
=
client
.
get
(
reverse
(
'send_email'
))
assert
response
.
status_code
==
status
.
HTTP_200_OK
assert
'index.html'
in
response
.
template_name
@
pytest
.
mark
.
django_db
def
test_post_valid_data
(
client
,
valid_data
,
expected_data
):
response
=
client
.
post
(
reverse
(
'send_email'
),
valid_data
)
assert
response
.
status_code
==
status
.
HTTP_200_OK
assert
response
.
data
==
expected_data
@
pytest
.
mark
.
django_db
def
test_post_invalid_data
(
client
,
invalid_data
):
response
=
client
.
post
(
reverse
(
'send_email'
),
invalid_data
)
assert
response
.
status_code
==
status
.
HTTP_400_BAD_REQUEST
assert
response
.
data
==
{
'error'
:
'Bad Request'
,
'description'
:
'Введенные Вами данные не валидны'
}
core/settings.py
View file @
485af427
...
@@ -13,6 +13,7 @@ https://docs.djangoproject.com/en/4.2/ref/settings/
...
@@ -13,6 +13,7 @@ https://docs.djangoproject.com/en/4.2/ref/settings/
import
os
import
os
from
pathlib
import
Path
from
pathlib
import
Path
import
pytest
from
dotenv
import
load_dotenv
from
dotenv
import
load_dotenv
...
@@ -118,7 +119,6 @@ AUTH_PASSWORD_VALIDATORS = [
...
@@ -118,7 +119,6 @@ AUTH_PASSWORD_VALIDATORS = [
},
},
]
]
CORS_ALLOWED_ORIGINS
=
[
CORS_ALLOWED_ORIGINS
=
[
'http://localhost:8000'
,
'http://localhost:8000'
,
'http://0.0.0.0:8000'
,
'http://0.0.0.0:8000'
,
...
...
entrypoint.sh
View file @
485af427
...
@@ -11,6 +11,7 @@ then
...
@@ -11,6 +11,7 @@ then
echo
"PostgreSQL started"
echo
"PostgreSQL started"
fi
fi
pytest
.
python manage.py migrate
--noinput
python manage.py migrate
--noinput
python manage.py collectstatic
--no-input
--clear
python manage.py collectstatic
--no-input
--clear
...
...
pytest.ini
0 → 100644
View file @
485af427
[pytest]
DJANGO_SETTINGS_MODULE
=
core.settings
python_files
=
tests.py test_*.py *_tests.py
requirements/base.txt
View file @
485af427
...
@@ -5,3 +5,6 @@ python-dotenv==1.0.*
...
@@ -5,3 +5,6 @@ python-dotenv==1.0.*
docusign-esign==3.22.*
docusign-esign==3.22.*
django-cors-headers==4.0.*
django-cors-headers==4.0.*
gunicorn==20.1.*
gunicorn==20.1.*
pytest==7.3.*
pytest-django==4.5.*
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