-
Notifications
You must be signed in to change notification settings - Fork 0
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
a70da08
commit 2e2f0a9
Showing
5 changed files
with
136 additions
and
12 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
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import pytest | ||
from astroplan import Observer | ||
import astropy.units as u | ||
|
||
|
||
@pytest.fixture(scope='module') | ||
def observer(): | ||
return Observer(latitude=51.559299 * u.deg, longitude=9.945472 * u.deg, elevation=201 * u.m) |
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 |
---|---|---|
@@ -0,0 +1,120 @@ | ||
from unittest.mock import Mock | ||
|
||
import pytest | ||
from astroplan import Observer | ||
|
||
from pyobs_cloudcover.web_api.coverage_query_executor import CoverageQueryExecutor | ||
from pyobs_cloudcover.web_api.server import Server | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_point_query_radec(aiohttp_client, observer: Observer) -> None: | ||
executor = CoverageQueryExecutor(observer=observer) | ||
executor.point_query_radec = Mock(return_value=False) # type: ignore | ||
executor.get_obs_time = Mock(return_value=0) | ||
|
||
server = Server(executor) | ||
|
||
client = await aiohttp_client(server._app) | ||
response = await client.get('/query/point?ra=0.0&dec=0.0') | ||
|
||
assert response.status == 200 | ||
data = await response.json() | ||
|
||
assert data["value"] is False | ||
assert data["obs_time"] == 0 | ||
|
||
@pytest.mark.asyncio | ||
async def test_point_query_altaz(aiohttp_client, observer: Observer) -> None: | ||
executor = CoverageQueryExecutor(observer=observer) | ||
executor.point_query_altaz = Mock(return_value=False) # type: ignore | ||
executor.get_obs_time = Mock(return_value=0) | ||
|
||
server = Server(executor) | ||
|
||
client = await aiohttp_client(server._app) | ||
response = await client.get('/query/point?alt=0.0&az=0.0') | ||
|
||
assert response.status == 200 | ||
data = await response.json() | ||
|
||
assert data["value"] is False | ||
assert data["obs_time"] == 0 | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_point_query_invalid(aiohttp_client, observer: Observer) -> None: | ||
executor = CoverageQueryExecutor(observer=observer) | ||
executor.point_query_altaz = Mock(return_value=False) # type: ignore | ||
executor.get_obs_time = Mock(return_value=0) | ||
|
||
server = Server(executor) | ||
|
||
client = await aiohttp_client(server._app) | ||
response = await client.get('/query/point?a=0.0&z=0.0') | ||
|
||
assert response.status == 400 | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_area_query_radec(aiohttp_client, observer: Observer) -> None: | ||
executor = CoverageQueryExecutor(observer=observer) | ||
executor.area_query_radec = Mock(return_value=0.0) # type: ignore | ||
executor.get_obs_time = Mock(return_value=0) | ||
|
||
server = Server(executor) | ||
|
||
client = await aiohttp_client(server._app) | ||
response = await client.get('/query/area?ra=0.0&dec=0.0&radius=10.0') | ||
|
||
assert response.status == 200 | ||
data = await response.json() | ||
|
||
assert data["value"] == 0.0 | ||
assert data["obs_time"] == 0 | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_area_query_altaz(aiohttp_client, observer: Observer) -> None: | ||
executor = CoverageQueryExecutor(observer=observer) | ||
executor.area_query_altaz = Mock(return_value=0.0) # type: ignore | ||
executor.get_obs_time = Mock(return_value=0) | ||
|
||
server = Server(executor) | ||
|
||
client = await aiohttp_client(server._app) | ||
response = await client.get('/query/area?alt=0.0&az=0.0&radius=10.0') | ||
|
||
assert response.status == 200 | ||
data = await response.json() | ||
|
||
assert data["value"] == 0.0 | ||
assert data["obs_time"] == 0 | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_area_query_invalid_coords(aiohttp_client, observer: Observer) -> None: | ||
executor = CoverageQueryExecutor(observer=observer) | ||
executor.area_query_altaz = Mock(return_value=0.0) # type: ignore | ||
executor.get_obs_time = Mock(return_value=0) | ||
|
||
server = Server(executor) | ||
|
||
client = await aiohttp_client(server._app) | ||
response = await client.get('/query/area?a=0.0&z=0.0&radius=10.0') | ||
|
||
assert response.status == 400 | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_area_query_invalid_coords(aiohttp_client, observer: Observer) -> None: | ||
executor = CoverageQueryExecutor(observer=observer) | ||
executor.area_query_altaz = Mock(return_value=0.0) # type: ignore | ||
executor.get_obs_time = Mock(return_value=0) | ||
|
||
server = Server(executor) | ||
|
||
client = await aiohttp_client(server._app) | ||
response = await client.get('/query/area?alt=0.0&az=0.0') | ||
|
||
assert response.status == 400 |