Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
Grid ADASMELIAE
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
VIPS
Models
GRID
Grid ADASMELIAE
Commits
d583b958
Commit
d583b958
authored
1 year ago
by
Lene Wasskog
Browse files
Options
Downloads
Patches
Plain Diff
test: Add tests for finding end date
parent
e93998a9
No related branches found
No related tags found
No related merge requests found
Pipeline
#3744
passed
1 year ago
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test_ADASMELIAE.py
+26
-2
26 additions, 2 deletions
test_ADASMELIAE.py
with
26 additions
and
2 deletions
test_ADASMELIAE.py
+
26
−
2
View file @
d583b958
import
pytest
from
datetime
import
datetime
from
ADASMELIAE
import
find_start_date
from
datetime
import
datetime
,
timedelta
from
ADASMELIAE
import
find_start_date
,
find_end_date
@pytest.fixture
def
example_result_files
():
# Fixture for generating content of result dir
return
[
"
result_2023-04-15.nc
"
,
"
result_2023-04-16.nc
"
,
...
...
@@ -16,6 +17,12 @@ def example_result_files():
]
@pytest.fixture
def
today
():
# Fixture for generating date for testing
return
datetime
.
now
().
date
()
def
test_find_start_date_with_previous_results
(
example_result_files
,
monkeypatch
):
MODEL_START_DATE
=
datetime
(
2023
,
3
,
1
)
monkeypatch
.
setenv
(
"
DATA_DIR
"
,
"
out
"
)
...
...
@@ -41,3 +48,20 @@ def test_find_start_date_without_previous_results(monkeypatch):
# Assert the expected start date
assert
start_date
==
MODEL_START_DATE
def
test_find_end_date_when_model_end_date_is_in_past
(
today
):
# Test when model end date is in the past
model_end_date
=
datetime
.
now
().
date
()
-
timedelta
(
days
=
1
)
assert
find_end_date
(
model_end_date
=
model_end_date
)
==
model_end_date
def
test_find_end_date_when_model_end_date_is_in_future
(
today
):
# Test when model end date is in the future
model_end_date
=
datetime
.
now
().
date
()
+
timedelta
(
days
=
1
)
assert
find_end_date
(
model_end_date
=
model_end_date
)
==
today
def
test_find_end_date_equal
(
today
):
# Test when model end date is today
assert
find_end_date
(
model_end_date
=
today
)
==
today
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