Fix friend_code max length issues in tests, and fix in_game_name length issues, also update tests to fit more scenarios

This commit is contained in:
badblocks 2025-03-27 17:26:07 -07:00
parent 0d4655bf80
commit b9c4d7a61d
10 changed files with 558 additions and 66 deletions

View file

@ -12,6 +12,7 @@ from accounts.models import FriendCode
from accounts.forms import FriendCodeForm, CustomUserCreationForm, UserSettingsForm
from accounts.templatetags import gravatar
from trades.models import TradeOffer
from tests.utils.rarity import RARITY_MAPPING
# Create your tests here.
@ -415,11 +416,11 @@ class FriendCodeViewsTests(TestCase):
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
# POST request.
new_data = {"in_game_name": "UpdatedViewGame"}
new_data = {"in_game_name": "UpdatedGame"}
response = self.client.post(url, new_data)
self.assertEqual(response.status_code, 302)
self.friend_code2.refresh_from_db()
self.assertEqual(self.friend_code2.in_game_name, "UpdatedViewGame")
self.assertEqual(self.friend_code2.in_game_name, "UpdatedGame")
def test_edit_friend_code_view_wrong_user(self):
"""A user should not be able to edit a friend code that does not belong to them."""
@ -490,7 +491,7 @@ class FriendCodeViewsTests(TestCase):
self.trade_offer = TradeOffer.objects.create(
initiated_by=self.friend_code2,
is_closed=False,
rarity_icon="⭐️",
rarity_icon=RARITY_MAPPING[5],
rarity_level=5
)
url = reverse("delete_friend_code", kwargs={"pk": self.friend_code2.pk})