Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Django Kubernetes Probes
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hub
Django Kubernetes Probes
Commits
bb165f67
Commit
bb165f67
authored
1 year ago
by
Bryan BRANCOTTE
Browse files
Options
Downloads
Patches
Plain Diff
more tests
parent
9a5d06a6
No related branches found
No related tags found
1 merge request
!1
More tests
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/settings.py
+2
-0
2 additions, 0 deletions
tests/settings.py
tests/tests.py
+29
-6
29 additions, 6 deletions
tests/tests.py
with
31 additions
and
6 deletions
tests/settings.py
+
2
−
0
View file @
bb165f67
...
...
@@ -6,6 +6,7 @@ INSTALLED_APPS = [
'
django.contrib.auth
'
,
'
django.contrib.contenttypes
'
,
'
django_kubernetes_probes
'
,
'
tests
'
,
]
BASE_DIR
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)))
...
...
@@ -18,3 +19,4 @@ DATABASES = {
}
ROOT_URLCONF
=
'
tests.urls
'
DEFAULT_AUTO_FIELD
=
'
django.db.models.BigAutoField
'
This diff is collapsed.
Click to expand it.
tests/tests.py
+
29
−
6
View file @
bb165f67
...
...
@@ -2,17 +2,40 @@ import logging
from
django.test
import
TestCase
from
django.urls
import
reverse
from
django.db
import
connection
from
django.contrib.auth
import
get_user_model
from
tests
import
models
logger
=
logging
.
getLogger
(
__name__
)
class
ProbeTestCase
(
TestCase
):
def
drap_table
(
self
,
model
):
with
connection
.
cursor
()
as
cursor
:
cursor
.
execute
(
f
"
DROP TABLE
{
model
.
_meta
.
db_table
}
"
)
def
test_probe_ready
(
self
):
self
.
assertEqual
(
200
,
self
.
client
.
get
(
reverse
(
"
probes:probe_ready
"
)).
status_code
)
self
.
assertEqual
(
200
,
self
.
client
.
get
(
reverse
(
"
probes:probe_ready
"
)).
status_code
)
def
test_probe_ready_without_user
(
self
):
self
.
drap_table
(
get_user_model
())
self
.
assertEqual
(
500
,
self
.
client
.
get
(
reverse
(
"
probes:probe_ready
"
)).
status_code
)
def
test_probe_ready_without_amodel
(
self
):
self
.
drap_table
(
models
.
AModel
)
self
.
assertEqual
(
500
,
self
.
client
.
get
(
reverse
(
"
probes:probe_ready
"
)).
status_code
)
def
test_probe_alive
(
self
):
self
.
assertEqual
(
200
,
self
.
client
.
get
(
reverse
(
"
probes:probe_alive
"
)).
status_code
)
self
.
assertEqual
(
200
,
self
.
client
.
get
(
reverse
(
"
probes:probe_alive
"
)).
status_code
)
def
test_probe_alive_without_user
(
self
):
self
.
drap_table
(
get_user_model
())
self
.
assertEqual
(
500
,
self
.
client
.
get
(
reverse
(
"
probes:probe_alive
"
)).
status_code
)
def
test_probe_alive_without_amodel
(
self
):
"""
for alive-ness we only look at user, other missing table in the db does not cause an error
"""
self
.
drap_table
(
models
.
AModel
)
self
.
assertEqual
(
200
,
self
.
client
.
get
(
reverse
(
"
probes:probe_alive
"
)).
status_code
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment