Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature add tests #1

Merged
merged 13 commits into from Jul 13, 2023
Merged

Feature add tests #1

merged 13 commits into from Jul 13, 2023

Conversation

cblack34
Copy link
Owner

No description provided.

cblack34 and others added 13 commits July 12, 2023 15:22
- Added `models_for_test.py` file with `Parent` and `Child` classes.
- Created a new table called `parents_to_children` to establish a many-to-many relationship between parents and children.
- Updated the `test_crud.py` file to import the newly added models (`Parent`, `Child`, and `Base`) from `models_for_test.py`.
- Added test data creation methods (`create_test_data()` and `link_children_to_parents()`) to populate the database with parent and child records.
- Modified existing tests in the `TestGetModels` class to use the new models (`Parent`) instead of the old model (`TestModel`).
This commit adds black and pylint as dev dependencies in the pyproject.toml file. The pytest version is also updated to "^7.4.0".

fix: Fix newline at end of file

This commit fixes the missing newline at the end of the models_for_test.py file.

refactor: Refactor test_crud.py

This commit refactors the test_crud.py file by removing unused variables, fixing indentation, and improving code readability.
- Added a new column `id_modulo` of type Integer to the Parent model in `models_for_test.py`.

feat: Import additional functions and classes for testing CRUD operations

- Imported the following functions and classes from `sqlalchemy_crud.crud` module:
  - get_model
  - get_model_by_attribute
  - get_models_by_attribute
  - create_model
  - update_model
  - delete_model
  - link_models
  - unlink_models

- These imports are necessary for testing CRUD operations in the `test_crud.py` file.

feat: Update test_get_models_with_default_offset_and_limit method

- Updated the `test_get_models_with_default_offset_and_limit` method in `test_crud.py`.
- The method now creates test data with an additional attribute, `id_modulo`, for each parent.
- The test checks if the models returned by calling `get_models` have the expected names and attributes.

feat: Add tests for relationship handling in CRUD operations

- Added tests for relationship handling in CRUD operations.
- Tests include:
    * Retrieving models with relationships using `get_models`
    * Retrieving a single model with relationships using `get_model`
    * Retrieving a single model by attribute value with relationships using `get_model_by_attribute`
    * Retrieving multiple models by attribute value with relationships using `get_models_by_attribute`
    * Creating a new model with relationships using `create_model`
    * Updating an existing model with relationships using `update_model`
    * Deleting a model with relationships using 'delete_model'
    * Linking two models together using 'link_models'

fix: Fix typo in link_children_to_parents method

- Fixed a typo in the loop range of the 'link_children_to_parents' method.
…s by attribute with invalid attributes.

- Added coverage and pytest-cov dependencies to pyproject.toml.
- Added test_get_model_by_attribute_with_invalid_attribute() method to test_crud.py.
- Added test_get_models_by_attribute_with_invalid_attribute() method to test_crud.py.
- Refactored the import statements to group related functions together
- Split long lines of code into multiple lines for improved readability
- Reorganized the order of function definitions in the test class
- Added more detailed comments to explain the purpose of each test case
- Removed unnecessary import statement from `sqlalchemy_crud/crud.py`
- Reordered import statements in `tests/models_for_test.py`
- Removed unused import statement from `tests/test_crud.py`
- Added a new workflow file `poetry-pytest.yml` for running tests using Poetry and pytest.
- Configured the workflow to run on pushes to the `main` branch and pull requests targeting the `main` branch.
- Set up the job to run on Ubuntu latest version.
- Added steps to checkout the code, set up Python 3.8, install Poetry, cache dependencies, and run tests using pytest.

Updated an existing workflow file `pylint.yml`.

- Commented out the entire content of the file as it was not being used.

Note: No specific names or files from the code were mentioned in this commit message.
Added a Pytest badge to the README.md file. The badge displays the status of the Pytest workflow for this project.
This commit renames the file dependabot.yml to workflows/dependabot.yml. This change was made to improve the organization and structure of the codebase.
This commit renames the dependabot.yml file to .github/dependabot.yml. This change improves the organization of the repository by moving the file to a more appropriate location.
The commit updates the README.md file by replacing the old badge link with a new one. The new badge link points to the GitHub Actions workflow for poetry-pytest.yml.
@cblack34 cblack34 merged commit b1a1a9a into master Jul 13, 2023
3 checks passed
@cblack34 cblack34 deleted the Feature-add-tests branch July 13, 2023 02:42
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.

None yet

1 participant