Skip to content

Commit

Permalink
v1.7.1
Browse files Browse the repository at this point in the history
version 1.7.1
  • Loading branch information
thusser authored Dec 19, 2023
2 parents 293e81d + 03b2748 commit 09c1722
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 9 deletions.
8 changes: 4 additions & 4 deletions pyobs/modules/test/standalone.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
4 changes: 3 additions & 1 deletion pyobs/utils/skyflats/flatfielder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
license = "MIT"
Expand Down
Empty file added tests/modules/test/__init__.py
Empty file.
30 changes: 30 additions & 0 deletions tests/modules/test/standalone.py
Original file line number Diff line number Diff line change
@@ -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
7 changes: 4 additions & 3 deletions tests/utils/skyflats/test_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
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",)


@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
Expand All @@ -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
Expand Down

0 comments on commit 09c1722

Please sign in to comment.