Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scheduling-system
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
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
SMASCH
scheduling-system
Commits
ee916a27
Commit
ee916a27
authored
7 years ago
by
Piotr Gawron
Browse files
Options
Downloads
Patches
Plain Diff
unit tests for checking if worker is on leave and getting worker for anynomous user
parent
a34886de
No related branches found
No related tags found
1 merge request
!100
Test coverage unit tests
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
smash/web/tests/models/test_worker.py
+18
-4
18 additions, 4 deletions
smash/web/tests/models/test_worker.py
with
18 additions
and
4 deletions
smash/web/tests/models/test_worker.py
+
18
−
4
View file @
ee916a27
from
django.contrib.auth.models
import
User
import
datetime
from
django.test
import
Client
from
django.test
import
TestCase
from
web.models
import
Worker
from
django.contrib.auth.models
import
User
,
AnonymousUser
from
django.test
import
Client
,
TestCase
from
web.models
import
Holiday
,
Worker
from
web.tests.functions
import
create_worker
from
web.tests.functions
import
create_worker
from
web.views.notifications
import
get_today_midnight_date
class
WorkerModelTests
(
TestCase
):
class
WorkerModelTests
(
TestCase
):
...
@@ -46,3 +48,15 @@ class WorkerModelTests(TestCase):
...
@@ -46,3 +48,15 @@ class WorkerModelTests(TestCase):
self
.
fail
(
"
Exception expected
"
)
self
.
fail
(
"
Exception expected
"
)
except
TypeError
:
except
TypeError
:
pass
pass
def
test_is_on_leave
(
self
):
worker
=
create_worker
()
self
.
assertFalse
(
worker
.
is_on_leave
())
Holiday
(
person
=
worker
,
datetime_start
=
get_today_midnight_date
()
+
datetime
.
timedelta
(
days
=-
2
),
datetime_end
=
get_today_midnight_date
()
+
datetime
.
timedelta
(
days
=
2
)).
save
()
self
.
assertTrue
(
worker
.
is_on_leave
())
def
test_get_by_user_for_anonymous
(
self
):
self
.
assertIsNone
(
Worker
.
get_by_user
(
AnonymousUser
()))
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