From f234ef2d8662348831f2d7616a978552e7d600a5 Mon Sep 17 00:00:00 2001 From: Injoon Hwang Date: Sat, 5 Aug 2023 14:36:00 +0000 Subject: [PATCH] fix(test): fix tests to run in prod env --- tests/test_articles.py | 4 ++-- tests/test_communication_article.py | 4 +--- tests/test_home.py | 11 ++++++----- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/tests/test_articles.py b/tests/test_articles.py index a2e29858..f522df3a 100644 --- a/tests/test_articles.py +++ b/tests/test_articles.py @@ -863,8 +863,8 @@ def test_update_realname_article(self): assert Article.objects.get(title=new_title).name_type == NameType.REALNAME def test_ban_vote_cancellation_after_30(self): - # SCHOOL_RESPONSE_VOTE_THRESHOLD is 3 in test - users = [self.user, self.user2] + users = Utils.create_users(num=SCHOOL_RESPONSE_VOTE_THRESHOLD - 1) + for user in users: self.http_request( user, "post", f"articles/{self.realname_article.id}/vote_positive" diff --git a/tests/test_communication_article.py b/tests/test_communication_article.py index bd44fee5..ffbc4a1b 100644 --- a/tests/test_communication_article.py +++ b/tests/test_communication_article.py @@ -5,7 +5,6 @@ import pytest from django.utils import timezone from rest_framework.status import HTTP_200_OK, HTTP_400_BAD_REQUEST -from rest_framework.test import APIClient from apps.core.models import Article, Board from apps.core.models.board import NameType @@ -14,8 +13,7 @@ SchoolResponseStatus, ) from apps.user.models import UserProfile -from ara.settings import ANSWER_PERIOD, MIN_TIME -from ara.settings.dev import SCHOOL_RESPONSE_VOTE_THRESHOLD +from ara.settings import ANSWER_PERIOD, MIN_TIME, SCHOOL_RESPONSE_VOTE_THRESHOLD from .conftest import RequestSetting, TestCase, Utils diff --git a/tests/test_home.py b/tests/test_home.py index 839f5df9..77092622 100644 --- a/tests/test_home.py +++ b/tests/test_home.py @@ -1,13 +1,14 @@ import pytest +from rest_framework import status from tests.conftest import RequestSetting, TestCase @pytest.mark.usefixtures("set_user_client") class TestHome(TestCase, RequestSetting): - def test_board_perm(self): - r = self.http_request(self.user, "get", "home") - assert r.status_code == 200 + def test_board_permission(self): + res = self.http_request(self.user, "get", "home") + assert res.status_code == status.HTTP_200_OK - r = self.http_request(None, "get", "home") - assert r.status_code == 401 + res = self.http_request(None, "get", "home") + assert res.status_code == status.HTTP_401_UNAUTHORIZED