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
b0c7809c
Commit
b0c7809c
authored
6 years ago
by
Carlos Vega
Browse files
Options
Downloads
Patches
Plain Diff
added tests for utils
parent
b846e242
No related branches found
No related tags found
1 merge request
!171
Feature/daily availability
Pipeline
#6812
failed
6 years ago
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
smash/web/tests/view/test_utils.py
+22
-0
22 additions, 0 deletions
smash/web/tests/view/test_utils.py
smash/web/utils.py
+3
-3
3 additions, 3 deletions
smash/web/utils.py
with
25 additions
and
3 deletions
smash/web/tests/view/test_utils.py
0 → 100644
+
22
−
0
View file @
b0c7809c
import
logging
from
django.test
import
TestCase
from
web.utils
import
get_weekdays_in_period
from
datetime
import
date
import
datetime
logger
=
logging
.
getLogger
(
__name__
)
class
Utils
(
TestCase
):
def
test_get_weekdays_in_period
(
self
):
fromdate
=
date
(
2018
,
10
,
9
)
todate
=
date
(
2018
,
10
,
12
)
weekdays
=
get_weekdays_in_period
(
fromdate
,
todate
)
self
.
assertEqual
(
weekdays
,
{
2
,
3
,
4
})
todate
=
datetime
.
datetime
(
2018
,
10
,
12
,
00
,
00
,
00
)
fromdate
=
datetime
.
datetime
(
2018
,
10
,
9
,
00
,
00
,
00
)
weekdays
=
get_weekdays_in_period
(
fromdate
,
todate
)
self
.
assertEqual
(
weekdays
,
{
2
,
3
,
4
})
\ No newline at end of file
This diff is collapsed.
Click to expand it.
smash/web/utils.py
+
3
−
3
View file @
b0c7809c
...
@@ -33,9 +33,9 @@ def get_weekdays_in_period(fromdate, todate):
...
@@ -33,9 +33,9 @@ def get_weekdays_in_period(fromdate, todate):
fromdate = datetime.datetime(2018, 10, 3, 15, 00, 00)
fromdate = datetime.datetime(2018, 10, 3, 15, 00, 00)
todate = datetime.datetime.today()
todate = datetime.datetime.today()
but
they
must have the same format !
but
both dates
must have the same format !
todate is not included in the range
Weekdays are returned as isoweekdays like the form described in week_choices from constants.py (starting at 1)
Weekdays are returned as isoweekdays like the form described in week_choices from constants.py (starting at 1)
'''
'''
if
todate
<
fromdate
:
if
todate
<
fromdate
:
...
...
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