Skip to content

Commit

Permalink
test: add tests for download bot zip / data
Browse files Browse the repository at this point in the history
  • Loading branch information
lladdy committed Dec 23, 2024
1 parent 0259567 commit 9d54c7b
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions aiarena/api/tests/test_bot_view_set.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from django.test import TestCase
from rest_framework.test import APIClient

from aiarena.core.tests.test_mixins import MatchReadyMixin


from django.urls import reverse
class BotSerializerTestCase(MatchReadyMixin, TestCase):
def test_download_bot_zip_success(self):
"""
Note that this test is for essentially a defunct feature. Downloads would be via AWS S3.
"""
self.client = APIClient()
self.client.force_authenticate(user=self.regularUser1)
bot = self.regularUser1Bot1 # owned by the current user

# URL base name for BotViewSet is api_bot, action url_path is zip
self.url = reverse("api_bot-download-zip", kwargs={"pk": bot.id})
response = self.client.get(self.url)
self.assertEqual(response.status_code, 200)

def test_download_bot_zip_unauthorized(self):
"""
Note that this test is for essentially a defunct feature. Downloads would be via AWS S3.
"""
self.client = APIClient()
self.client.force_authenticate(user=self.regularUser1)
bot = self.staffUser1Bot1 # owned by someone else

# URL base name for BotViewSet is api_bot, action url_path is zip
self.url = reverse("api_bot-download-zip", kwargs={"pk": bot.id})
response = self.client.get(self.url)
self.assertEqual(response.status_code, 404)

0 comments on commit 9d54c7b

Please sign in to comment.