def test_create_email(self): self.client.login(username='******', password='******') game = Game() modify_game(game) self.client.post(self.url, game.__dict__) game = Game.objects.get(title=game.title) self.assertEmail(['*****@*****.**'], game.email_format(None), "Game Submission", "staff submitted '%s'" % game.title)
def test_post_revision(self, expected, updates): self.client.login(username="******", password="******") post_data = {"location": 1, "time_block": 1, "time_slot": 1} game = Game() modify_game(game) game.user = User.objects.get(username="******") game.location = Location.objects.get(id=post_data["location"]) game.time_block = TimeBlock.objects.get(id=post_data["time_block"]) game.time_slot = TimeSlot.objects.get(id=post_data["time_slot"]) game.last_modified = timezone.now() game.save() post_data["id"] = game.id self.assertEquals(len(reversion.get_for_object(game)), 0) post_data.update(updates) self.client.post(self.url, post_data) versions = reversion.get_for_object(game) self.assertEquals(len(versions), 1) self.assertEquals(versions[0].revision.comment, "AJAX Schedule Submission - %s Changed" % expected)
def run_post_test(self, username, location=Location.objects.all()[0], time_block=TimeBlock.objects.all()[0], time_slot=TimeSlot.objects.all()[0]): self.client.login(username=username, password="******") game = Game() modify_game(game) game.user = User.objects.get(username=username) game.last_modified = timezone.now() - timedelta(days=-1) game.save() modified_date = timezone.now() game = Game.objects.get(title="Unit Test Title") post_data = {"id": game.id} if location: post_data["location"] = location.id if time_block: post_data["time_block"] = time_block.id if time_slot: post_data["time_slot"] = time_slot.id self.client.post(self.url, post_data) game = Game.objects.get(title="Unit Test Title") self.assertGreater(game.last_scheduled, modified_date) self.assertEquals(game.time_block, time_block) self.assertEquals(game.time_slot, time_slot) self.assertEquals(game.location, location)
def run_create_post_test(self, username): self.client.login(username=username, password='******') game = Game() modify_game(game) modified_date = timezone.now() response = self.client.post(self.url, game.__dict__) self.assertRedirects(response, reverse("convention:user_profile")) actual = Game.objects.get(title="Unit Test Title") check_game(self, actual, modified_date) self.assertEquals(actual.user, User.objects.get(username=username))
def test_create_revision(self): self.client.login(username='******', password='******') game = Game() modify_game(game) response = self.client.post(self.url, game.__dict__) self.assertRedirects(response, reverse("convention:user_profile")) actual = Game.objects.get(title="Unit Test Title") versions = reversion.get_for_object(actual) self.assertEquals(len(versions), 1) self.assertEquals(versions[0].revision.comment, "Form Submission - New")
def test_create_after_con_open_con_full_wait_list_post(self): info = ConInfo.objects.all()[0] info.registration_opens = timezone.now() - timedelta(days=1) info.max_attendees = 0 info.save() self.client.login(username='******', password='******') game = Game() modify_game(game) response = self.client.post(self.url, game.__dict__) self.assertEquals(response.status_code, 200) self.assertSectionContains(response, 'On Wait List', 'h2') self.assertSectionContains( response, 'we cannot accept game submissions from people on the wait ', 'h2', '/p')
def test_create_after_con_open_con_full_not_registered_post(self): info = ConInfo.objects.all()[0] info.registration_opens = timezone.now() - timedelta(days=1) info.max_attendees = 0 info.save() user = User(username='******') user.set_password('123') user.save() self.client.login(username='******', password='******') game = Game() modify_game(game) response = self.client.post(self.url, game.__dict__) self.assertEquals(response.status_code, 200) self.assertSectionContains(response, 'Con Full', 'h2') self.assertSectionContains(response, 'a href', 'section id="main" role="main"', '/section') self.assertSectionContains(response, 'Once registration opens', 'section id="main" role="main"', '/section', False)
def test_get_start_no_block_no_slot(self): game = Game() self.assertEquals(get_start(game), 100)
def test_get_start_no_slot(self): game = Game() game.time_block = TimeBlock(text="Friday Night", sort_id=0) game.time_slot = None self.assertEquals(get_start(game), 100)
def test_get_start_no_block(self): game = Game() game.time_block = None game.time_slot = TimeSlot(start=5, stop=23) self.assertEquals(get_start(game), 100)
def test_get_start(self, block, start, expected): game = Game() game.time_block = TimeBlock(text=block, sort_id=0) game.time_slot = TimeSlot(start=start, stop=23) self.assertEquals(get_start(game), expected)