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

Unit Tests #40

Closed
WayneLambert opened this issue Jul 1, 2020 · 12 comments
Closed

Unit Tests #40

WayneLambert opened this issue Jul 1, 2020 · 12 comments
Assignees
Labels
Stale Issue tests Tests to verify project functionality

Comments

@WayneLambert
Copy link
Owner

WayneLambert commented Jul 1, 2020

Unit tests need to be written for the project's apps.

@WayneLambert WayneLambert self-assigned this Jul 1, 2020
@WayneLambert WayneLambert added app: blog Issues relating to the `blog` app tests Tests to verify project functionality labels Jul 1, 2020
@WayneLambert WayneLambert pinned this issue Jul 4, 2020
WayneLambert added a commit that referenced this issue Jul 5, 2020
@WayneLambert WayneLambert added the app: api Issues relating to the `api` app label Jul 5, 2020
WayneLambert added a commit that referenced this issue Jul 5, 2020
WayneLambert added a commit that referenced this issue Jul 12, 2020
WayneLambert added a commit that referenced this issue Jul 17, 2020
Add unit tests and improve coverage
WayneLambert added a commit that referenced this issue Jul 17, 2020
Add unit tests and improve coverage
WayneLambert added a commit that referenced this issue Jul 23, 2020
@WayneLambert WayneLambert removed app: api Issues relating to the `api` app app: blog Issues relating to the `blog` app labels Jul 23, 2020
@WayneLambert
Copy link
Owner Author

Coverage including branches currently sits at 85%

WayneLambert added a commit that referenced this issue Jul 26, 2020
Capture instances of game being played #40
WayneLambert added a commit that referenced this issue Jul 26, 2020
Capture instances of game being played #40
@WayneLambert WayneLambert unpinned this issue Jul 26, 2020
WayneLambert added a commit that referenced this issue Jul 28, 2020
WayneLambert added a commit that referenced this issue Jul 30, 2020
WayneLambert added a commit that referenced this issue Aug 3, 2020
The update to PyTest >6.0 introduced some breaking changes due to feature deprecations. Unit tests have been re-ran all and have passed.

Adds the following functionality:

- Updated Pytest to version 6.0.1 + Hypothesis
- Amended positional arguments for fixtures to named ones
- Amended `pytest.ini` file to remove unknown configuration options
- Added docstrings to global `helpers` module

See also: #40
WayneLambert added a commit that referenced this issue Aug 3, 2020
The update to PyTest >6.0 introduced some breaking changes due to
feature deprecations. Unit tests have been re-ran all and have passed.

Adds the following functionality:

- Updated Pytest to version 6.0.1 + Hypothesis
- Amended positional arguments for fixtures to named ones
- Amended `pytest.ini` file to remove unknown configuration options
- Added docstrings to global `helpers` module

See also: #40
WayneLambert added a commit that referenced this issue Aug 3, 2020
Improve the testing and coverage reporting for the project enabling a
more robust build.

Adds the following functionality:

- Adds a GitHub action that runs the PyTest suite including the
  generation of a code coverage report
- Amends coverage config file to account for code areas that don't
  require testing
- Amends pytest config file to suppress Django deprecation warning
- Add codecov.io badge to project's README

See also: #40
WayneLambert added a commit that referenced this issue Aug 3, 2020
The GitHub action's build failed on the previous commit because pip
couldn't find a `coverall` package. The `coverall` package is no longer
required since I'm favouring codecov.io

Amends the following:

- Removes the requirement for pip to install `coverall`
- Adds a command to upgrade pip before installing additional packages

See also: #40
WayneLambert added a commit that referenced this issue Aug 3, 2020
The GitHub action's build failed on the previous commit because pip
didn't recognise the commands for `django-factoryboy` and `hypothesis`
without the preceding `install` keyword.

Adds the following:

- `install` keyword for the `django-factoryboy` package
- `install` keyword for the `hypothesis` package

See also: #40
WayneLambert added a commit that referenced this issue Sep 14, 2020
Addresses the following:

- Refactors the validations code
- Improves docstrings
- Increases test coverage with the `validations.py` code
- Increases test coverage with the `logic.py` code
- Removes unnecessary additional templates
- Local test coverage now stands at 93%

Develops: #40
WayneLambert added a commit that referenced this issue Sep 14, 2020
Addresses the following:

- Removes unnecessary additional templates in Countdown Letters app
- Increases test coverage and tests more scenarios with parametrization
- Removes a test to an external link that fails on the CI test run. When
  tested manually, the linked does successfully GET
- Local test coverage now stands at 94%

Develops: #40
@WayneLambert WayneLambert reopened this Sep 18, 2020
WayneLambert added a commit that referenced this issue Sep 20, 2020
The blog's search feature requires development to be more user-friendly
and more presentable.

Addresses the following:

- Develops search to full word search rather than part of word. This
  returns less results but more relevant.
- Make the search bar full width, removes the search button and adds
  autofocus to facilitate faster searching.
- Removes redundant templates
- Renames some templates, views and URL paths to be more reflective of
  their functionality/featureset
- Adds search page with just the search bar
- Tweak blog README
- Adjusts a few tests for the blog's URLs and views.
- Tweaks other pytest config including fixtures and docstrings

Develops: #72
Linked Issue: #40
@WayneLambert
Copy link
Owner Author

WayneLambert commented Sep 20, 2020

Previously, I had an issue running tests with pytest-xdist. I thought it was something to do with me running my tests within a Docker container, however after reading the CHANGELOG which said:

v3.10.0 (2020-08-25)
Improvements

  • Officialy support Django 3.1
  • Preliminary supoprt for upcoming Django 3.2
  • Support for pytest-xdist 2.0

I can use pytest-xdist with many processors. With optimisations in my tests, I can now run a test suite a 448 tests in 42 seconds.

Run with -n 0 flag if running a small suite and the setup would take longer. This essentially disables pytest-xdist.

WayneLambert added a commit that referenced this issue Sep 20, 2020
Addresses the following:

- Increases test coverage
- Adds config for using `pytest-xdist` and speeds up full test suite

Develops: #40
WayneLambert added a commit that referenced this issue Sep 20, 2020
Addresses the following:

- Update test for looking up invalid word from Oxford Online API within
  the Countdown Letters Game app

Develops: #40
WayneLambert added a commit that referenced this issue Sep 21, 2020
Addresses the following:

- Updates font formats in Tiny MCE config
- Updates location for default blog image
- Updates feeds for posts and categories
- Tweaks sitemap
- Adds bleach dependency
- Updates pytest config

Test Issue: #40
WayneLambert added a commit that referenced this issue Sep 23, 2020
Addresses the following:

- Abstracts the main logic for all views into a model manager removing
  repitition in the blog's views
- Uses the model manager across the project within the `api`, `blog`
  and `pages` apps
- Adjusts views and template config to remove all duplicate queries for
  all views
- Adjusts `sitemap.py` to account for published model manager
- Adjusts `feeds.py` to account for published model manager
- Check any failing tests and update any requiring logic changes
- Updates the admin to display `id` for the models since I use it in
  development and don't necessarily want to open the interpreter or
  DataGrip to see the id/pk all of the time
- Adjust manage.py to take advantage of Rich's pretty printing in
  development config
- Tweak Docker config for column width of my screen

Tests Issue Ref: #40
Related Issue: #72
Blog Documentation Update: #15
WayneLambert added a commit that referenced this issue Sep 29, 2020
Addresses the following:

- Updates database fixtures to use deterministic settings since the
  testing Postgres database checks for unique key violations
- Moves some arrangement logic back into the tests which were previously
  contained within the fixtures, which in my opinion, was an abstraction
  too far. This made the AAA pattern of the test itself less obvious
- Removes some tests which were not testing the database behaviour that
  I had originally thought. Switching to Postgres with its strict
  checking helped uncover these mistaken assumptions
- Since email addresses can contain uppercased characters, changed the
  form's clean method to allow this
- Improves some of the docstrings for the tests and fixtures

Develops: #40
WayneLambert added a commit that referenced this issue Sep 29, 2020
Ensures the pytest cache is cleared upon a CI test run

Ref: #40
WayneLambert added a commit that referenced this issue Sep 29, 2020
* Update Django Debug Toolbar

Addresses the following:

- Update Django Debug Toolbar to version 3.1.1
- Removes static files from version 2.2
- Collects static from version 3.1.1

* Update project packages and dependencies

* Update About Me page

Addresses the following:

- Improves the copy for the page

* Update Rich config

Addresses the following:

- Adds config to enable a friendly traceback within the terminal which
  is useful for reading tracebacks more quickly

* Add test database for Postgres

Addresses the following:

- Add a new container to the Docker develpment setup that includes a
  Postgres database on a `tmpfs` volume for testing purposes
- Update Postgres to use version 11.9 (matching Heroku's updated version)
- Add `django.contrib.postgres` to installed apps to take advantage of
  Postgres specific search features  #72

* Develop search feature

Addresses the following:

Adds Postgres specific search functionality which includes:

- Cleans unwanted characters and whitespace from user's search input
- Uses stemmed keywords
- Removes stop words
- Adds message if user does not submit any search string
- Implements relevancy and search ranking
- Removes redundanct model method which returned resultset that can is
  now obtained from a model manager

Some HTML templates have also been tidied up.

* Develop users app

Addresses the following:

- Changes the primary key setup for the Profile model so that it uses
  the `users` field which is naturally unique because it's the foreign
  key field on the `auth_user` table and its a one-to-one relationship
- Moves the saving of a new profile away from the form
- Simplified `ProfileView` by amalgamating functionality of previous
  `get` and `get_context_data` methods into a single `get_object`
  method
- Removes unrequired `get_success_url` method and uses a `reverse_lazy`
  implementation instead. Also simplifies testing requirement
- Restructures the views to be more logically ordered

* Update test suite

Addresses the following:

- Updates database fixtures to use deterministic settings since the
  testing Postgres database checks for unique key violations
- Moves some arrangement logic back into the tests which were previously
  contained within the fixtures, which in my opinion, was an abstraction
  too far. This made the AAA pattern of the test itself less obvious
- Removes some tests which were not testing the database behaviour that
  I had originally thought. Switching to Postgres with its strict
  checking helped uncover these mistaken assumptions
- Since email addresses can contain uppercased characters, changed the
  form's clean method to allow this
- Improves some of the docstrings for the tests and fixtures

Develops: #40

* Add cache clear to CI test run

Ensures the pytest cache is cleared upon a CI test run

Ref: #40
@github-actions
Copy link
Contributor

github-actions bot commented Oct 2, 2020

This issue is stale since it has been open for 10 days without any activity. If the 'Stale Issue' label hasn't been removed or a comment made on the issue, it will be closed after 5 days of inactivity.

WayneLambert added a commit that referenced this issue Oct 5, 2020
Attempts the following:

- Adds a postgres service to the workflow in an attempt to initialise a
  Postgres instance using the temporary file system to enable the pytest
  runner to run the CI tests using Postgres

Ref Issue: #40
WayneLambert added a commit that referenced this issue Oct 5, 2020
Attempts the following:

- Adds a postgres service to the workflow in an attempt (#2) to
  initialise a Postgres instance using the temporary file system to
  enable the pytest runner to run the CI tests using Postgres

Ref Issue: #40
WayneLambert added a commit that referenced this issue Oct 5, 2020
Attempts the following:

- Adds a postgres service to the workflow in an attempt (#3) to
  initialise a Postgres instance using the temporary file system to
  enable the pytest runner to run the CI tests using Postgres

Ref Issue: #40
WayneLambert added a commit that referenced this issue Oct 5, 2020
Attempts the following:

- Adds a postgres service to the workflow in an attempt (#4) to
  initialise a Postgres instance using the temporary file system to
  enable the pytest runner to run the CI tests using Postgres

Ref Issue: #40
WayneLambert added a commit that referenced this issue Oct 5, 2020
Attempts the following:

- Adds a postgres service to the workflow in an attempt (#5) to
  initialise a Postgres instance using the temporary file system to
  enable the pytest runner to run the CI tests using Postgres

Ref Issue: #40
WayneLambert added a commit that referenced this issue Oct 5, 2020
Attempts the following:

- Adds a postgres service to the workflow in an attempt (#6) to
  initialise a Postgres instance using the temporary file system to
  enable the pytest runner to run the CI tests using Postgres

Ref Issue: #40
WayneLambert added a commit that referenced this issue Oct 5, 2020
Attempts the following:

- Adds a postgres service to the workflow in an attempt (#7) to
  initialise a Postgres instance using the temporary file system to
  enable the pytest runner to run the CI tests using Postgres

Ref Issue: #40
@WayneLambert
Copy link
Owner Author

The GitHub Action for the testing needs to be configured. The tests are running and passing which do not require the database, however the tests seemingly don't have the proper authentication for the test Postgres database. It seems that the environment variables are not set up correctly.

@github-actions
Copy link
Contributor

This issue is stale since it has been open for 10 days without any activity. If the 'Stale Issue' label hasn't been removed or a comment made on the issue, it will be closed after 5 days of inactivity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Stale Issue tests Tests to verify project functionality
Projects
None yet
Development

No branches or pull requests

1 participant