Skip to content

Add BDD tests#52

Open
TiagoOpenCosmos wants to merge 5 commits intomainfrom
feature/add-bdd-tests
Open

Add BDD tests#52
TiagoOpenCosmos wants to merge 5 commits intomainfrom
feature/add-bdd-tests

Conversation

@TiagoOpenCosmos
Copy link
Copy Markdown
Contributor

@TiagoOpenCosmos TiagoOpenCosmos commented Feb 13, 2026

No description provided.

- Added pytest-bdd and responses as dev dependencies
- Created BDD test structure with 78 scenarios across 7 feature areas:
  - Items (15): CRUD operations and search
  - Collections (10): CRUD and listing
  - Storage (13): Upload, download, delete
  - Projects (13): Project item management
  - Authentication (12): M2M auth, token refresh, hooks
  - Error handling (9): Exception types and formats
  - Validation (10): Date, license, parameter validation
- Added dedicated BDD test job to CI pipeline
- All tests use mock server approach (responses library)
- Updated mock_config fixture to explicitly set URL configurations
  (test.app.open-cosmos.com) instead of relying on config.yaml
- Fixed preauthenticated session test to use mock_config fixture
- Ensures tests pass in CI where config.yaml is not present
Copy link
Copy Markdown

Copilot AI left a comment

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 adds comprehensive BDD (Behavior-Driven Development) test coverage to the DataCosmos SDK using pytest-bdd and the responses library for HTTP mocking. The tests are organized into 7 feature areas with 78 scenarios that cover CRUD operations, authentication, error handling, validation, and storage operations. The implementation follows a mock-first approach without integration tests, using the responses library to mock all HTTP interactions.

Changes:

  • Added pytest-bdd (>=7.0.0) and responses (>=0.25.0) as development dependencies
  • Created 7 feature files with 78 BDD scenarios covering items, collections, storage, projects, authentication, error handling, and validation
  • Implemented step definitions for all scenarios with shared fixtures and mocking infrastructure
  • Updated CI pipeline with a dedicated BDD test job that runs independently from unit tests

Reviewed changes

Copilot reviewed 20 out of 21 changed files in this pull request and generated 35 comments.

Show a summary per file
File Description
uv.lock Updated lock file with new dev dependencies (pytest-bdd, responses) and dependency version changes
pyproject.toml Added pytest-bdd and responses to dev dependencies; configured pytest markers and BDD features directory
.github/workflows/main.yaml Split test job into separate "unit tests" and "BDD tests" jobs; updated test paths and job dependencies
tests/bdd/conftest.py Shared fixtures for BDD tests including mock responses, client configuration, and test data generators
tests/bdd/step_defs/init.py Package initialization file for step definitions
tests/bdd/step_defs/conftest.py Step-level configuration file with unused imports
tests/bdd/step_defs/test_*.py Step definition implementations for each feature area (items, collections, storage, projects, authentication, error_handling, validation)
tests/bdd/features/*.feature Gherkin feature files defining BDD scenarios for all 7 feature areas
tests/bdd/init.py Package initialization file for BDD tests

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/bdd/step_defs/test_storage.py
Comment thread tests/bdd/step_defs/test_items.py Outdated
Comment thread tests/bdd/step_defs/test_items.py Outdated
Comment thread tests/bdd/step_defs/test_items.py Outdated
Comment thread tests/bdd/features/items.feature Outdated
Comment thread tests/bdd/step_defs/test_storage.py Outdated
Comment thread tests/bdd/step_defs/test_storage.py Outdated
Comment thread tests/bdd/step_defs/test_validation.py Outdated
Comment thread tests/bdd/step_defs/test_validation.py Outdated
Comment thread tests/bdd/step_defs/test_projects.py Outdated
- Remove unused imports (pytest, ScenarioContext) from step files
- Add shutil.rmtree cleanup for temp directories via pytest finalizer
- Use getattr(context, 'exception', None) for safer exception checks
- Fix DatacosmosError constructor (use setattr for status_code)
- Consolidate verify_datacosmos_error and verify_value_error steps in conftest
- Remove trailing whitespace from items.feature
- Remove unused imports (json, pytest, parsers, ScenarioContext)
- Delete empty tests/bdd/step_defs/conftest.py
- Improve ScenarioContext type hints
- Move shared 'a configured STAC client' step to conftest.py
- Replace tempfile.mkdtemp() with tmp_path fixture
- Update pytest-bdd and responses version constraints
- Update CI workflow to include tests/test_pass.py
- Remove accidentally committed files: k8s-test/, datacosmos-sdk.code-workspace, test_project_ops.py
Copy link
Copy Markdown
Member

@pepjo pepjo left a comment

Choose a reason for hiding this comment

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

I've only reviewed the BDD tests, they look good to me :)

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.

3 participants