Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AKPlanning
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
KIF
AKPlanning
Commits
8b83f47b
Commit
8b83f47b
authored
3 years ago
by
Benjamin Hättasch
Committed by
Nadja Geisler
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add further dashboard tests (and improve existing ones)
parent
0041dbc7
No related branches found
No related tags found
1 merge request
!95
Test cases
Pipeline
#22538
passed
3 years ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
AKDashboard/tests.py
+79
-3
79 additions, 3 deletions
AKDashboard/tests.py
with
79 additions
and
3 deletions
AKDashboard/tests.py
+
79
−
3
View file @
8b83f47b
import
pytz
from
django.test
import
TestCase
from
django.apps
import
apps
from
django.test
import
TestCase
,
override_settings
from
django.urls
import
reverse
from
django.utils.timezone
import
now
from
AKDashboard.models
import
DashboardButton
from
AKModel.models
import
Event
,
AK
,
AKCategory
...
...
@@ -11,12 +13,13 @@ class DashboardTests(TestCase):
def
setUpTestData
(
cls
):
super
().
setUpTestData
()
cls
.
event
=
Event
.
objects
.
create
(
name
=
"
Test Event
"
,
slug
=
"
test
"
,
name
=
"
Dashboard
Test Event
"
,
slug
=
"
dashboard
test
"
,
timezone
=
pytz
.
utc
,
start
=
now
(),
end
=
now
(),
active
=
True
,
plan_hidden
=
False
,
)
cls
.
default_category
=
AKCategory
.
objects
.
create
(
name
=
"
Test Category
"
,
...
...
@@ -33,6 +36,7 @@ class DashboardTests(TestCase):
response
=
self
.
client
.
get
(
url
)
self
.
assertEqual
(
response
.
status_code
,
404
)
@override_settings
(
DASHBOARD_SHOW_RECENT
=
True
)
def
test_history
(
self
):
url
=
reverse
(
'
dashboard:dashboard_event
'
,
kwargs
=
{
"
slug
"
:
self
.
event
.
slug
})
...
...
@@ -50,3 +54,75 @@ class DashboardTests(TestCase):
response
=
self
.
client
.
get
(
url
)
self
.
assertEqual
(
len
(
response
.
context
[
"
recent_changes
"
]),
1
)
self
.
assertEqual
(
response
.
context
[
"
recent_changes
"
][
0
][
'
text
'
],
"
New AK: Test AK.
"
)
def
test_public
(
self
):
url_dashboard_index
=
reverse
(
'
dashboard:dashboard
'
)
url_event_dashboard
=
reverse
(
'
dashboard:dashboard_event
'
,
kwargs
=
{
"
slug
"
:
self
.
event
.
slug
})
# Non-Public event (should not be part of the global dashboard
# but should have an individual dashboard page for those knowing the url)
self
.
event
.
public
=
False
self
.
event
.
save
()
response
=
self
.
client
.
get
(
url_dashboard_index
)
print
(
response
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertFalse
(
self
.
event
in
response
.
context
[
"
events
"
])
response
=
self
.
client
.
get
(
url_event_dashboard
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
response
.
context
[
"
event
"
],
self
.
event
)
# Public event -- should be part of the global dashboard
self
.
event
.
public
=
True
self
.
event
.
save
()
response
=
self
.
client
.
get
(
url_dashboard_index
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertTrue
(
self
.
event
in
response
.
context
[
"
events
"
])
def
test_active
(
self
):
url_event_dashboard
=
reverse
(
'
dashboard:dashboard_event
'
,
kwargs
=
{
"
slug
"
:
self
.
event
.
slug
})
if
apps
.
is_installed
(
'
AKSubmission
'
):
# Non-active event -> No submission
self
.
event
.
active
=
False
self
.
event
.
save
()
response
=
self
.
client
.
get
(
url_event_dashboard
)
self
.
assertNotContains
(
response
,
"
AK Submission
"
)
# Active event -> Submission should be open
self
.
event
.
active
=
True
self
.
event
.
save
()
response
=
self
.
client
.
get
(
url_event_dashboard
)
self
.
assertContains
(
response
,
"
AK Submission
"
)
def
test_plan_hidden
(
self
):
url_event_dashboard
=
reverse
(
'
dashboard:dashboard_event
'
,
kwargs
=
{
"
slug
"
:
self
.
event
.
slug
})
if
apps
.
is_installed
(
'
AKPlan
'
):
# Plan hidden? No buttons should show up
self
.
event
.
plan_hidden
=
True
self
.
event
.
save
()
response
=
self
.
client
.
get
(
url_event_dashboard
)
self
.
assertNotContains
(
response
,
"
Current AKs
"
)
self
.
assertNotContains
(
response
,
"
AK Wall
"
)
# Plan not hidden?
# Buttons for current AKs and AK Wall should be on the page
self
.
event
.
plan_hidden
=
False
self
.
event
.
save
()
response
=
self
.
client
.
get
(
url_event_dashboard
)
self
.
assertContains
(
response
,
"
Current AKs
"
)
self
.
assertContains
(
response
,
"
AK Wall
"
)
def
test_dashboard_buttons
(
self
):
url_event_dashboard
=
reverse
(
'
dashboard:dashboard_event
'
,
kwargs
=
{
"
slug
"
:
self
.
event
.
slug
})
response
=
self
.
client
.
get
(
url_event_dashboard
)
self
.
assertNotContains
(
response
,
"
Dashboard Button Test
"
)
DashboardButton
.
objects
.
create
(
text
=
"
Dashboard Button Test
"
,
event
=
self
.
event
)
response
=
self
.
client
.
get
(
url_event_dashboard
)
self
.
assertContains
(
response
,
"
Dashboard Button Test
"
)
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