habitmove/tests/test_habits.py

67 lines
1.5 KiB
Python

import pytest
from habitmove import loopdata, nomiedata
from habitmove import habits
@pytest.fixture
def trackerlist():
return [
nomiedata.Tracker(
hidden=False,
score=-1,
tag="testtrack",
emoji="🧪",
label="Testing",
uom="kilotest",
id="12345",
),
nomiedata.Tracker(
hidden=False,
tag="testtrack",
emoji="🧪",
label="Testing",
id="54321",
one_tap=False,
color="#FF0000",
ignore_zeros=False,
math="mean",
type="range",
uom="megatest",
min=0,
max=10,
goal=6,
default=2,
score=1,
),
]
def test_simple_habit_transform_from_tracker(trackerlist):
result = habits.trackers_to_habits([trackerlist[0]])
assert result == [
loopdata.Habit(
name="🧪 Testing",
description="testtrack",
unit="kilotest",
uuid="12345",
archived=False,
color=0,
)
]
def test_range_habit_transform_from_tracker(trackerlist):
result = habits.trackers_to_habits([trackerlist[1]])
assert result == [
loopdata.Habit(
name="🧪 Testing",
description="testtrack",
unit="megatest",
uuid="54321",
archived=False,
color=11,
type=1,
target_value=6,
)
]