-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
470171a
commit b99235d
Showing
2 changed files
with
13 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,32 @@ | ||
# standard library | ||
from dataclasses import asdict | ||
from tempfile import NamedTemporaryFile | ||
|
||
|
||
# dependencies | ||
from azely.location import Location, get_location | ||
from pytest import mark | ||
from tomlkit import dump | ||
|
||
|
||
# test data | ||
locations = [ | ||
Location( | ||
name="Atacama Large Millimeter/submillimeter Array", | ||
longitude="292d14m48.93972s", | ||
longitude="-67d45m11.06028s", | ||
latitude="-23d01m21.97704s", | ||
altitude="0.0 m", | ||
altitude="0m", | ||
), | ||
Location( | ||
name="Gran Telescopio Milimétrico Alfonso Serrano", | ||
longitude="262d41m06.76068s", | ||
longitude="-97d18m53.23932s", | ||
latitude="18d59m08.66328s", | ||
altitude="0.0 m", | ||
altitude="0m", | ||
), | ||
Location( | ||
name="Nobeyama Radio Astronomy Observatory", | ||
longitude="138d28m25.28621699s", | ||
latitude="35d56m34.76364s", | ||
altitude="0.0 m", | ||
altitude="0m", | ||
), | ||
] | ||
|
||
|
||
# test functions | ||
@mark.parametrize("obj", locations) | ||
def test_get_location(obj: Location) -> None: | ||
with NamedTemporaryFile("w", suffix=".toml") as f: | ||
dump({obj.name: asdict(obj)}, f) | ||
|
||
# save an object to the TOML file | ||
assert get_location(obj.name, source=f.name) == obj | ||
# read the object from the TOML file | ||
assert get_location(obj.name, source=f.name) == obj | ||
assert get_location(obj.name, source=None) == obj |