Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
LOFAR
Manage
Activity
Members
Labels
Plan
Issues
Wiki
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review 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
RadioObservatory
LOFAR
Commits
eebc2d9b
Commit
eebc2d9b
authored
4 years ago
by
Jörn Künsemöller
Browse files
Options
Downloads
Patches
Plain Diff
TMSS-435
: add tests for sunrise etc.
parent
8282fea9
No related branches found
No related tags found
1 merge request
!269
Resolve TMSS-435
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
SAS/TMSS/test/t_conversions.py
+38
-0
38 additions, 0 deletions
SAS/TMSS/test/t_conversions.py
with
38 additions
and
0 deletions
SAS/TMSS/test/t_conversions.py
+
38
−
0
View file @
eebc2d9b
...
...
@@ -26,6 +26,7 @@ import logging
import
requests
import
dateutil.parser
import
astropy.coordinates
import
json
logger
=
logging
.
getLogger
(
__name__
)
logging
.
basicConfig
(
format
=
'
%(asctime)s %(levelname)s %(message)s
'
,
level
=
logging
.
INFO
)
...
...
@@ -127,6 +128,43 @@ class UtilREST(unittest.TestCase):
lon_str2
=
r2
.
content
.
decode
(
'
utf8
'
)
self
.
assertNotEqual
(
lon_str1
,
lon_str2
)
def
test_util_sun_rise_and_set_returns_json_structure_with_defaults
(
self
):
r
=
requests
.
get
(
BASE_URL
+
'
/util/sun_rise_and_set
'
,
auth
=
AUTH
)
self
.
assertEqual
(
r
.
status_code
,
200
)
r_dict
=
json
.
loads
(
r
.
content
.
decode
(
'
utf-8
'
))
# assert defaults to core and today
self
.
assertIn
(
'
CS002
'
,
r_dict
.
keys
())
sunrise_start
=
dateutil
.
parser
.
parse
(
r_dict
[
'
CS002
'
][
'
sunrise
'
][
0
][
'
start
'
])
self
.
assertEqual
(
datetime
.
date
.
today
(),
sunrise_start
.
date
())
def
test_util_sun_rise_and_set_considers_stations
(
self
):
stations
=
[
'
CS005
'
,
'
RS305
'
,
'
DE609
'
]
r
=
requests
.
get
(
BASE_URL
+
'
/util/sun_rise_and_set?stations=%s
'
%
'
,
'
.
join
(
stations
),
auth
=
AUTH
)
self
.
assertEqual
(
r
.
status_code
,
200
)
r_dict
=
json
.
loads
(
r
.
content
.
decode
(
'
utf-8
'
))
# assert station is included in response and timestamps differ
sunset_start_last
=
None
for
station
in
stations
:
self
.
assertIn
(
station
,
r_dict
.
keys
())
sunset_start
=
dateutil
.
parser
.
parse
(
r_dict
[
station
][
'
sunset
'
][
0
][
'
start
'
])
if
sunset_start_last
:
self
.
assertNotEqual
(
sunset_start
,
sunset_start_last
)
sunset_start_last
=
sunset_start
def
test_util_sun_rise_and_set_considers_timestamps
(
self
):
timestamps
=
[
'
2020-01-01
'
,
'
2020-02-22T16-00-00
'
,
'
2020-3-11
'
,
'
2020-01-01
'
]
r
=
requests
.
get
(
BASE_URL
+
'
/util/sun_rise_and_set?timestamps=%s
'
%
'
,
'
.
join
(
timestamps
),
auth
=
AUTH
)
self
.
assertEqual
(
r
.
status_code
,
200
)
r_dict
=
json
.
loads
(
r
.
content
.
decode
(
'
utf-8
'
))
# assert all requested timestamps are included in response (sunrise on same day)
for
i
in
range
(
len
(
timestamps
)):
expected_date
=
dateutil
.
parser
.
parse
(
timestamps
[
i
]).
date
()
response_date
=
dateutil
.
parser
.
parse
(
r_dict
[
'
CS002
'
][
'
sunrise
'
][
i
][
'
start
'
]).
date
()
self
.
assertEqual
(
expected_date
,
response_date
)
if
__name__
==
"
__main__
"
:
os
.
environ
[
'
TZ
'
]
=
'
UTC
'
...
...
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