Skip to content

A place to go for all the insights regarding the artificial intelligence club at NC State.

Notifications You must be signed in to change notification settings

vyathakavilocana/AIatNCStateWebsite

Repository files navigation

AI at NC State Website

A one-stop website to find all news, updates, and much more regarding the Artificial Intelligence Club at North Carolina State University.

Table of Contents

Development

Getting Started

Install Docker and Docker-Compose or make sure they are updated to the latest version if they are already installed. Build and start the development Docker containers with the following command:

docker compose up --build

If all works well, you should be able to create an admin account with:

docker compose run --rm backend python manage.py createsuperuser

Loading Development Database Fixtures

docker compose run --rm backend python manage.py loaddata dev-fixtures.json

Dumping Development Database Fixtures

docker compose run --rm backend python manage.py dumpdata --exclude=auth --exclude=contenttypes --exclude=admin --exclude=sessions --exclude=users -o dev-fixtures.json

Backend Testing

Running All Backend Tests

You can run all the backend unit tests at once with the following command:

docker compose run --rm backend coverage run manage.py test

There is also a helper script which runs all the unit tests which can be executed with the following command:

docker compose run --rm backend /test.sh

Additionally, if you would like to skip generating an HTML coverage report, you can do so by including the --no-html option (-nh for short) like so:

docker compose run --rm backend /test.sh --no-html

Running a Subset of Backend Tests

Every backend unit test should be decorated with the Django tag decorator to enable the running of smaller subsets tests that are common in some way. Tags should be defined as attributes of the Tags enumeration in the core.testcases module. The following is an example of tagging a test:

from core.testcases import Tags, VerboseTestCase

class ExampleTestCase(VerboseTestCase):
    @tag(Tags.MODEL)
    def test_model_example(self):
        self.fail('Not yet implemented.')

Following from this example, in order to only run units tests with the MODEL tag, you can run the following command:

docker compose run --rm backend python manage.py test --tag=model

Note that you use the enumeration member value 'model' rather than the name of the member MODEL. Also note that coverage cannot be used when running tests in this manner.

For more complex usage of Django tags (e.g., tagging a test with multiple tags, and excluding tests by tag when running tests) please refer to the official documentation.

Generating Test Coverage Reports

In order to view the test coverage breakdown of the most recent test execution, run the following command after doing a full run of all the tests:

docker compose run --rm backend coverage report

Alternatively, if you wish to view a more detailed breakdown of the test coverage report, you can generate an HTML version of the report which allows you to explore which lines of code were run, missed or excluded. First, run the following command:

docker compose run --rm backend coverage html

Then, open the generated index.html file in the backend/htmlcov directory with your preferred web browser.

Convenience Shell Script

There is a shell script included in the backend/scripts directory to make running all of the backend unit tests and generating an HTML coverage report more convenient. The script can be run with the following command:

docker compose run --rm backend /test.sh

You can also use the optional --no-html (shorthand -nh) command-line argument if you want to skip generating an HTML coverage report. For example:

docker compose run --rm backend /test.sh -nh

Frontend Testing

TODO

About

A place to go for all the insights regarding the artificial intelligence club at NC State.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published