def test_correct_input(self):
        """
        update_festival_info() is to return a list of the modified fields
        Festival is to be modified
        """

        user = login(self.client)
        client = create_client('test')
        client.write_access = True
        client.save()

        festival = create_festival('test', user)
        festival.save()
        concert = create_concert(festival, 'test')
        concert.save()

        response = self.client.post('/backend/u/conc/',
                                    {'client': 'test',
                                     'id': concert.pk,
                                     'stage': 2,
                                     'artist': 'tset'
                                     })

        self.assertEqual(response.status_code, 200)
        response_string = response.content.decode('utf-8')
        self.assertTrue('artist:tset' in response_string)
        self.assertTrue('stage:2' in response_string)
        self.assertEqual(3, len(response_string.split('\n')))
        self.assertEqual(1, Concert.objects.filter(festival=festival, artist='tset').count())
示例#2
0
    def test_invalid_fields(self):
        """
        update_festival_info() is to return "Incorrect input" if fields are input with wrong data
        """

        user = login(self.client)
        client = create_client('test')
        client.write_access = True
        client.save()

        festival = create_festival('test', user)
        festival.save()

        response = self.client.post(
            '/backend/u/fest/', {
                'client': 'test',
                'id': festival.pk,
                'name': 'test',
                'description': 'test',
                'country':
                'impossiblylongandabsurdnameforacountrythatreallyshouldntexist',
                'city': 'test',
                'address': 'test',
                'genre': 'test',
                'prices': '0e',
                'owner': 'test',
                'official': False
            })
        self.assertEqual(response.status_code, 200)
        self.assertEqual('Incorrect input', response.content.decode('utf-8'))
        festival = Festival.objects.get(pk=festival.pk)
        self.assertEqual('test', festival.country)
    def test_invalid_fields(self):
        """
        write_concert_info() is to return "Incorrect input" if fields are input with wrong data
        """

        login(self.client)
        client = create_client('test')
        client.write_access = True
        client.save()

        festival = create_festival('test', create_user())
        festival.save()

        response = self.client.post('/backend/w/conc/',
                                    {'client': 'test',
                                     'festival': festival.pk,
                                     'artist':
                                         'testtestsetsetsetsetse\
                                         tsetsetsetsetsetsetsetsetsetsetsetsetsetsetsetsetsetsetsetstsetsetsetset\
                                         testsetsetsetestestsetsetsetstsetsetsetsetsetsetsetsetsetsetsetsetsetstset\
                                         testetsetsetsettestsetsetsetsetsetsetsetsetsetsetsetsetsetsetsetsetsetsett',
                                     'start': (timezone.datetime.utcnow() +
                                               timezone.timedelta(days=2,
                                                                  hours=1)).timestamp(),
                                     'end': (timezone.datetime.utcnow() +
                                             timezone.timedelta(days=2,
                                                                hours=2)).timestamp()})
        self.assertEqual(response.status_code, 200)
        self.assertEqual('Incorrect input', response.content.decode('utf-8'))
        self.assertFalse(Concert.objects.filter(festival=festival).exists())
    def test_invalid_fields(self):
        """
        update_concert_info() is to return "Incorrect input" if fields are input with wrong data
        """

        user = login(self.client)
        client = create_client('test')
        client.write_access = True
        client.save()

        festival = create_festival('test', user)
        festival.save()
        concert = create_concert(festival, 'test')
        concert.save()

        response = self.client.post('/backend/u/conc/',
                                    {'client': 'test',
                                     'id': concert.pk,
                                     'artist':
                                         'testtestsetsetsetsetse\
                                         tsetsetsetsetsetsetsetsetsetsetsetsetsetsetsetsetsetsetsetstsetsetsetset\
                                         testsetsetsetestestsetsetsetstsetsetsetsetsetsetsetsetsetsetsetsetsetstset\
                                         testetsetsetsettestsetsetsetsetsetsetsetsetsetsetsetsetsetsetsetsetsetsett'})
        self.assertEqual(response.status_code, 200)
        self.assertEqual('Incorrect input', response.content.decode('utf-8'))
        self.assertEqual(1, Concert.objects.filter(festival=festival, artist='test').count())
    def test_no_permissions(self):
        """
        write_concert_info() is to return "Permission not granted"
        if the permissions necessary are not granted
        """

        login(self.client)

        client = create_client('test')
        client.write_access = False
        client.save()
        festival = create_festival('test', create_user())
        festival.save()
        response = self.client.post(
            '/backend/w/conc/', {
                'client':
                'test',
                'festival':
                festival.pk,
                'artist':
                'test',
                'start':
                timezone.datetime.utcnow() +
                timezone.timedelta(days=2, hours=1),
                'end':
                timezone.datetime.utcnow() +
                timezone.timedelta(days=2, hours=2)
            })
        self.assertEqual(response.status_code, 200)
        self.assertEqual('Permission not granted',
                         response.content.decode('utf-8'))
    def test_duplication(self):
        """
        write_concert_info() is to return "Artist exists" if a concert entry with the same artist
        already exists
        """

        login(self.client)
        client = create_client('test')
        client.write_access = True
        client.save()

        festival = create_festival('test', create_user())
        festival.save()
        concert = create_concert(festival, 'test')
        concert.save()
        response = self.client.post(
            '/backend/w/conc/', {
                'client':
                'test',
                'festival':
                festival.pk,
                'artist':
                'test',
                'start': (timezone.datetime.utcnow() +
                          timezone.timedelta(days=2, hours=1)).timestamp(),
                'end': (timezone.datetime.utcnow() +
                        timezone.timedelta(days=2, hours=2)).timestamp()
            })
        self.assertEqual(response.status_code, 200)
        self.assertEqual('Artist exists', response.content.decode('utf-8'))
    def test_invalid_fields(self):
        """
        write_concert_info() is to return "Incorrect input" if fields are input with wrong data
        """

        login(self.client)
        client = create_client('test')
        client.write_access = True
        client.save()

        festival = create_festival('test', create_user())
        festival.save()

        response = self.client.post(
            '/backend/w/conc/', {
                'client':
                'test',
                'festival':
                festival.pk,
                'artist':
                'testtestsetsetsetsetse\
                                         tsetsetsetsetsetsetsetsetsetsetsetsetsetsetsetsetsetsetsetstsetsetsetset\
                                         testsetsetsetestestsetsetsetstsetsetsetsetsetsetsetsetsetsetsetsetsetstset\
                                         testetsetsetsettestsetsetsetsetsetsetsetsetsetsetsetsetsetsetsetsetsetsett',
                'start': (timezone.datetime.utcnow() +
                          timezone.timedelta(days=2, hours=1)).timestamp(),
                'end': (timezone.datetime.utcnow() +
                        timezone.timedelta(days=2, hours=2)).timestamp()
            })
        self.assertEqual(response.status_code, 200)
        self.assertEqual('Incorrect input', response.content.decode('utf-8'))
        self.assertFalse(Concert.objects.filter(festival=festival).exists())
    def test_correct_input(self):
        """
        update_festival_info() is to return a list of the modified fields
        Festival is to be modified
        """

        user = login(self.client)
        client = create_client('test')
        client.write_access = True
        client.save()

        festival = create_festival('test', user)
        festival.save()

        response = self.client.post('/backend/u/fest/',
                                    {'client': 'test',
                                     'id': festival.pk,
                                     'city': 'testest',
                                     'description': 'testestest'
                                     })

        self.assertEqual(response.status_code, 200)
        response_string = response.content.decode('utf-8')
        self.assertTrue('city:testest\n' in response_string)
        self.assertTrue('description:testestest\n' in response_string)
        self.assertEqual(3, len(response_string.split('\n')))
        festival = Festival.objects.get(pk=festival.pk)
        self.assertEqual('testest', festival.city)
    def test_correct_input(self):
        """
        write_concert_info() is to return "OK" if information is successfully added.
        A new concert instance is to be created
        """

        login(self.client)
        client = create_client('test')
        client.write_access = True
        client.save()

        festival = create_festival('test', create_user())
        festival.save()

        response = self.client.post(
            '/backend/w/conc/', {
                'client':
                'test',
                'festival':
                festival.pk,
                'artist':
                'test',
                'start': (timezone.datetime.utcnow() +
                          timezone.timedelta(days=2, hours=1)).timestamp(),
                'end': (timezone.datetime.utcnow() +
                        timezone.timedelta(days=2, hours=2)).timestamp()
            })
        self.assertEqual(response.status_code, 200)
        self.assertEqual('OK', response.content.decode('utf-8'))
        self.assertTrue(Concert.objects.filter(artist='test').exists())
    def test_duplication(self):
        """
        write_concert_info() is to return "Artist exists" if a concert entry with the same artist
        already exists
        """

        login(self.client)
        client = create_client('test')
        client.write_access = True
        client.save()

        festival = create_festival('test', create_user())
        festival.save()
        concert = create_concert(festival, 'test')
        concert.save()
        response = self.client.post('/backend/w/conc/',
                                    {'client': 'test',
                                     'festival': festival.pk,
                                     'artist': 'test',
                                     'start': (timezone.datetime.utcnow() +
                                               timezone.timedelta(days=2,
                                                                  hours=1)).timestamp(),
                                     'end': (timezone.datetime.utcnow() +
                                             timezone.timedelta(days=2,
                                                                hours=2)).timestamp()})
        self.assertEqual(response.status_code, 200)
        self.assertEqual('Artist exists', response.content.decode('utf-8'))
    def test_correct_input(self):
        """
        write_concert_info() is to return "OK" if information is successfully added.
        A new concert instance is to be created
        """

        login(self.client)
        client = create_client('test')
        client.write_access = True
        client.save()

        festival = create_festival('test', create_user())
        festival.save()

        response = self.client.post('/backend/w/conc/',
                                    {'client': 'test',
                                     'festival': festival.pk,
                                     'artist': 'test',
                                     'start': (timezone.datetime.utcnow() +
                                               timezone.timedelta(days=2,
                                                                  hours=1)).timestamp(),
                                     'end': (timezone.datetime.utcnow() +
                                             timezone.timedelta(days=2,
                                                                hours=2)).timestamp()})
        self.assertEqual(response.status_code, 200)
        self.assertEqual('OK', response.content.decode('utf-8'))
        self.assertTrue(Concert.objects.filter(artist='test').exists())
    def test_invalid_fields(self):
        """
        update_festival_info() is to return "Incorrect input" if fields are input with wrong data
        """

        user = login(self.client)
        client = create_client('test')
        client.write_access = True
        client.save()

        festival = create_festival('test', user)
        festival.save()

        response = self.client.post('/backend/u/fest/',
                                    {'client': 'test',
                                     'id': festival.pk,
                                     'name': 'test',
                                     'description': 'test',
                                     'country':
                                         'impossiblylongandabsurdnameforacountrythatreallyshouldntexist',
                                     'city': 'test',
                                     'address': 'test',
                                     'genre': 'test',
                                     'prices': '0e',
                                     'owner': 'test',
                                     'official': False})
        self.assertEqual(response.status_code, 200)
        self.assertEqual('Incorrect input', response.content.decode('utf-8'))
        festival = Festival.objects.get(pk=festival.pk)
        self.assertEqual('test', festival.country)
示例#13
0
    def test_no_matching_festivals(self):
        """
        delete_festival() is to return "Invalid Festival ID" if festival is not found
        No festivals are to be deleted
        """

        user = login(self.client)

        client = create_client('test')
        client.delete_access = True
        client.save()

        festival = create_festival('test', user)
        festival.save()
        festival1 = create_festival('testest', user)
        festival1.save()
        festival2 = create_festival('testestest', user)
        festival2.save()
        response = self.client.post('/backend/d/fest/', {
            'client': 'test',
            'id': 15
        })
        self.assertEqual('Invalid Festival ID',
                         response.content.decode('utf-8'))
        self.assertEqual(3, Festival.objects.all().count())
示例#14
0
    def test_correct_input(self):
        """
        update_festival_info() is to return a list of the modified fields
        Festival is to be modified
        """

        user = login(self.client)
        client = create_client('test')
        client.write_access = True
        client.save()

        festival = create_festival('test', user)
        festival.save()

        response = self.client.post(
            '/backend/u/fest/', {
                'client': 'test',
                'id': festival.pk,
                'city': 'testest',
                'description': 'testestest'
            })

        self.assertEqual(response.status_code, 200)
        response_string = response.content.decode('utf-8')
        self.assertTrue('city:testest\n' in response_string)
        self.assertTrue('description:testestest\n' in response_string)
        self.assertEqual(3, len(response_string.split('\n')))
        festival = Festival.objects.get(pk=festival.pk)
        self.assertEqual('testest', festival.city)
 def test_query_existing_client(self):
     """
     if client_has_permission() is called with a name, relating to an
     existing client object, the corresponding Client object is to be queried
     """
     client = create_client('test')
     client.read_access = False
     client.save()
     num_before_count = Client.objects.all().count()
     permission = client_has_permission('test', 'read')
     num_after_count = Client.objects.all().count()
     self.assertEqual(num_before_count, num_after_count)
     self.assertFalse(permission)
    def test_no_permissions(self):
        """
        update_festival_info() should return "Permission not granted"
        if the permissions necessary are not granted
        """

        login(self.client)

        client = create_client('test')
        client.write_access = False
        client.save()
        response = self.client.post('/backend/u/fest/', {'client': 'test', 'id': 3})
        self.assertEqual(response.status_code, 200)
        self.assertEqual('Permission not granted', response.content.decode('utf-8'))
示例#17
0
    def test_festival_matches(self):
        """
        vote() is to return the number of voters for the festival if festival is found.
        Festival is to be upvoted before result
        """
        login(self.client)

        client = create_client('test')
        client.vote_access = True
        client.save()
        festival = create_festival('test', create_user())
        festival.save()
        response = self.client.post('/backend/v/', {'client': 'test', 'id': festival.pk})
        self.assertEqual(festival.voters_number(), int(response.content.decode('utf-8')))
    def test_no_permissions(self):
        """
        delete_concert() is to return "Permission not granted"
        if the permissions necessary are not granted
        """

        login(self.client)

        client = create_client('test')
        client.delete_access = False
        client.save()
        response = self.client.post('/backend/d/conc/', {'client': 'test', 'id': 0})
        self.assertEqual(response.status_code, 200)
        self.assertEqual('Permission not granted', response.content.decode('utf-8'))
    def test_no_permissions(self):
        """
        read_multiple_festivals() should return "Permission not granted"
        if the permissions necessary are not granted
        """

        login(self.client)

        client = create_client('test')
        client.read_access = False
        client.save()
        response = self.client.post('/backend/mult/fest/', {'client': 'test', 'num': 3})
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.content.decode('utf-8'), 'Permission not granted')
示例#20
0
    def test_missing_fields(self):
        """
        write_festival_info() is to return "Incorrect input" if necessary fields are missing
        """

        login(self.client)
        client = create_client('test')
        client.write_access = True
        client.save()

        response = self.client.post('/backend/w/fest/',
                                    {'client': 'test'})
        self.assertEqual(response.status_code, 200)
        self.assertEqual('Incorrect input', response.content.decode('utf-8'))
        self.assertFalse(Festival.objects.filter(name='test').exists())
示例#21
0
    def test_no_matching_festivals(self):
        """
        vote() is to return "Invalid Festival ID" if festival is not found
        no festivals are to be upvoted
        """

        login(self.client)

        client = create_client('test')
        client.vote_access = True
        client.save()
        festival = create_festival('test', create_user())
        festival.save()
        response = self.client.post('/backend/v/', {'client': 'test', 'id': 15})
        self.assertEqual('Invalid Festival ID', response.content.decode('utf-8'))
        self.assertEqual(0, festival.voters_number())
示例#22
0
    def test_no_permissions(self):
        """
        update_festival_info() should return "Permission not granted"
        if the permissions necessary are not granted
        """

        login(self.client)

        client = create_client('test')
        client.write_access = False
        client.save()
        response = self.client.post('/backend/u/fest/', {
            'client': 'test',
            'id': 3
        })
        self.assertEqual(response.status_code, 200)
        self.assertEqual('Permission not granted',
                         response.content.decode('utf-8'))
示例#23
0
    def test_festival_matches(self):
        """
        vote() is to return the number of voters for the festival if festival is found.
        Festival is to be upvoted before result
        """
        login(self.client)

        client = create_client('test')
        client.vote_access = True
        client.save()
        festival = create_festival('test', create_user())
        festival.save()
        response = self.client.post('/backend/v/', {
            'client': 'test',
            'id': festival.pk
        })
        self.assertEqual(festival.voters_number(),
                         int(response.content.decode('utf-8')))
示例#24
0
    def test_duplication(self):
        """
        write_festival_info() is to return "Name exists" if a festival entry with the same name
        already exists
        """

        login(self.client)
        client = create_client('test')
        client.write_access = True
        client.save()

        festival = create_festival('test', create_user())
        festival.save()
        response = self.client.post('/backend/w/fest/',
                                    {'client': 'test',
                                     'name': 'test'})
        self.assertEqual(response.status_code, 200)
        self.assertEqual('Name exists', response.content.decode('utf-8'))
    def test_no_permissions(self):
        """
        read_multiple_festivals() should return "Permission not granted"
        if the permissions necessary are not granted
        """

        login(self.client)

        client = create_client('test')
        client.read_access = False
        client.save()
        response = self.client.post('/backend/mult/fest/', {
            'client': 'test',
            'num': 3
        })
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.content.decode('utf-8'),
                         'Permission not granted')
    def test_not_owner(self):
        """
        update_festival_info() should return "Permission not granted"
        if the current user is different from the festival owner
        """
        creating_user = create_user()
        creating_user.save()
        festival = create_festival('test', creating_user)
        festival.save()

        login(self.client)

        client = create_client('test')
        client.delete_access = True
        client.save()

        response = self.client.post('/backend/u/fest/', {'client': 'test', 'id': 3})
        self.assertEqual(response.status_code, 200)
        self.assertEqual('Permission not granted', response.content.decode('utf-8'))
    def test_concert_found(self):
        """
        delete_festival() is to return "OK" if concert is found
        Concert is to be deleted
        """

        user = login(self.client)

        client = create_client('test')
        client.delete_access = True
        client.save()
        festival = create_festival('test', user)
        festival.save()
        concert = create_concert(festival, 'test')
        create_concert(festival, 'testest')
        create_concert(festival, 'testestest')
        response = self.client.post('/backend/d/conc/', {'client': 'test', 'id': concert.pk})
        self.assertEqual(response.status_code, 200)
        self.assertEqual('OK', response.content.decode('utf-8'))
        self.assertEqual(2, Concert.objects.all().count())
示例#28
0
    def test_no_matching_festivals(self):
        """
        vote() is to return "Invalid Festival ID" if festival is not found
        no festivals are to be upvoted
        """

        login(self.client)

        client = create_client('test')
        client.vote_access = True
        client.save()
        festival = create_festival('test', create_user())
        festival.save()
        response = self.client.post('/backend/v/', {
            'client': 'test',
            'id': 15
        })
        self.assertEqual('Invalid Festival ID',
                         response.content.decode('utf-8'))
        self.assertEqual(0, festival.voters_number())
    def test_no_matching_festivals(self):
        """
        update_festival_info() is to return "Invalid Festival ID" if festival is not found
        No festivals are to be updated
        """

        user = login(self.client)

        client = create_client('test')
        client.write_access = True
        client.save()

        festival = create_festival('test', user)
        festival.save()
        festival1 = create_festival('testest', user)
        festival1.save()
        festival2 = create_festival('testestest', user)
        festival2.save()
        response = self.client.post('/backend/u/fest/', {'client': 'test', 'id': 15})
        self.assertEqual('Invalid Festival ID', response.content.decode('utf-8'))
    def test_festival_matches(self):
        """
        delete_festival is to return "OK" if a festival is found. The festival found is to be
        deleted
        """

        user = login(self.client)

        client = create_client('test')
        client.delete_access = True
        client.save()

        festival1 = create_festival('test', user)
        festival1.save()
        festival2 = create_festival('testest', user)
        festival2.save()
        festival = create_festival('testestest', user)
        festival.save()
        response = self.client.post('/backend/d/fest/', {'client': 'test', 'id': festival.pk})
        self.assertEqual('OK', response.content.decode('utf-8'))
        self.assertEqual(2, Festival.objects.all().count())
    def test_not_uploader(self):
        """
        delete_concert() is to return "Permission not granted"
        if the uploader of the festival hosting the concert is different from the logged user
        """
        creating_user = create_user()

        festival = create_festival('test', creating_user)
        festival.save()

        concert = create_concert(festival, 'test')
        concert.save()

        login(self.client)

        client = create_client('test')
        client.delete_access = True
        client.save()
        response = self.client.post('/backend/d/conc/', {'client': 'test', 'id': concert.pk})
        self.assertEqual(response.status_code, 200)
        self.assertEqual('Permission not granted', response.content.decode('utf-8'))
    def test_no_concert_found(self):
        """
        delete_concert() is to return "Concert Not Found" if no concert is found
        No concerts are to be deleted
        """

        user = login(self.client)

        client = create_client('test')
        client.delete_access = True
        client.save()
        festival = create_festival('test', user)
        festival.save()
        create_concert(festival, 'test')
        create_concert(festival, 'testest')
        create_concert(festival, 'testestest')
        response = self.client.post('/backend/d/conc/',
                                    {'client': 'test', 'festival': festival.pk + 1, 'artist': 'asdf'})
        self.assertEqual(response.status_code, 200)
        self.assertEqual('Concert Not Found', response.content.decode('utf-8'))
        self.assertEqual(3, Concert.objects.all().count())
    def test_not_owner(self):
        """
        update_concert_info() should return "Permission not granted"
        if the current user is different from the owner of the festival hosting the concert
        """
        creating_user = create_user()
        creating_user.save()
        festival = create_festival('test', creating_user)
        festival.save()

        concert = create_concert(festival, 'test')
        concert.save()

        login(self.client)

        client = create_client('test')
        client.delete_access = True
        client.save()

        response = self.client.post('/backend/u/conc/', {'client': 'test', 'id': concert.pk})
        self.assertEqual(response.status_code, 200)
        self.assertEqual('Permission not granted', response.content.decode('utf-8'))
    def test_no_matching_concerts(self):
        """
        update_concert_info() is to return "Concert not found" if concert is not found
        No concerts are to be updated
        """

        user = login(self.client)

        client = create_client('test')
        client.write_access = True
        client.save()

        festival = create_festival('test', user)
        festival.save()
        concert1 = create_concert(festival, 'test')
        concert1.save()
        concert2 = create_concert(festival, 'testest')
        concert2.save()
        concert3 = create_concert(festival, 'testestest')
        concert3.save()
        response = self.client.post('/backend/u/conc/', {'client': 'test', 'id': -1})
        self.assertEqual('Concert Not Found', response.content.decode('utf-8'))
示例#35
0
    def test_no_permissions(self):
        """
        write_festival_info() is to return "Permission not granted"
        if the permissions necessary are not granted
        """

        login(self.client)

        client = create_client('test')
        client.write_access = False
        client.save()
        response = self.client.post('/backend/w/fest/', {'client': 'test',
                                                         'name': 'test',
                                                         'description': 'test',
                                                         'country': 'test',
                                                         'city': 'test',
                                                         'address': 'test',
                                                         'genre': 'test',
                                                         'prices': '0e',
                                                         'official': False})
        self.assertEqual(response.status_code, 200)
        self.assertEqual('Permission not granted', response.content.decode('utf-8'))
示例#36
0
    def test_not_uploader(self):
        """
        delete_festival() should return "Permission not granted"
        if the current user is different from the festival uploader
        """
        creating_user = create_user()
        creating_user.save()
        festival = create_festival('test', creating_user)
        festival.save()

        login(self.client)

        client = create_client('test')
        client.delete_access = True
        client.save()

        response = self.client.post('/backend/d/fest/', {
            'client': 'test',
            'id': festival.pk
        })
        self.assertEqual(response.status_code, 200)
        self.assertEqual('Permission not granted',
                         response.content.decode('utf-8'))
    def test_no_permissions(self):
        """
        write_concert_info() is to return "Permission not granted"
        if the permissions necessary are not granted
        """

        login(self.client)

        client = create_client('test')
        client.write_access = False
        client.save()
        festival = create_festival('test', create_user())
        festival.save()
        response = self.client.post('/backend/w/conc/', {'client': 'test',
                                                         'festival': festival.pk,
                                                         'artist': 'test',
                                                         'start': timezone.datetime.utcnow() +
                                                                  timezone.timedelta(days=2,
                                                                                     hours=1),
                                                         'end': timezone.datetime.utcnow() +
                                                                timezone.timedelta(days=2,
                                                                                   hours=2)})
        self.assertEqual(response.status_code, 200)
        self.assertEqual('Permission not granted', response.content.decode('utf-8'))
示例#38
0
    def test_festival_matches(self):
        """
        delete_festival is to return "OK" if a festival is found. The festival found is to be
        deleted
        """

        user = login(self.client)

        client = create_client('test')
        client.delete_access = True
        client.save()

        festival1 = create_festival('test', user)
        festival1.save()
        festival2 = create_festival('testest', user)
        festival2.save()
        festival = create_festival('testestest', user)
        festival.save()
        response = self.client.post('/backend/d/fest/', {
            'client': 'test',
            'id': festival.pk
        })
        self.assertEqual('OK', response.content.decode('utf-8'))
        self.assertEqual(2, Festival.objects.all().count())
示例#39
0
    def test_correct_input(self):
        """
        write_festival_info() is to return "OK" if information is successfully added.
        A new festival instance is to be created
        """

        login(self.client)
        client = create_client('test')
        client.write_access = True
        client.save()

        response = self.client.post('/backend/w/fest/',
                                    {'client': 'test',
                                     'name': 'test',
                                     'description': 'test',
                                     'country': 'test',
                                     'city': 'test',
                                     'address': 'test',
                                     'genre': 'test',
                                     'prices': '0e',
                                     'official': False})
        self.assertEqual(response.status_code, 200)
        self.assertEqual('OK', response.content.decode('utf-8'))
        self.assertTrue(Festival.objects.filter(name='test').exists())