Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jsakkos committed Dec 25, 2024
1 parent 285c149 commit 505fcee
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 12 deletions.
15 changes: 7 additions & 8 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,14 @@ jobs:
run: |
uv venv
uv pip install -e .
uv tool install pytest
- name: Run tests with pytest and coverage
run: |
uvx pytest tests
uv run --dev pytest tests --cov=lr_autotag --cov-report xml
# - name: Upload coverage to Codecov
# uses: codecov/codecov-action@v3
# with:
# file: ./coverage.xml
# flags: unittests
# fail_ci_if_error: true
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
flags: unittests
fail_ci_if_error: true
32 changes: 28 additions & 4 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ def test_cli_catalog_path(runner):

result = runner.invoke(main, ['--catalog', 'test.lrcat'])
assert result.exit_code == 0
MockTagger.assert_called_once_with('test.lrcat', None)
MockTagger.assert_called_once_with('test.lrcat', None, 'src/lr_autotag/Foundation List 2.0.1.txt')
mock_instance.process_catalog.assert_called_once_with('keyword_suggestions.json', False, False)

def test_cli_image_folder(runner):
with patch('lr_autotag.cli.LightroomClassicTagger') as MockTagger:
Expand All @@ -23,7 +24,8 @@ def test_cli_image_folder(runner):

result = runner.invoke(main, ['--image-folder', 'test/images'])
assert result.exit_code == 0
MockTagger.assert_called_once_with(None, 'test/images')
MockTagger.assert_called_once_with(None, 'test/images', 'src/lr_autotag/Foundation List 2.0.1.txt')
mock_instance.process_catalog.assert_called_once_with('keyword_suggestions.json', False, False)

def test_cli_overwrite_flag(runner):
with patch('lr_autotag.cli.LightroomClassicTagger') as MockTagger:
Expand All @@ -32,7 +34,28 @@ def test_cli_overwrite_flag(runner):

result = runner.invoke(main, ['--catalog', 'test.lrcat', '--overwrite'])
assert result.exit_code == 0
mock_instance.process_catalog.assert_called_once_with('keyword_suggestions.json', True)
MockTagger.assert_called_once_with('test.lrcat', None, 'src/lr_autotag/Foundation List 2.0.1.txt')
mock_instance.process_catalog.assert_called_once_with('keyword_suggestions.json', True, False)

def test_cli_dry_run(runner):
with patch('lr_autotag.cli.LightroomClassicTagger') as MockTagger:
mock_instance = MockTagger.return_value
mock_instance.process_catalog.return_value = {}

result = runner.invoke(main, ['--catalog', 'test.lrcat', '--dry-run'])
assert result.exit_code == 0
MockTagger.assert_called_once_with('test.lrcat', None, 'src/lr_autotag/Foundation List 2.0.1.txt')
mock_instance.process_catalog.assert_called_once_with('keyword_suggestions.json', False, True)

def test_cli_custom_keywords_file(runner):
with patch('lr_autotag.cli.LightroomClassicTagger') as MockTagger:
mock_instance = MockTagger.return_value
mock_instance.process_catalog.return_value = {}

result = runner.invoke(main, ['--catalog', 'test.lrcat', '--keywords-file', 'custom_keywords.txt'])
assert result.exit_code == 0
MockTagger.assert_called_once_with('test.lrcat', None, 'custom_keywords.txt')
mock_instance.process_catalog.assert_called_once_with('keyword_suggestions.json', False, False)

def test_cli_custom_output(runner):
with patch('lr_autotag.cli.LightroomClassicTagger') as MockTagger:
Expand All @@ -41,4 +64,5 @@ def test_cli_custom_output(runner):

result = runner.invoke(main, ['--catalog', 'test.lrcat', '--output', 'custom.json'])
assert result.exit_code == 0
mock_instance.process_catalog.assert_called_once_with('custom.json', False)
MockTagger.assert_called_once_with('test.lrcat', None, 'src/lr_autotag/Foundation List 2.0.1.txt')
mock_instance.process_catalog.assert_called_once_with('custom.json', False, False)

0 comments on commit 505fcee

Please sign in to comment.