# Path: kobra/factories.py
# class DiscountFactory(factory.DjangoModelFactory):
#     ticket_type = factory.SubFactory(TicketTypeFactory)
#     union = factory.Iterator(Union.objects.all())
#     amount = factory.fuzzy.FuzzyInteger(5, 30)
# 
#     class Meta:
#         model = Discount
# 
# class DiscountRegistrationFactory(factory.DjangoModelFactory):
#     discount = factory.SubFactory(DiscountFactory)
#     student = factory.SubFactory(StudentFactory)
# 
#     class Meta:
#         model = DiscountRegistration
# 
# class TicketTypeFactory(factory.DjangoModelFactory):
#     name = factory.Faker('word')
#     event = factory.SubFactory(EventFactory)
# 
#     class Meta:
#         model = TicketType
# 
# class UserFactory(factory.DjangoModelFactory):
#     name = factory.Faker('name')
# 
#     email = factory.Faker('email')
# 
#     class Meta:
#         model = settings.AUTH_USER_MODEL


from rest_framework import status
from rest_framework.reverse import reverse
from rest_framework.test import APITestCase
from ....factories import (DiscountFactory, DiscountRegistrationFactory,
                           TicketTypeFactory, UserFactory)
        url = reverse('v1:discount-detail', kwargs={'pk': discount.pk})

        self.client.force_authenticate(user)
        response = self.client.delete(url)
        self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)

    def test_delete_authenticated_unowned_with_registrations(self):
        user = UserFactory()
        discount = DiscountFactory()
        DiscountRegistrationFactory(discount=discount)
        url = reverse('v1:discount-detail', kwargs={'pk': discount.pk})

        self.client.force_authenticate(user)
        response = self.client.delete(url)
        self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)

    def test_delete_authenticated_owned_without_registrations(self):
        user = UserFactory()
        discount = DiscountFactory()
        discount.ticket_type.event.organization.admins.add(user)
        url = reverse('v1:discount-detail', kwargs={'pk': discount.pk})

        self.client.force_authenticate(user)
        response = self.client.delete(url)
        self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)

    def test_delete_authenticated_owned_with_registrations(self):
        user = UserFactory()
        discount = DiscountFactory()
        discount.ticket_type.event.organization.admins.add(user)

# Path: kobra/factories.py
# class DiscountFactory(factory.DjangoModelFactory):
#     ticket_type = factory.SubFactory(TicketTypeFactory)
#     union = factory.Iterator(Union.objects.all())
#     amount = factory.fuzzy.FuzzyInteger(5, 30)
# 
#     class Meta:
#         model = Discount
# 
# class DiscountRegistrationFactory(factory.DjangoModelFactory):
#     discount = factory.SubFactory(DiscountFactory)
#     student = factory.SubFactory(StudentFactory)
# 
#     class Meta:
#         model = DiscountRegistration
# 
# class TicketTypeFactory(factory.DjangoModelFactory):
#     name = factory.Faker('word')
#     event = factory.SubFactory(EventFactory)
# 
#     class Meta:
#         model = TicketType
# 
# class UserFactory(factory.DjangoModelFactory):
#     name = factory.Faker('name')
# 
#     email = factory.Faker('email')
# 
#     class Meta:
#         model = settings.AUTH_USER_MODEL


# Path: kobra/api/v1/tests/test_discounts.py
from rest_framework import status
from rest_framework.reverse import reverse
from rest_framework.test import APITestCase
from ....factories import (DiscountFactory, DiscountRegistrationFactory,
                           TicketTypeFactory, UserFactory)

        url = reverse('v1:discount-detail', kwargs={'pk': discount.pk})

        self.client.force_authenticate(user)
        response = self.client.delete(url)
        self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)

    def test_delete_authenticated_unowned_with_registrations(self):
        user = UserFactory()
        discount = DiscountFactory()
        DiscountRegistrationFactory(discount=discount)
        url = reverse('v1:discount-detail', kwargs={'pk': discount.pk})

        self.client.force_authenticate(user)
        response = self.client.delete(url)
        self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)

    def test_delete_authenticated_owned_without_registrations(self):
        user = UserFactory()
        discount = DiscountFactory()
        discount.ticket_type.event.organization.admins.add(user)
        url = reverse('v1:discount-detail', kwargs={'pk': discount.pk})

        self.client.force_authenticate(user)
        response = self.client.delete(url)
        self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)

    def test_delete_authenticated_owned_with_registrations(self):
        user = UserFactory()
        discount = DiscountFactory()
        discount.ticket_type.event.organization.admins.add(user)

        DiscountRegistrationFactory(discount=discount)