diff --git a/.github/workflows/django_test.yml b/.github/workflows/django_test.yml new file mode 100644 index 0000000..a1c49a7 --- /dev/null +++ b/.github/workflows/django_test.yml @@ -0,0 +1,32 @@ +name: Django CI + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + max-parallel: 4 + matrix: + python-version: [3.11] + + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: Install Dependencies + run: | + python -m pip install --upgrade pip + cd api + pip install -r requirements.txt + - name: Run Tests + run: | + cd api + python manage.py test diff --git a/api/masteriqapp/tests/test_models.py b/api/masteriqapp/tests/test_models.py index d917514..32018f0 100644 --- a/api/masteriqapp/tests/test_models.py +++ b/api/masteriqapp/tests/test_models.py @@ -28,11 +28,11 @@ def test_use_model(self): iq_test = IQ.objects.create(user=user_test, category=category_test, iq=100) - assert len(Category.objects.filter(name="Test")) == 1 - assert len(Question.objects.filter(text="Yes or No?")) == 1 - assert len(Option.objects.filter(text="Yes")) == 1 - assert len(Option.objects.all()) >= 2 - assert len(User.objects.filter(username="test")) == 1 + assert Category.objects.get(id=category_test.id).name == category_test.name + assert Question.objects.get(id=question_test.id).text == question_test.text + assert Option.objects.get(id=option_1.id).text == option_1.text + assert len(Option.objects.filter(question=question_test)) == 2 + assert User.objects.get(id=user_test.id).username == user_test.username assert len(IQ.objects.filter(user=user_test, category=category_test)) == 1 def test_use_manager(self):