def test_only_invalid_entries_is_zero_valid(self): week = compo.blank_week() entry = compo.create_blank_entry("Invalid", 0) week["entries"].append(entry) assert not compo.entry_valid(entry) assert compo.count_valid_entries(week) == 0
def test_move_weeks(self, mocker): self.mock_pickle(mocker) compo.current_week = "Gandalf the Gray" compo.next_week = "Gandalf the White" compo.move_to_next_week() assert compo.current_week == "Gandalf the White" assert compo.next_week == compo.blank_week()
def test_counts_valid_entries(self): week = compo.blank_week() entry = compo.create_blank_entry("Invalid", 0) entry["pdf"] = "yes" entry["pdfFilename"] = "here" entry["mp3"] = "yes" entry["mp3Format"] = "here" entry["mp3Filename"] = "yes" week["entries"].append(entry) assert compo.entry_valid(entry) assert compo.count_valid_entries(week) == 1
def test_cant_vote_too_low(self): week = compo.blank_week() votes = [{ "userID": 1234, "ratings": [{ "voteParam": "overall", "entryUUID": "123", "rating": -5 }] }] week["votes"] = votes.copy() compo.verify_votes(week) assert week["votes"][0]["ratings"] == []
def test_a_single_vote_is_ok(self): week = compo.blank_week() votes = [{ "userID": 1234, "ratings": [{ "voteParam": "overall", "entryUUID": "123", "rating": 3 }] }] week["votes"] = votes.copy() compo.verify_votes(week) assert week["votes"] == votes
def test_duped_votes_are_discarded(self): week = compo.blank_week() rating1 = { "voteParam": "overall", "entryUUID": "123", "rating": 3 } rating2 = { "voteParam": "overall", "entryUUID": "123", "rating": 4 } votes = [{ "userID": 1234, "ratings": [rating1, rating2] }] week["votes"] = votes.copy() compo.verify_votes(week) assert week["votes"][0]["ratings"] == [rating1]
def test_all_is_good_by_default(self): week = compo.blank_week() compo.verify_votes(week) assert week["votes"] == []
def test_no_entries_is_zero_valid(self): week = compo.blank_week() assert compo.count_valid_entries(week) == 0
def setup(self): compo.current_week = compo.blank_week() compo.next_week = compo.blank_week()