Skip to content

Commit

Permalink
disable add/edit/delete on v1 (#748)
Browse files Browse the repository at this point in the history
[#188514696]
  • Loading branch information
uraniumanchor authored Jan 4, 2025
1 parent ba7a091 commit b7d9f44
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 1,244 deletions.
563 changes: 0 additions & 563 deletions tests/test_api.py

Large diffs are not rendered by default.

7 changes: 0 additions & 7 deletions tests/test_auth.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import urllib.parse
from unittest import skipIf

import django
import post_office.models
from django.contrib.auth import get_user_model
from django.test import RequestFactory, TestCase, override_settings
Expand Down Expand Up @@ -73,11 +71,6 @@ def test_register_inactive_user(self):
)
self.assertContains(resp, 'An e-mail has been sent to your address.')

# TODO: remove skip when 3.2 no longer supported
@skipIf(
django.VERSION < (4, 1),
'assertFormError requires response object until Django 4.1',
)
def test_register_active_user(self):
AuthUser.objects.create(
username='existinguser', email='[email protected]', is_active=True
Expand Down
149 changes: 0 additions & 149 deletions tests/test_interstitial.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,155 +112,6 @@ def test_interstitials_for_run(self):
}
)

def test_move_interstitial_up_within_run(self):
i1 = models.Interstitial.objects.create(
event=self.event1, order=self.run2.order, suborder=1
)
i2 = models.Interstitial.objects.create(
event=self.event1, order=self.run2.order, suborder=2
)
i3 = models.Interstitial.objects.create(
event=self.event1, order=self.run2.order, suborder=3
)
self.client.force_login(self.superuser)
resp = self.client.post(
reverse('tracker:api_v1:interstitial'),
{
'id': i3.id,
'order': self.run2.order,
'suborder': i2.suborder,
},
)
self.assertEqual(resp.status_code, 200)
self.assertInterstitialOrder({self.run2: [i1, i3, i2]})

def test_move_interstitial_down_within_run(self):
i1 = models.Interstitial.objects.create(
event=self.event1, order=self.run2.order, suborder=1
)
i2 = models.Interstitial.objects.create(
event=self.event1, order=self.run2.order, suborder=2
)
i3 = models.Interstitial.objects.create(
event=self.event1, order=self.run2.order, suborder=3
)
self.client.force_login(self.superuser)
resp = self.client.post(
reverse('tracker:api_v1:interstitial'),
{
'id': i1.id,
'order': self.run2.order,
'suborder': i2.suborder,
},
)
self.assertEqual(resp.status_code, 200)
self.assertInterstitialOrder({self.run2: [i2, i1, i3]})

def test_move_interstitial_up_between_run(self):
i1 = models.Interstitial.objects.create(
event=self.event1, order=self.run2.order, suborder=1
)
i2 = models.Interstitial.objects.create(
event=self.event1, order=self.run2.order, suborder=2
)
i3 = models.Interstitial.objects.create(
event=self.event1, order=self.run2.order, suborder=3
)
i4 = models.Interstitial.objects.create(
event=self.event1, order=self.run3.order, suborder=1
)
i5 = models.Interstitial.objects.create(
event=self.event1, order=self.run3.order, suborder=2
)
i6 = models.Interstitial.objects.create(
event=self.event1, order=self.run3.order, suborder=3
)
self.client.force_login(self.superuser)
resp = self.client.post(
reverse('tracker:api_v1:interstitial'),
{
'id': i2.id,
'order': self.run3.order,
'suborder': i6.suborder,
},
)
self.assertEqual(resp.status_code, 200)
self.assertInterstitialOrder(
{
self.run2: [i1, i3],
self.run3: [i4, i5, i2, i6],
}
)

def test_move_interstitial_down_between_run(self):
i1 = models.Interstitial.objects.create(
event=self.event1, order=self.run2.order, suborder=1
)
i2 = models.Interstitial.objects.create(
event=self.event1, order=self.run2.order, suborder=2
)
i3 = models.Interstitial.objects.create(
event=self.event1, order=self.run2.order, suborder=3
)
i4 = models.Interstitial.objects.create(
event=self.event1, order=self.run3.order, suborder=1
)
i5 = models.Interstitial.objects.create(
event=self.event1, order=self.run3.order, suborder=2
)
i6 = models.Interstitial.objects.create(
event=self.event1, order=self.run3.order, suborder=3
)
self.client.force_login(self.superuser)
resp = self.client.post(
reverse('tracker:api_v1:interstitial'),
{
'id': i5.id,
'order': self.run2.order,
'suborder': i2.suborder,
},
)
self.assertEqual(resp.status_code, 200)
self.assertInterstitialOrder(
{
self.run2: [i1, i5, i2, i3],
self.run3: [i4, i6],
}
)

def test_move_interstitial_fill_holes(self):
i1 = models.Interstitial.objects.create(
event=self.event1, order=self.run2.order, suborder=1
)
i2 = models.Interstitial.objects.create(
event=self.event1, order=self.run2.order, suborder=3
)
i3 = models.Interstitial.objects.create(
event=self.event1, order=self.run2.order, suborder=5
)
i4 = models.Interstitial.objects.create(
event=self.event1, order=self.run3.order, suborder=3
)
i5 = models.Interstitial.objects.create(
event=self.event1, order=self.run3.order, suborder=7
)
self.client.force_login(self.superuser)
resp = self.client.post(
reverse('tracker:api_v1:interstitial'),
{
'id': i2.id,
'order': self.run3.order,
'suborder': -1,
},
)
self.assertEqual(resp.status_code, 200)
self.assertInterstitialOrder(
{
self.run2: [i1, i3],
self.run3: [i4, i5, i2],
}
)

# smoke test
def test_full_schedule(self):
ad = models.Ad.objects.create(
Expand Down
7 changes: 0 additions & 7 deletions tests/test_prize.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import datetime
import random
from decimal import Decimal
from unittest import skipIf
from unittest.mock import patch

import django
import post_office.models
from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME
from django.contrib.auth.models import User
Expand Down Expand Up @@ -1463,11 +1461,6 @@ def test_prize_key_import_action(self):
reverse('admin:tracker_prize_key_import', args=(self.prize_with_keys.id,)),
)

# TODO: remove skip when 3.2 no longer supported
@skipIf(
django.VERSION < (4, 1),
'assertFormError requires response object until Django 4.1',
)
def test_prize_key_import_form(self):
keys = ['dead-beef-dead-beef-123%d' % i for i in range(5)]
response = self.client.get(
Expand Down
10 changes: 0 additions & 10 deletions tests/test_speedrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
import random
import zoneinfo
from typing import Iterable, List, Optional, Union
from unittest import skipIf

import django
from django.contrib.auth.models import User
from django.core.exceptions import ValidationError
from django.test import TransactionTestCase
Expand Down Expand Up @@ -471,10 +469,6 @@ def test_start_run(self):
self.assertEqual(self.run3.anchor_time, expected_start)
self.assertEqual(self.run3.starttime, expected_start)

@skipIf(
django.VERSION < (4, 1),
'assertFormError requires response object until Django 4.1',
)
def test_invalid_time(self):
from tracker.admin.forms import StartRunForm

Expand All @@ -491,10 +485,6 @@ def test_invalid_time(self):
self.assertFalse(form.is_valid())
self.assertFormError(form, None, StartRunForm.Errors.invalid_start_time)

@skipIf(
django.VERSION < (4, 1),
'assertFormError requires response object until Django 4.1',
)
def test_anchor_drift(self):
from tracker.admin.forms import StartRunForm

Expand Down
123 changes: 0 additions & 123 deletions tests/test_viewutil.py

This file was deleted.

8 changes: 3 additions & 5 deletions tracker/api_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@
urlpatterns = [
path('', api.root, name='root'),
path('search/', api.search, name='search'),
path('add/', api.add, name='add'),
path('edit/', api.edit, name='edit'),
path('delete/', api.delete, name='delete'),
path('add/', api.gone, name='add'),
path('edit/', api.gone, name='edit'),
path('delete/', api.gone, name='delete'),
path('command/', api.command, name='command'),
path('me/', api.me, name='me'),
# moved over from private repo, stopgap until v2 is ready
path('ads/<int:event>/', api.ads, name='ads'),
path('interstitial/', api.interstitial_reorder, name='interstitial'),
path('interviews/<int:event>/', api.interviews, name='interviews'),
path('hosts/<int:event>/', api.hosts),
]
6 changes: 3 additions & 3 deletions tracker/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@
path('ipn/', donateviews.ipn, name='ipn'),
path('analytics/', analyticsviews.post_analytics, name='analytics'),
path('search/', api.search),
path('add/', api.add),
path('edit/', api.edit),
path('delete/', api.delete),
path('add/', api.gone),
path('edit/', api.gone),
path('delete/', api.gone),
path('command/', api.command),
path('me/', api.me, name='me'),
path('api/v1/', include(api_urls, namespace='api_v1')),
Expand Down
Loading

0 comments on commit b7d9f44

Please sign in to comment.