From 7e7a7e246a4dbc254c2f156a4386e47c2f11c9e9 Mon Sep 17 00:00:00 2001 From: germanhydrogen Date: Thu, 14 Dec 2023 14:56:24 +0100 Subject: [PATCH 1/4] Changed at_side() call to directly specified coordinates of SAAO --- tests/utils/skyflats/test_scheduler.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/utils/skyflats/test_scheduler.py b/tests/utils/skyflats/test_scheduler.py index 13bf6b7c..a65ddf4a 100644 --- a/tests/utils/skyflats/test_scheduler.py +++ b/tests/utils/skyflats/test_scheduler.py @@ -4,7 +4,7 @@ from pyobs.utils.skyflats import Scheduler from pyobs.utils.skyflats.priorities import ConstSkyflatPriorities from pyobs.utils.time import Time - +import astropy.units as u pytest_plugins = ("pytest_asyncio",) @@ -12,7 +12,8 @@ @pytest.mark.asyncio async def test_scheduler(): # init observer and time - observer = Observer.at_site("SAAO") + saao_observer = Observer(longitude=20.8108 * u.deg, latitude=-32.375823 * u.deg, + elevation=1798.0 * u.m, timezone="UTC") now = Time("2019-11-21T17:10:00Z") # have some test functions @@ -26,7 +27,7 @@ async def test_scheduler(): priorities = ConstSkyflatPriorities({("B", (1, 1)): 1, ("V", (1, 1)): 2, ("R", (1, 1)): 3}) # create scheduler - scheduler = Scheduler(functions, priorities, observer) + scheduler = Scheduler(functions, priorities, saao_observer) await scheduler(now) # test order From 549b482842e1c0d3cbb6baf0827fbc342b55ca31 Mon Sep 17 00:00:00 2001 From: germanhydrogen Date: Thu, 14 Dec 2023 15:40:18 +0100 Subject: [PATCH 2/4] Added unit tests to standalone and did minimal refactoring --- pyobs/modules/test/standalone.py | 8 ++++---- tests/modules/test/__init__.py | 0 tests/modules/test/standalone.py | 30 ++++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 tests/modules/test/__init__.py create mode 100644 tests/modules/test/standalone.py diff --git a/pyobs/modules/test/standalone.py b/pyobs/modules/test/standalone.py index 362fbe67..9283c6dc 100644 --- a/pyobs/modules/test/standalone.py +++ b/pyobs/modules/test/standalone.py @@ -33,11 +33,11 @@ async def _message_func(self): """Thread function for async processing.""" # loop until closing while True: - # log message - log.info(self._message) + await self._loop() - # sleep a little - await asyncio.sleep(self._interval) + async def _loop(self): + log.info(self._message) + await asyncio.sleep(self._interval) __all__ = ["StandAlone"] diff --git a/tests/modules/test/__init__.py b/tests/modules/test/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/modules/test/standalone.py b/tests/modules/test/standalone.py new file mode 100644 index 00000000..e4343154 --- /dev/null +++ b/tests/modules/test/standalone.py @@ -0,0 +1,30 @@ +import asyncio +import logging + +import pytest + +from pyobs.modules.test import StandAlone + + +def test_default(): + module = StandAlone() + assert module._message == "Hello world" + assert module._interval == 10 + + +@pytest.mark.asyncio +async def test_loop(mocker, caplog): + mocker.patch("asyncio.sleep", return_value=None) + module = StandAlone("Testmessage", 3) + + with caplog.at_level(logging.INFO): + await module._loop() + + assert caplog.messages[0] == "Testmessage" + asyncio.sleep.assert_called_once_with(3) + + +@pytest.mark.asyncio +async def test_background_task(): + module = StandAlone() + assert module._message_func in module._background_tasks From dbee3aa2dadfa5f5db7cddc69c65bcb34db5f525 Mon Sep 17 00:00:00 2001 From: Tim-Oliver Husser Date: Tue, 19 Dec 2023 19:45:42 +0100 Subject: [PATCH 3/4] allow pointing to be None --- pyobs/utils/skyflats/flatfielder.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pyobs/utils/skyflats/flatfielder.py b/pyobs/utils/skyflats/flatfielder.py index 7314b6d4..da8cb349 100644 --- a/pyobs/utils/skyflats/flatfielder.py +++ b/pyobs/utils/skyflats/flatfielder.py @@ -88,7 +88,9 @@ def __init__( self._abort = asyncio.Event() # pointing - self._pointing: Optional[SkyFlatsBasePointing] = self.get_safe_object(pointing, SkyFlatsBasePointing) + self._pointing: Optional[SkyFlatsBasePointing] = None + if pointing is not None: + self._pointing = self.get_safe_object(pointing, SkyFlatsBasePointing) # state machine self._state = FlatFielder.State.INIT From 03b27481a18e1dcfa927b346e84f7e2094399d64 Mon Sep 17 00:00:00 2001 From: Tim-Oliver Husser Date: Tue, 19 Dec 2023 19:45:57 +0100 Subject: [PATCH 4/4] v1.7.1 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 290f3f22..c70aa8ab 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [tool.poetry] name = "pyobs-core" packages = [{ include = "pyobs" }] -version = "1.7.0" +version = "1.7.1" description = "robotic telescope software" authors = ["Tim-Oliver Husser "] license = "MIT"