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
6bb63bdb
Commit
6bb63bdb
authored
3 years ago
by
Nadja Geisler
Browse files
Options
Downloads
Plain Diff
Merge branch 'tests' into 'main'
Test cases See merge request
!95
parents
8274a93e
8b83f47b
No related branches found
No related tags found
1 merge request
!95
Test cases
Pipeline
#22539
passed
3 years ago
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitlab-ci.yml
+1
-1
1 addition, 1 deletion
.gitlab-ci.yml
AKDashboard/tests.py
+128
-1
128 additions, 1 deletion
AKDashboard/tests.py
AKPlanning/settings_ci.py
+4
-1
4 additions, 1 deletion
AKPlanning/settings_ci.py
with
133 additions
and
3 deletions
.gitlab-ci.yml
+
1
−
1
View file @
6bb63bdb
...
...
@@ -24,4 +24,4 @@ before_script:
test
:
script
:
-
source venv/bin/activate
-
python manage.py test --settings AKPlanning.settings_ci
-
python manage.py test --settings AKPlanning.settings_ci
--keepdb
This diff is collapsed.
Click to expand it.
AKDashboard/tests.py
+
128
−
1
View file @
6bb63bdb
# Create your tests here.
import
pytz
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
class
DashboardTests
(
TestCase
):
@classmethod
def
setUpTestData
(
cls
):
super
().
setUpTestData
()
cls
.
event
=
Event
.
objects
.
create
(
name
=
"
Dashboard Test Event
"
,
slug
=
"
dashboardtest
"
,
timezone
=
pytz
.
utc
,
start
=
now
(),
end
=
now
(),
active
=
True
,
plan_hidden
=
False
,
)
cls
.
default_category
=
AKCategory
.
objects
.
create
(
name
=
"
Test Category
"
,
event
=
cls
.
event
,
)
def
test_dashboard_view
(
self
):
url
=
reverse
(
'
dashboard:dashboard_event
'
,
kwargs
=
{
"
slug
"
:
self
.
event
.
slug
})
response
=
self
.
client
.
get
(
url
)
self
.
assertEqual
(
response
.
status_code
,
200
)
def
test_nonexistent_dashboard_view
(
self
):
url
=
reverse
(
'
dashboard:dashboard_event
'
,
kwargs
=
{
"
slug
"
:
"
nonexistent-event
"
})
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
})
# History should be empty
response
=
self
.
client
.
get
(
url
)
self
.
assertQuerysetEqual
(
response
.
context
[
"
recent_changes
"
],
[])
AK
.
objects
.
create
(
name
=
"
Test AK
"
,
category
=
self
.
default_category
,
event
=
self
.
event
,
)
# History should now contain one AK (Test AK)
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.
AKPlanning/settings_ci.py
+
4
−
1
View file @
6bb63bdb
...
...
@@ -16,6 +16,9 @@ DATABASES = {
'
PASSWORD
'
:
'
mysql
'
,
'
OPTIONS
'
:
{
'
init_command
'
:
"
SET sql_mode=
'
STRICT_TRANS_TABLES
'"
}
},
'
TEST
'
:
{
'
NAME
'
:
'
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