Skip to content

Commit

Permalink
fix(test): fix tests to run in prod env
Browse files Browse the repository at this point in the history
  • Loading branch information
injoonH committed Aug 5, 2023
1 parent 671c9eb commit f234ef2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
4 changes: 2 additions & 2 deletions tests/test_articles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 1 addition & 3 deletions tests/test_communication_article.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
11 changes: 6 additions & 5 deletions tests/test_home.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit f234ef2

Please sign in to comment.