Ejemplo n.º 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."
        )
Ejemplo n.º 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.")
Ejemplo n.º 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.")
Ejemplo n.º 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.",
        )
Ejemplo n.º 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.")
Ejemplo n.º 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.")
Ejemplo n.º 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."
        )
Ejemplo n.º 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."
        )
Ejemplo n.º 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"])
Ejemplo n.º 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"])
Ejemplo n.º 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"])
Ejemplo n.º 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"])
Ejemplo n.º 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"])
Ejemplo n.º 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"])