Skip to content

Commit

Permalink
- Dev7: Fixed logical error for instantview
Browse files Browse the repository at this point in the history
  • Loading branch information
spacemanspiff2007 committed Oct 10, 2024
1 parent 40eeb51 commit 9a7f6d1
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 16 deletions.
2 changes: 1 addition & 1 deletion requirements_setup.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ aiomqtt == 2.3.0
# eascheduler ==
git+https://github.com/spacemanspiff2007/eascheduler.git@rework

immutables == 0.20
immutables == 0.21
easyconfig == 0.3.2
stack_data == 0.6.3
colorama == 0.4.6
Expand Down
2 changes: 1 addition & 1 deletion src/HABApp/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
# Development versions contain the DEV-COUNTER postfix:
# - 24.01.0.DEV-1

__version__ = '24.09.0.DEV-6'
__version__ = '24.09.0.DEV-7'
8 changes: 4 additions & 4 deletions src/HABApp/core/lib/instant_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,16 @@ def newer_than(self, obj=None, **kwargs):
return self._cmp(gt, obj, **kwargs)

def __lt__(self, other: HINT_OBJ) -> bool:
return self._cmp(lt, other)
return self._cmp(gt, other)

def __le__(self, other: HINT_OBJ) -> bool:
return self._cmp(le, other)
return self._cmp(ge, other)

def __gt__(self, other: HINT_OBJ) -> bool:
return self._cmp(gt, other)
return self._cmp(lt, other)

def __ge__(self, other: HINT_OBJ) -> bool:
return self._cmp(ge, other)
return self._cmp(le, other)

def __eq__(self, other: InstantView | Instant) -> bool:
if isinstance(other, InstantView):
Expand Down
26 changes: 16 additions & 10 deletions tests/test_core/test_lib/test_instant_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,30 @@ def view():


def test_methods(view: InstantView):
assert view < seconds(1)
assert not view < seconds(60)
assert view <= seconds(60)

assert view > seconds(61)
assert view > seconds(59)
assert not view > seconds(60)
assert view >= seconds(60)

assert view < seconds(61)
assert not view < seconds(60)
assert view <= seconds(60)


def test_cmp_obj(view: InstantView):
assert view < TimeDelta(seconds=59)
assert view < dt_timedelta(seconds=59)
assert view < 'PT59S'
assert view < 59
assert view > TimeDelta(seconds=59)
assert view > dt_timedelta(seconds=59)
assert view > 'PT59S'
assert view > 59


def test_cmp_funcs(view: InstantView):
assert view.older_than(seconds=59)
assert view > 59
assert view >= 60

assert view.newer_than(seconds=61)
assert view < 61
assert view <= 60


def test_delta_funcs(view: InstantView):
Expand All @@ -51,4 +56,5 @@ def test_convert():

def test_repr():
view = InstantView(SystemDateTime(2021, 1, 2, 10, 11, 12).instant())
assert str(view) == 'InstantView(2021-01-02T10:11:12+01:00)'
# Cut the timezone away because we don't know where the test is running
assert str(view)[:-6] == 'InstantView(2021-01-02T10:11:12+'

0 comments on commit 9a7f6d1

Please sign in to comment.