Skip to content

Commit

Permalink
Merge pull request #404 from sparcs-kaist/develop
Browse files Browse the repository at this point in the history
Fix tests to use appropriate environment variables
  • Loading branch information
injoonH authored Aug 5, 2023
2 parents 5797c3c + c42bfdf commit abe95c0
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 15 deletions.
5 changes: 0 additions & 5 deletions ara/settings/dev/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,3 @@
SCHOOL_RESPONSE_VOTE_THRESHOLD = 3
ANSWER_PERIOD = 14
MIN_TIME = datetime.min.replace(tzinfo=timezone.utc)

try:
from .local_settings import *
except ImportError:
pass
1 change: 1 addition & 0 deletions ara/settings/prod/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
]

REST_FRAMEWORK["DEFAULT_AUTHENTICATION_CLASSES"] = (
"rest_framework.authentication.BasicAuthentication",
"rest_framework.authentication.SessionAuthentication",
)

Expand Down
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 abe95c0

Please sign in to comment.