Consolidate pytest.ini with pyproject.toml & add test
Some checks failed
Run Tests / run-tests (push) Failing after 29s
Some checks failed
Run Tests / run-tests (push) Failing after 29s
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import streamlit as st
|
||||
|
||||
from streamlit import dialog
|
||||
from tomlkit import key
|
||||
|
||||
from queries import crud, daily_stats, weekly_stats, monthly_stats, yearly_stats
|
||||
from enums import CounterType
|
||||
|
||||
@@ -76,13 +78,14 @@ with st.container(key="counter-table"):
|
||||
if counter_type is CounterType.SIMPLE.value:
|
||||
st.markdown(f"**{stats_current} {stats_current_unit}**")
|
||||
else:
|
||||
st.markdown(f"""
|
||||
**{stats_current} {stats_current_unit}**
|
||||
*{stats_prev} {stats_prev_unit}*
|
||||
""")
|
||||
st.markdown(f"**{stats_current} {stats_current_unit}** *{stats_prev} {stats_prev_unit}*")
|
||||
|
||||
with st.container(horizontal=True, width="stretch", horizontal_alignment="right"):
|
||||
st.page_link("pages/stats.py", icon=":material/bar_chart:", icon_position="right", label="", query_params={"counter_id": str(counter_id)})
|
||||
st.page_link("pages/stats.py",
|
||||
icon=":material/bar_chart:",
|
||||
icon_position="right",
|
||||
label="",
|
||||
query_params={"counter_id": str(counter_id)})
|
||||
|
||||
st.html(f"""
|
||||
<style>
|
||||
|
||||
@@ -14,6 +14,10 @@ dependencies = [
|
||||
"pytest-env (>=1.6.0,<2.0.0)"
|
||||
]
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core>=1.0.0"]
|
||||
build-backend = "poetry.core.masonry.api"
|
||||
|
||||
[virtualenvs]
|
||||
in-project = true
|
||||
create = true
|
||||
@@ -35,6 +39,13 @@ pytest = ">=9.0"
|
||||
[tool.poetry.dependencies]
|
||||
python = ">=3.10,<4"
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core>=1.0.0"]
|
||||
build-backend = "poetry.core.masonry.api"
|
||||
[tool.pytest.ini_options]
|
||||
log_cli = true
|
||||
log_cli_level = "INFO"
|
||||
log_cli_format = "%(asctime)s [%(levelname)8s] %(message)s (%(filename)s:%(lineno)s)"
|
||||
log_cli_date_format="%Y-%m-%d %H:%M:%S"
|
||||
pythonpath = "../app"
|
||||
env = [
|
||||
"DATABASE_FILE=testdb.sqlite",
|
||||
"DATABASE_URL=sqlite:///testdb.sqlite?cache=shared"
|
||||
]
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
[pytest]
|
||||
log_cli = 1
|
||||
log_cli_level = INFO
|
||||
log_cli_format = %(asctime)s [%(levelname)8s] %(message)s (%(filename)s:%(lineno)s)
|
||||
log_cli_date_format=%Y-%m-%d %H:%M:%S
|
||||
pythonpath = ../app
|
||||
env =
|
||||
DATABASE_FILE=testdb.sqlite
|
||||
DATABASE_URL=sqlite:///testdb.sqlite?cache=shared
|
||||
|
||||
@@ -7,6 +7,7 @@ def test_initial_state(app):
|
||||
assert not app.error
|
||||
assert len(app.header) == 0 # No counter currently present
|
||||
|
||||
|
||||
def test_add_counter(app):
|
||||
app.run()
|
||||
|
||||
@@ -31,6 +32,7 @@ def test_add_counter(app):
|
||||
assert len(app.header) == 1 # A new counter was added
|
||||
assert app.header[0].value == ":material/calendar_clock: Walk"
|
||||
|
||||
|
||||
def test_remove_counter(app):
|
||||
|
||||
# Create a counter to remove
|
||||
@@ -57,3 +59,20 @@ def test_remove_counter(app):
|
||||
app.run()
|
||||
|
||||
assert len(app.header) == 0 # No counter exists
|
||||
|
||||
|
||||
def test_increment_counter(app):
|
||||
|
||||
# Create a counter to increment
|
||||
queries.crud.create_counter("Remove me", CounterType.SIMPLE, "020122")
|
||||
|
||||
app.run()
|
||||
assert not app.exception
|
||||
assert not app.error
|
||||
|
||||
assert len(app.header) == 1 # One counter exists
|
||||
assert "0 times" in app.markdown[0].value # Counter is 0
|
||||
|
||||
app.button(key="increment_counter_1").click().run()
|
||||
|
||||
assert "1 times" in app.markdown[0].value # Counter is 1
|
||||
|
||||
Reference in New Issue
Block a user