Beispiel #1
0
    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."
        )
Beispiel #2
0
    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.")
Beispiel #3
0
    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.")
Beispiel #4
0
    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.",
        )
Beispiel #5
0
    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.")
Beispiel #6
0
    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.")
Beispiel #7
0
    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."
        )
Beispiel #8
0
    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."
        )
Beispiel #9
0
    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"])
Beispiel #10
0
    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"])
Beispiel #11
0
    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"])
Beispiel #12
0
    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"])
Beispiel #13
0
    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"])
Beispiel #14
0
    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"])