Skip to content

Refactor: Mock OpenAI calls in job analyzer tests - #6

Open
frenzel-ai-dev wants to merge 4 commits into
mainfrom
feat/refactor-job-analyzer-tests
Open

Refactor: Mock OpenAI calls in job analyzer tests#6
frenzel-ai-dev wants to merge 4 commits into
mainfrom
feat/refactor-job-analyzer-tests

Conversation

@frenzel-ai-dev

Copy link
Copy Markdown
Owner

I've separated the OpenAI API-dependent test into an integration test.

  • I modified tests/test_job_analyzer.py to ensure all tests use unittest.mock for OpenAI API calls.
  • I created tests/integration/test_job_analyzer_integration.py and moved the test that makes actual API calls (test_full_analysis_process) into it.
  • This integration test is marked with @pytest.mark.integration and requires the OPENAI_API_KEY environment variable to be set to pass.

Unit tests in tests/test_job_analyzer.py now all pass with mocks. The integration test in tests/integration/test_job_analyzer_integration.py will pass if a valid OPENAI_API_KEY is available in the environment.

I've separated the OpenAI API-dependent test into an integration test.

- I modified `tests/test_job_analyzer.py` to ensure all tests use `unittest.mock` for OpenAI API calls.
- I created `tests/integration/test_job_analyzer_integration.py` and moved the test that makes actual API calls (`test_full_analysis_process`) into it.
- This integration test is marked with `@pytest.mark.integration` and requires the `OPENAI_API_KEY` environment variable to be set to pass.

Unit tests in `tests/test_job_analyzer.py` now all pass with mocks.
The integration test in `tests/integration/test_job_analyzer_integration.py` will pass if a valid `OPENAI_API_KEY` is available in the environment.
@frenzel-ai-dev
frenzel-ai-dev requested a review from Copilot May 26, 2025 22:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the job analyzer test suite by removing the real-API integration test from the unit tests and moving it into its own integration test file.

  • All unit tests in tests/test_job_analyzer.py now mock OpenAI API calls.
  • A separate integration test in tests/integration/test_job_analyzer_integration.py exercises the full analysis process with real API calls (marked with @pytest.mark.integration).

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
tests/test_job_analyzer.py Removed the @pytest.mark.integration test, ensuring all unit tests mock OpenAI API calls.
tests/integration/test_job_analyzer_integration.py Added a new integration test file that runs the full CLI analysis with real OpenAI API calls.

@@ -0,0 +1,63 @@
import os

Copilot AI May 26, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The import 'os' is unused; if you're planning to check OPENAI_API_KEY, consider adding a skip guard using os.getenv, otherwise remove the import.

Copilot uses AI. Check for mistakes.
Comment thread tests/integration/test_job_analyzer_integration.py Outdated
Comment thread tests/integration/test_job_analyzer_integration.py Outdated
Comment thread tests/integration/test_job_analyzer_integration.py Outdated
frenzel-ai-dev and others added 3 commits May 26, 2025 18:54
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants