def test_filter_satisfied_results(self): """ read_multiple_festivals() is to return between 1 and num results, depending on how many satisfy the filter """ login(self.client) user = create_user() create_festival('test', user) fest1 = create_festival('testest', user) fest1.city = 'testest' fest1.prices = '3e 50e 200e' fest1.save() fest2 = create_festival('testestest', user) fest2.prices = '3e 50e 200e' fest2.save() fest3 = create_festival('testestestest', user) fest3.prices = '1000e' fest3.save() response = self.client.post('/backend/mult/fest/', { 'client': 'test', 'num': 3, 'min_price': '20e', 'max_price': '60e' }) data = json.loads(response.content.decode('utf-8')) self.assertEqual(len(data), 2)
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_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_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_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_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_no_client_name_provided(self): """ write_concert_info() is to return "Client name not provided" if no client name is provided """ login(self.client) festival = create_festival('test', create_user()) festival.save() response = self.client.post( '/backend/w/conc/', { '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('Client name not provided', response.content.decode('utf-8'))
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_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())
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_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_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_min_value_is_higher_than_max_value(self): """ price_is_in_range() is to throw InvalidInputOrDifferentCurrencyError if max_value is higher than min_value """ festival = create_festival('test', create_user()) with self.assertRaises(InvalidInputOrDifferentCurrencyError): festival.price_is_in_range('10e', '5e')
def test_filter_does_not_satisfy_any_results(self): """ read_multiple_festivals() is to return empty JSON data document in case no records satisfy the filter """ login(self.client) create_festival('test', create_user()) response = self.client.post('/backend/mult/fest/', { 'client': 'test', 'num': 3, 'name': 'test', 'country': 'test', 'city': 'asdf' }) data = json.loads(response.content.decode('utf-8')) self.assertEqual(len(data), 0)
def test_filter_does_not_satisfy_any_results(self): """ read_multiple_festivals() is to return empty JSON data document in case no records satisfy the filter """ login(self.client) create_festival('test', create_user()) response = self.client.post( '/backend/mult/fest/', { 'client': 'test', 'num': 3, 'name': 'test', 'country': 'test', 'city': 'asdf' }) data = json.loads(response.content.decode('utf-8')) self.assertEqual(len(data), 0)
def test_empty_prices_string_in_fest(self): """ price_is_in_range() should treat empty prices string in the festival as a 0 value of any currency """ festival = create_festival('test', create_user()) self.assertTrue(festival.price_is_in_range(max_price='$10')) self.assertFalse(festival.price_is_in_range(min_price='5e')) self.assertFalse(festival.price_is_in_range('5e', '10e'))
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_price_is_in_range_currency_mismatch(self): """ price_is_in_range() should throw InvalidInputOrDifferentCurrencyError if the currency strings do not match """ festival = create_festival('test', create_user()) festival.prices = '3e 50e 200e' festival.save() with self.assertRaises(InvalidInputOrDifferentCurrencyError): festival.price_is_in_range('$3', '$5')
def test_no_concert_found(self): """ read_concert_info() is to return an empty JSON document if no concert satisfies the criteria """ login(self.client) festival = create_festival('test', create_user()) festival.save() response = self.client.post('/backend/r/conc/', {'client': 'test', 'artist': 0}) data = json.loads(response.content.decode('utf-8')) self.assertFalse(data)
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_no_festival_found(self): """ read_festival_info() is to return "Invalid Festival ID" data document if festival is not found """ login(self.client) festival = create_festival('test', create_user()) festival.save() response = self.client.post('/backend/r/fest/', {'client': 'test', 'id': festival.pk + 1}) self.assertEqual(response.status_code, 200) self.assertEqual(response.content.decode('utf-8'), 'Invalid Festival ID')
def test_price_is_in_range_negative_value(self): """ price_is_in_range() is to throw InvalidInputOrDifferentCurrencyError if any of the values provided is negative """ festival = create_festival('test', create_user()) with self.assertRaises(InvalidInputOrDifferentCurrencyError): festival.price_is_in_range('-3e', '5e') with self.assertRaises(InvalidInputOrDifferentCurrencyError): festival.price_is_in_range('3e', '-5e') with self.assertRaises(InvalidInputOrDifferentCurrencyError): festival.price_is_in_range('-3e', '-5e')
def test_less_records_available_than_requested(self): """ read_multiple_festivals() is to return the amount of available festivals in case that number is less than the number requested """ login(self.client) fest = create_festival('test', create_user()) fest.save() response = self.client.post('/backend/mult/fest/', {'client': 'test', 'num': 3}) self.assertEqual(response.status_code, 200) data = json.loads(response.content.decode('utf-8')) self.assertEqual(len(data), 1)
def test_empty_festival(self): """ read_festival_concerts() is to return an empty JSON data document if festival is found but empty """ login(self.client) festival = create_festival('test', create_user()) festival.save() response = self.client.post('/backend/mult/conc/', {'client': 'test', 'id': festival.pk}) self.assertEqual(response.status_code, 200) data = json.loads(response.content.decode('utf-8')) self.assertTrue(not data)
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_concert_found(self): """ read_concert_info() is to return a JSON document containing the concert's information """ login(self.client) festival = create_festival('test', create_user()) festival.save() concert = create_concert(festival, 'test') concert.save() response = self.client.post('/backend/r/conc/', {'client': 'test', 'id': concert.pk}) data = json.loads(response.content.decode('utf-8')) self.assertTrue(data) self.assertTrue('test', data['artist'])
def test_records_available_equal_or_more_than_requested(self): """ read_multiple_festivals() is to return the requested number of records in case the database has that many records """ login(self.client) user = create_user() fest1 = create_festival('test', user) fest1.save() fest2 = create_festival('testest', user) fest2.save() fest3 = create_festival('testestest', user) fest3.save() response = self.client.post('/backend/mult/fest/', {'client': 'test', 'num': 3}) self.assertEqual(response.status_code, 200) data = json.loads(response.content.decode('utf-8')) self.assertEqual(len(data), 3) create_festival('testestestest', user) response = self.client.post('/backend/mult/fest/', {'client': 'test', 'num': 3}) self.assertEqual(response.status_code, 200) data = json.loads(response.content.decode('utf-8')) self.assertEqual(len(data), 3)
def test_festival_found(self): """ read_festival_info() is to return an JSON data document containing the data of the festival found """ login(self.client) festival = create_festival('test', create_user()) festival.save() response = self.client.post('/backend/r/fest/', {'client': 'test', 'id': festival.pk}) self.assertEqual(response.status_code, 200) data = json.loads(response.content.decode('utf-8')) self.assertTrue(data) self.assertEqual(data['name'], festival.name)
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_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_valid_festival(self): """ read_festival_concerts() is to return all concerts in the festival """ login(self.client) festival = create_festival('test', create_user()) festival.save() create_concert(festival, 'test') create_concert(festival, 'testest') create_concert(festival, 'testestest') response = self.client.post('/backend/mult/conc/', {'client': 'test', 'id': festival.pk}) self.assertEqual(response.status_code, 200) data = json.loads(response.content.decode('utf-8')) self.assertEqual(len(data), 3)
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_festival_found(self): """ read_festival_info() is to return "Invalid Festival ID" data document if festival is not found """ login(self.client) festival = create_festival('test', create_user()) festival.save() response = self.client.post('/backend/r/fest/', { 'client': 'test', 'id': festival.pk + 1 }) self.assertEqual(response.status_code, 200) self.assertEqual(response.content.decode('utf-8'), 'Invalid Festival ID')
def test_only_min_value_is_defined(self): """ price_is_in_range() is to return all results higher than min_price """ festival = create_festival('test', create_user()) festival.prices = '3e 50e 200e' festival.save() self.assertTrue(festival.price_is_in_range('5e')) self.assertTrue(festival.price_is_in_range('5 e')) festival.prices = '$3 $50 $200' festival.save() self.assertTrue(festival.price_is_in_range('$3')) self.assertTrue(festival.price_is_in_range('$ 3'))
def test_less_records_available_than_requested(self): """ read_multiple_festivals() is to return the amount of available festivals in case that number is less than the number requested """ login(self.client) fest = create_festival('test', create_user()) fest.save() response = self.client.post('/backend/mult/fest/', { 'client': 'test', 'num': 3 }) self.assertEqual(response.status_code, 200) data = json.loads(response.content.decode('utf-8')) self.assertEqual(len(data), 1)
def test_empty_festival(self): """ read_festival_concerts() is to return an empty JSON data document if festival is found but empty """ login(self.client) festival = create_festival('test', create_user()) festival.save() response = self.client.post('/backend/mult/conc/', { 'client': 'test', 'id': festival.pk }) self.assertEqual(response.status_code, 200) data = json.loads(response.content.decode('utf-8')) self.assertTrue(not data)
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_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_festival_found(self): """ read_festival_info() is to return an JSON data document containing the data of the festival found """ login(self.client) festival = create_festival('test', create_user()) festival.save() response = self.client.post('/backend/r/fest/', { 'client': 'test', 'id': festival.pk }) self.assertEqual(response.status_code, 200) data = json.loads(response.content.decode('utf-8')) self.assertTrue(data) self.assertEqual(data['name'], festival.name)
def test_price_is_in_range_correct_input_in_range(self): """ price_is_in_range() is to return True if the currency strings are equal, none of the inputs are negative numbers and at least one of the prices fits within the requirements """ festival = create_festival('test', create_user()) festival.prices = '3e 50e 200e' festival.save() self.assertTrue(festival.price_is_in_range('5e', '100e')) self.assertTrue(festival.price_is_in_range('5 e', '100 e')) festival.prices = '$3 $50 $200' festival.save() self.assertTrue(festival.price_is_in_range('$3', '$100')) self.assertTrue(festival.price_is_in_range('$ 3', '$ 100'))
def test_price_is_in_range_correct_input_outside_range(self): """ price_is_in_range() is to return False without throwing an exception if the currency strings are equal, none of the inputs are negative numbers and no prices satisfy the requirements """ festival = create_festival('test', create_user()) festival.prices = '3e 50e 200e' festival.save() self.assertFalse(festival.price_is_in_range('4e', '10e')) self.assertFalse(festival.price_is_in_range('4 e', '10 e')) festival.prices = '$25 $50 $200' festival.save() self.assertFalse(festival.price_is_in_range('$1', '$10')) self.assertFalse(festival.price_is_in_range('$ 1', '$ 10'))
def test_valid_festival(self): """ read_festival_concerts() is to return all concerts in the festival """ login(self.client) festival = create_festival('test', create_user()) festival.save() create_concert(festival, 'test') create_concert(festival, 'testest') create_concert(festival, 'testestest') response = self.client.post('/backend/mult/conc/', { 'client': 'test', 'id': festival.pk }) self.assertEqual(response.status_code, 200) data = json.loads(response.content.decode('utf-8')) self.assertEqual(len(data), 3)
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())
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())