-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add tests for download bot zip / data
- Loading branch information
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|