def testChangeSubmissionChangesStandings(self): json_standings = get_floor_standings() decoded_standings = json.loads(json_standings) first_label = decoded_standings["info"][0]["label"] point_diff = decoded_standings["info"][0]["points"] - self.test_user.points self.test_user.points += point_diff # Should move this user into a tie. self.test_user.last_awarded_submission = datetime.datetime.today() self.test_user.save() json_standings = get_floor_standings() decoded_standings = json.loads(json_standings) self.assertEqual( decoded_standings["info"][1]["label"], first_label, "Test that the former 1st place floor is now second." )
def testChangeSubmissionChangesStandings(self): json_standings = get_floor_standings() decoded_standings = json.loads(json_standings) first_label = decoded_standings["info"][0]["label"] point_diff = decoded_standings["info"][0][ "points"] - self.test_user.points self.test_user.points += point_diff # Should move this user into a tie. self.test_user.last_awarded_submission = datetime.datetime.today() self.test_user.save() json_standings = get_floor_standings() decoded_standings = json.loads(json_standings) self.assertEqual( decoded_standings["info"][1]["label"], first_label, "Test that the former 1st place floor is now second.")
def testAddPointsChangeStandings(self): json_standings = get_floor_standings() decoded_standings = json.loads(json_standings) # Save label of first place user. first_label = decoded_standings["info"][0]["label"] point_diff = decoded_standings["info"][0][ "points"] - self.test_user.points self.test_user.points += point_diff + 1 # Should move this floor ahead. self.test_user.save() json_standings = get_floor_standings() decoded_standings = json.loads(json_standings) self.assertEqual( decoded_standings["info"][1]["label"], first_label, "Test that the original first place floor is now second.")
def testAddPointsChangeStandings(self): json_standings = get_floor_standings() decoded_standings = json.loads(json_standings) # Save label of first place user. first_label = decoded_standings["info"][0]["label"] point_diff = decoded_standings["info"][0]["points"] - self.test_user.points self.test_user.points += point_diff + 1 # Should move this floor ahead. self.test_user.save() json_standings = get_floor_standings() decoded_standings = json.loads(json_standings) self.assertEqual( decoded_standings["info"][1]["label"], first_label, "Test that the original first place floor is now second.", )
def testAddPointsChangeStandings(self): json_standings = get_floor_standings() decoded_standings = json.loads(json_standings) # Save first place label. first_label = decoded_standings["info"][0]["label"] floor_points = self.test_floor.points point_diff = decoded_standings["info"][0]["points"] - floor_points profile = self.test_floor.profile_set.all()[0] profile.points += point_diff + 1 # Should move this floor ahead. profile.save() json_standings = get_floor_standings() decoded_standings = json.loads(json_standings) self.assertEqual( decoded_standings["info"][1]["label"], first_label, "Test that the original first place floor is now second.") self.assertEqual(decoded_standings["info"][0]["points"], floor_points + point_diff + 1, "Test that the points were updated.")
def testChangeSubmissionChangesStandings(self): json_standings = get_floor_standings() decoded_standings = json.loads(json_standings) # Save first place label. first_label = decoded_standings["info"][0]["label"] floor_points = self.test_floor.points point_diff = decoded_standings["info"][0]["points"] - floor_points profile = self.test_floor.profile_set.all()[0] profile.points += point_diff # Should move this floor into a tie. profile.last_awarded_submission = datetime.datetime.today() profile.save() json_standings = get_floor_standings() decoded_standings = json.loads(json_standings) self.assertEqual( decoded_standings["info"][1]["label"], first_label, "Test that the original first place floor is now second.") self.assertEqual(decoded_standings["info"][0]["points"], floor_points + point_diff, "Test that the points were updated.")
def testAddPointsChangeStandings(self): json_standings = get_floor_standings() decoded_standings = json.loads(json_standings) # Save first place label. first_label = decoded_standings["info"][0]["label"] floor_points = self.test_floor.points point_diff = decoded_standings["info"][0]["points"] - floor_points profile = self.test_floor.profile_set.all()[0] profile.points += point_diff + 1 # Should move this floor ahead. profile.save() json_standings = get_floor_standings() decoded_standings = json.loads(json_standings) self.assertEqual( decoded_standings["info"][1]["label"], first_label, "Test that the original first place floor is now second.", ) self.assertEqual( decoded_standings["info"][0]["points"], floor_points + point_diff + 1, "Test that the points were updated." )
def testChangeSubmissionChangesStandings(self): json_standings = get_floor_standings() decoded_standings = json.loads(json_standings) # Save first place label. first_label = decoded_standings["info"][0]["label"] floor_points = self.test_floor.points point_diff = decoded_standings["info"][0]["points"] - floor_points profile = self.test_floor.profile_set.all()[0] profile.points += point_diff # Should move this floor into a tie. profile.last_awarded_submission = datetime.datetime.today() profile.save() json_standings = get_floor_standings() decoded_standings = json.loads(json_standings) self.assertEqual( decoded_standings["info"][1]["label"], first_label, "Test that the original first place floor is now second.", ) self.assertEqual( decoded_standings["info"][0]["points"], floor_points + point_diff, "Test that the points were updated." )
def testFloorStandingsForRound(self): """Test the standings for a round.""" json_standings = get_floor_standings(round_name=self.current_round) decoded_standings = json.loads(json_standings) # Verify that the returned structure is correct. self.assertTrue(decoded_standings.has_key("title")) self.assertTrue(decoded_standings.has_key("info")) # Verify that the contents are correct. self.assertEqual(len(decoded_standings["info"]), Floor.objects.count()) self.assertEqual(decoded_standings["title"], "%s: %s" % (self.title_prefix, self.current_round), "Test that correct title is generated.") first = decoded_standings["info"][0] second = decoded_standings["info"][1] self.assertTrue(first["points"] >= second["points"])
def testFloorStandingsOverall(self): json_standings = get_floor_standings() decoded_standings = json.loads(json_standings) # Verify that the returned structure is correct. self.assertTrue(decoded_standings.has_key("title")) self.assertTrue(decoded_standings.has_key("info")) # Verify that the contents are correct. self.assertEqual( len(decoded_standings["info"]), Floor.objects.count(), "Test that the correct number of floors is generated.") self.assertEqual(decoded_standings["title"], "%s: Overall" % self.title_prefix, "Test that correct title is generated.") first = decoded_standings["info"][0] second = decoded_standings["info"][1] self.assertTrue(first["points"] >= second["points"])
def testFloorStandingsWithDorm(self): """Test getting the standings for a dorm.""" dorm = Dorm.objects.all()[0] json_standings = get_floor_standings(dorm=dorm, ) decoded_standings = json.loads(json_standings) # Verify that the returned structure is correct. self.assertTrue(decoded_standings.has_key("title")) self.assertTrue(decoded_standings.has_key("info")) # Verify that the contents are correct. self.assertEqual( len(decoded_standings["info"]), dorm.floor_set.count(), "Test that the correct number of floors is generated.") self.assertEqual(decoded_standings["title"], "%s: Overall" % dorm.name, "Test that correct title is generated.") first = decoded_standings["info"][0] second = decoded_standings["info"][1] self.assertTrue(first["points"] >= second["points"])
def testFloorStandingsForRound(self): """Test the standings for a round.""" json_standings = get_floor_standings(round_name=self.current_round) decoded_standings = json.loads(json_standings) # Verify that the returned structure is correct. self.assertTrue(decoded_standings.has_key("title")) self.assertTrue(decoded_standings.has_key("info")) # Verify that the contents are correct. self.assertEqual(len(decoded_standings["info"]), Floor.objects.count()) self.assertEqual( decoded_standings["title"], "%s: %s" % (self.title_prefix, self.current_round), "Test that correct title is generated.", ) first = decoded_standings["info"][0] second = decoded_standings["info"][1] self.assertTrue(first["points"] >= second["points"])
def testFloorStandingsWithDorm(self): """Test getting the standings for a dorm.""" dorm = Dorm.objects.all()[0] json_standings = get_floor_standings(dorm=dorm) decoded_standings = json.loads(json_standings) # Verify that the returned structure is correct. self.assertTrue(decoded_standings.has_key("title")) self.assertTrue(decoded_standings.has_key("info")) # Verify that the contents are correct. self.assertEqual( len(decoded_standings["info"]), dorm.floor_set.count(), "Test that the correct number of floors is generated.", ) self.assertEqual(decoded_standings["title"], "%s: Overall" % dorm.name, "Test that correct title is generated.") first = decoded_standings["info"][0] second = decoded_standings["info"][1] self.assertTrue(first["points"] >= second["points"])
def testFloorStandingsOverall(self): json_standings = get_floor_standings() decoded_standings = json.loads(json_standings) # Verify that the returned structure is correct. self.assertTrue(decoded_standings.has_key("title")) self.assertTrue(decoded_standings.has_key("info")) # Verify that the contents are correct. self.assertEqual( len(decoded_standings["info"]), Floor.objects.count(), "Test that the correct number of floors is generated.", ) self.assertEqual( decoded_standings["title"], "%s: Overall" % self.title_prefix, "Test that correct title is generated." ) first = decoded_standings["info"][0] second = decoded_standings["info"][1] self.assertTrue(first["points"] >= second["points"])