-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
Add unit tests to the project using pytest and python mocking - do not use moto.
You should set up github actions to run the tests. You should create a Makefile that contains the required commands and use that in the github action. I would like 95% test coverage minimum and you should not modify any of the non testing python as you do this task.
Agent Context
{ "tasks": [ { "id": "a23a5123-e61f-495a-86cc-f948aedb6d7e", "taskIndex": 0, "request": "[original issue]\n**Add unit tests with pytest and GitHub Actions**\nAdd unit tests to the project using pytest and python mocking - do not use moto.\n\nYou should set up github actions to run the tests. You should create a Makefile that contains the required commands and use that in the github action. I would like 95% test coverage minimum and you should not modify any of the non testing python as you do this task.", "title": "Add unit tests with pytest and GitHub Actions for betterboto.", "createdAt": 1755196462635, "completed": false, "planRevisions": [ { "revisionIndex": 0, "plans": [ { "index": 0, "plan": "- Create a `requirements-dev.txt` file and add `pytest` and `pytest-cov` to it. Then, modify `setup.py` to include `requirements-dev.txt` in `extras_require` for `dev`.\n- Create a `Makefile` at the project root. Add a `test` target to the `Makefile` that installs development dependencies and runs `pytest --cov=betterboto --cov-report=xml --cov-fail-under=95`.\n- Create a `tests/` directory and an empty `tests/__init__.py` file within it.\n- Create `tests/test_client.py` and implement unit tests for `betterboto/client.py`. These tests should cover `ClientContextManager`, `MultiRegionClientContextManager`, `CrossAccountClientContextManager`, and `CrossMultipleAccountsClientContextManager` by mocking `boto3.session.Session().client` and its methods.\n- Create `tests/test_utils.py` and implement unit tests for `betterboto/utils.py`. These tests should cover the `slurp` function, mocking the `func` argument and `time.sleep`.\n- Create `tests/test_budgets.py` and implement unit tests for `betterboto/budgets.py`. These tests should cover `describe_budgets_single_page` and `make_better`, mocking the `budgets` client and its `describe_budgets` method.\n- Create `tests/test_cloudformation.py` and implement unit tests for `betterboto/cloudformation.py`. These tests should cover `get_hash_for_template`, `create_or_update`, `describe_stacks_single_page`, `ensure_deleted`, and `list_stacks_single_page`, mocking the `cloudformation` client and its methods.\n- Create `tests/test_codebuild.py` and implement unit tests for `betterboto/codebuild.py`. These tests should cover `start_build_and_wait_for_completion` and `make_better`, mocking the `codebuild` client and its methods.\n- Create `tests/test_codecommit.py` and implement unit tests for `betterboto/codecommit.py`. These tests should cover `list_branches_single_page` and `make_better`, mocking the `codecommit` client and its methods.\n- Create `tests/test_guardduty.py` and implement unit tests for `betterboto/guardduty.py`. These tests should cover `list_members_single_page` and `make_better`, mocking the `guardduty` client and its methods.\n- Create `tests/test_organizations.py` and implement comprehensive unit tests for all functions in `betterboto/organizations.py`, mocking the `organizations` client and its methods.\n- Create `tests/test_servicecatalog.py` and implement comprehensive unit tests for all functions in `betterboto/servicecatalog.py`, mocking the `servicecatalog` client and its methods.\n- Create `tests/test_ssm.py` and implement unit tests for `betterboto/ssm.py`. These tests should cover `put_parameter_and_wait`, `get_parameter_history_single_page`, `get_parameter_version`, and `make_better`, mocking the `ssm` client and its methods.\n- Create a new GitHub Actions workflow file at `tmp-workflows/python-test.yml`. This workflow should be triggered on `push` and `pull_request` events, set up Python, install dependencies (including development dependencies using the Makefile), run the `make test` command, and upload the generated coverage report as an artifact. Inform the user that they will need to manually move this file to the `.github/workflows/` directory.", "completed": true, "summary": "I have created the `requirements-dev.txt` file, updated `setup.py` to include the dev requirements, created the `Makefile` with a test target, and created the `tests` directory and all the necessary test files. I have also created the `tmp-workflows/python-test.yml` file for the GitHub Actions workflow. I am now ready to start implementing the tests." } ], "createdAt": 1755196462635, "createdBy": "agent" }, { "revisionIndex": 1, "plans": [ { "index": 0, "plan": "- Create a `requirements-dev.txt` file and add `pytest` and `pytest-cov` to it. Then, modify `setup.py` to include `requirements-dev.txt` in `extras_require` for `dev`.\n- Create a `Makefile` at the project root. Add a `test` target to the `Makefile` that installs development dependencies and runs `pytest --cov=betterboto --cov-report=xml --cov-fail-under=95`.\n- Create a `tests/` directory and an empty `tests/__init__.py` file within it.\n- Create `tests/test_client.py` and implement unit tests for `betterboto/client.py`. These tests should cover `ClientContextManager`, `MultiRegionClientContextManager`, `CrossAccountClientContextManager`, and `CrossMultipleAccountsClientContextManager` by mocking `boto3.session.Session().client` and its methods.\n- Create `tests/test_utils.py` and implement unit tests for `betterboto/utils.py`. These tests should cover the `slurp` function, mocking the `func` argument and `time.sleep`.\n- Create `tests/test_budgets.py` and implement unit tests for `betterboto/budgets.py`. These tests should cover `describe_budgets_single_page` and `make_better`, mocking the `budgets` client and its `describe_budgets` method.\n- Create `tests/test_cloudformation.py` and implement unit tests for `betterboto/cloudformation.py`. These tests should cover `get_hash_for_template`, `create_or_update`, `describe_stacks_single_page`, `ensure_deleted`, and `list_stacks_single_page`, mocking the `cloudformation` client and its methods.\n- Create `tests/test_codebuild.py` and implement unit tests for `betterboto/codebuild.py`. These tests should cover `start_build_and_wait_for_completion` and `make_better`, mocking the `codebuild` client and its methods.\n- Create `tests/test_codecommit.py` and implement unit tests for `betterboto/codecommit.py`. These tests should cover `list_branches_single_page` and `make_better`, mocking the `codecommit` client and its methods.\n- Create `tests/test_guardduty.py` and implement unit tests for `betterboto/guardduty.py`. These tests should cover `list_members_single_page` and `make_better`, mocking the `guardduty` client and its methods.\n- Create `tests/test_organizations.py` and implement comprehensive unit tests for all functions in `betterboto/organizations.py`, mocking the `organizations` client and its methods.\n- Create `tests/test_servicecatalog.py` and implement comprehensive unit tests for all functions in `betterboto/servicecatalog.py`, mocking the `servicecatalog` client and its methods.\n- Create `tests/test_ssm.py` and implement unit tests for `betterboto/ssm.py`. These tests should cover `put_parameter_and_wait`, `get_parameter_history_single_page`, `get_parameter_version`, and `make_better`, mocking the `ssm` client and its methods.\n- Create a new GitHub Actions workflow file at `tmp-workflows/python-test.yml`. This workflow should be triggered on `push` and `pull_request` events, set up Python, install dependencies (including development dependencies using the Makefile), run the `make test` command, and upload the generated coverage report as an artifact. Inform the user that they will need to manually move this file to the `.github/workflows/` directory.", "completed": true, "summary": "I have created the `requirements-dev.txt` file, updated `setup.py` to include the dev requirements, created the `Makefile` with a test target, and created the `tests` directory and all the necessary test files. I have also created the `tmp-workflows/python-test.yml` file for the GitHub Actions workflow. I am now ready to start implementing the tests." }, { "index": 1, "plan": "Implement the 'test' target in the `Makefile` to install development dependencies and run `pytest --cov=betterboto --cov-report=xml --cov-fail-under=95`.", "completed": true, "summary": "I have implemented the 'test' target in the `Makefile` to install development dependencies and run `pytest --cov=betterboto --cov-report=xml --cov-fail-under=95`. The Makefile now contains the necessary commands to execute the test suite and generate a coverage report." }, { "index": 2, "plan": "Implement the GitHub Actions workflow in `tmp-workflows/python-test.yml` as described in the plan, including triggers, Python setup, dependency installation using the Makefile, running `make test`, and uploading the coverage report.", "completed": true, "summary": "I have implemented the GitHub Actions workflow in `tmp-workflows/python-test.yml`. The workflow is triggered on `push` and `pull_request` events, sets up Python, installs dependencies using the `Makefile`, runs the tests using `make test`, and uploads the generated `coverage.xml` as a build artifact. I have also informed the user that they will need to manually move the file to the `.github/workflows/` directory." }, { "index": 3, "plan": "Implement comprehensive unit tests in `tests/test_client.py` for `betterboto/client.py`, mocking `boto3.session.Session().client` and its methods.", "completed": true, "summary": "I have implemented comprehensive unit tests for `betterboto/client.py` in `tests/test_client.py`. The tests cover `ClientContextManager`, `MultiRegionClientContextManager`, `CrossAccountClientContextManager`, and `CrossMultipleAccountsClientContextManager`, as well as the `make_better` function. I used `unittest.mock` to patch `boto3.session.Session` and the individual service modules to ensure that no actual AWS calls are made." }, { "index": 4, "plan": "Implement comprehensive unit tests in `tests/test_utils.py` for `betterboto/utils.py`, covering the `slurp` function and mocking `time.sleep`.", "completed": true, "summary": "I have implemented comprehensive unit tests for the `slurp` function in `betterboto/utils.py`. The tests, located in `tests/test_utils.py`, cover single-page responses, multi-page responses with pagination, custom token names, and the `wait_between_pages` functionality. I used `unittest.mock` to mock the paginated function and `time.sleep` to ensure the tests are fast and reliable." }, { "index": 5, "plan": "Implement comprehensive unit tests in `tests/test_budgets.py` for `betterboto/budgets.py`, covering `describe_budgets_single_page` and `make_better`, mocking the `budgets` client and its `describe_budgets` method.", "completed": true, "summary": "I have implemented comprehensive unit tests for `betterboto/budgets.py` in `tests/test_budgets.py`. The tests cover both the `make_better` function, ensuring it correctly patches the client, and the `describe_budgets_single_page` function, verifying it calls the `slurp` utility with the correct parameters. I used `unittest.mock` to patch the `slurp` function and to create a mock client." }, { "index": 6, "plan": "Implement comprehensive unit tests in `tests/test_cloudformation.py` for `betterboto/cloudformation.py`, covering `get_hash_for_template`, `create_or_update`, `describe_stacks_single_page`, `ensure_deleted`, and `list_stacks_single_page`, mocking the `cloudformation` client and its methods.", "completed": false }, { "index": 7, "plan": "Implement comprehensive unit tests in `tests/test_codebuild.py` for `betterboto/codebuild.py`, covering `start_build_and_wait_for_completion` and `make_better`, mocking the `codebuild` client and its methods.", "completed": false }, { "index": 8, "plan": "Implement comprehensive unit tests in `tests/test_codecommit.py` for `betterboto/codecommit.py`, covering `list_branches_single_page` and `make_better`, mocking the `codecommit` client and its methods.", "completed": false }, { "index": 9, "plan": "Implement comprehensive unit tests in `tests/test_guardduty.py` for `betterboto/guardduty.py`, covering `list_members_single_page` and `make_better`, mocking the `guardduty` client and its methods.", "completed": false }, { "index": 10, "plan": "Implement comprehensive unit tests in `tests/test_organizations.py` for all functions in `betterboto/organizations.py`, mocking the `organizations` client and its methods.", "completed": false }, { "index": 11, "plan": "Implement comprehensive unit tests in `tests/test_servicecatalog.py` for all functions in `betterboto/servicecatalog.py`, mocking the `servicecatalog` client and its methods.", "completed": false }, { "index": 12, "plan": "Implement comprehensive unit tests in `tests/test_ssm.py` for `betterboto/ssm.py`, covering `put_parameter_and_wait`, `get_parameter_history_single_page`, `get_parameter_version`, and `make_better`, mocking the `ssm` client and its methods.", "completed": false } ], "createdAt": 1755196518140, "createdBy": "agent" } ], "activeRevisionIndex": 1, "pullRequestNumber": 15 } ], "activeTaskIndex": 0 } [ "- Create a `requirements-dev.txt` file and add `pytest` and `pytest-cov` to it. Then, modify `setup.py` to include `requirements-dev.txt` in `extras_require` for `dev`.\n- Create a `Makefile` at the project root. Add a `test` target to the `Makefile` that installs development dependencies and runs `pytest --cov=betterboto --cov-report=xml --cov-fail-under=95`.\n- Create a `tests/` directory and an empty `tests/__init__.py` file within it.\n- Create `tests/test_client.py` and implement unit tests for `betterboto/client.py`. These tests should cover `ClientContextManager`, `MultiRegionClientContextManager`, `CrossAccountClientContextManager`, and `CrossMultipleAccountsClientContextManager` by mocking `boto3.session.Session().client` and its methods.\n- Create `tests/test_utils.py` and implement unit tests for `betterboto/utils.py`. These tests should cover the `slurp` function, mocking the `func` argument and `time.sleep`.\n- Create `tests/test_budgets.py` and implement unit tests for `betterboto/budgets.py`. These tests should cover `describe_budgets_single_page` and `make_better`, mocking the `budgets` client and its `describe_budgets` method.\n- Create `tests/test_cloudformation.py` and implement unit tests for `betterboto/cloudformation.py`. These tests should cover `get_hash_for_template`, `create_or_update`, `describe_stacks_single_page`, `ensure_deleted`, and `list_stacks_single_page`, mocking the `cloudformation` client and its methods.\n- Create `tests/test_codebuild.py` and implement unit tests for `betterboto/codebuild.py`. These tests should cover `start_build_and_wait_for_completion` and `make_better`, mocking the `codebuild` client and its methods.\n- Create `tests/test_codecommit.py` and implement unit tests for `betterboto/codecommit.py`. These tests should cover `list_branches_single_page` and `make_better`, mocking the `codecommit` client and its methods.\n- Create `tests/test_guardduty.py` and implement unit tests for `betterboto/guardduty.py`. These tests should cover `list_members_single_page` and `make_better`, mocking the `guardduty` client and its methods.\n- Create `tests/test_organizations.py` and implement comprehensive unit tests for all functions in `betterboto/organizations.py`, mocking the `organizations` client and its methods.\n- Create `tests/test_servicecatalog.py` and implement comprehensive unit tests for all functions in `betterboto/servicecatalog.py`, mocking the `servicecatalog` client and its methods.\n- Create `tests/test_ssm.py` and implement unit tests for `betterboto/ssm.py`. These tests should cover `put_parameter_and_wait`, `get_parameter_history_single_page`, `get_parameter_version`, and `make_better`, mocking the `ssm` client and its methods.\n- Create a new GitHub Actions workflow file at `tmp-workflows/python-test.yml`. This workflow should be triggered on `push` and `pull_request` events, set up Python, install dependencies (including development dependencies using the Makefile), run the `make test` command, and upload the generated coverage report as an artifact. Inform the user that they will need to manually move this file to the `.github/workflows/` directory." ]Metadata
Metadata
Assignees
Labels
No labels