Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ GOOGLE_API_KEY=key
# SERVICE_DESK Integration
SERVICE_DESK_URL=
SERVICE_DESK_USER=
SERVICE_DESK_TOKEN=
SERVICE_DESK_TOKEN=

# Your time zone. Defaults to UTC.
TIME_ZONE=
2 changes: 1 addition & 1 deletion .github/workflows/conventional-label.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ jobs:
steps:
- uses: bcoe/conventional-release-labels@886f696738527c7be444262c327c89436dfb95a8 #v1.3.1
with:
type_labels: '{"feat": "feature", "fix": "fix", "breaking": "breaking", "ci": "CI", "build": "build", "refactor": "refactor"}'
type_labels: '{"feat": "feature", "fix": "fix", "breaking": "breaking", "ci": "CI", "build": "build", "refactor": "refactor", "test": "test"}'
4 changes: 2 additions & 2 deletions src/lightman_ai/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ def run(
load_dotenv(env_file)
configure_sentry()

mutually_exclusive_fields_set = [x for x in [start_date, today, yesterday] if x]
if len(mutually_exclusive_fields_set) > 1:
mutually_exclusive_date_fields = [x for x in [start_date, today, yesterday] if x]
if len(mutually_exclusive_date_fields) > 1:
raise click.UsageError("--today, --yesterday and --start-date are mutually exclusive. Set one at a time.")
elif today:
now = datetime.now(ZoneInfo(settings.TIME_ZONE))
Expand Down
32 changes: 32 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from unittest.mock import ANY, Mock, call, patch
from zoneinfo import ZoneInfo

import pytest
from click.testing import CliRunner
from freezegun import freeze_time
from lightman_ai import cli
Expand Down Expand Up @@ -57,6 +58,37 @@ def test_arguments(self, m_prompt: Mock, m_config: Mock, m_lightman: Mock, m_loa
assert m_prompt.call_args == call(path="prompt file")
assert m_load_dotenv.call_args == call(".env") # Default env file

@pytest.mark.parametrize(
("field1", "field2", "field3"),
[
("--today", "--yesterday", ""),
("--today", "--start-date", "2025-07-29"),
("--yesterday", "--start-date", "2025-07-29"),
],
)
@patch("lightman_ai.cli.lightman")
def test_today_yesterday_start_date_mutualle_exlusive(
self,
m_lightman: Mock,
field1: str,
field2: str,
field3: str,
) -> None:
runner = CliRunner()

args = [field1, field2]
if field3:
args.append(field3)
with patch_config_file():
result = runner.invoke(
cli.run,
args,
)

assert result.exit_code == 2
assert "--today, --yesterday and --start-date are mutually exclusive. Set one at a time." in result.output
assert m_lightman.call_count == 0

@patch("lightman_ai.cli.load_dotenv")
@patch("lightman_ai.cli.lightman")
@patch("lightman_ai.cli.FileConfig.get_config_from_file")
Expand Down