def test_add_match_duplicate(self): day = MatchDay('Tuesday') avb1 = Match(Team('A'), Team('B')) avb2 = Match(Team('B'), Team('A')) avb3 = Match(Team('A'), Team('B')) self.assertEqual(day.add_match(avb1), avb1) self.assertEqual(day.add_match(avb2), False) self.assertEqual(day.add_match(avb3), False)
def setup_matches(teams): matches = set() for home_team in teams: for away_team in teams: if home_team != away_team: matches.add(Match(home_team, away_team)) return matches
def travel(self, obj): now = datetime.datetime.now(tz=get_current_timezone()) if obj.eated and obj.showerd and not obj.matched: obj.out_time = now + datetime.timedelta( minutes=random.randint(1, 5)) # obj.out_time = now + datetime.timedelta(minutes=random.randint(10, 30)) obj.return_time = now + datetime.timedelta( minutes=random.randint(6, 9)) # obj.return_time = now + datetime.timedelta(hours=random.randint(1, 10)) obj.matched = True ms = Match.objects.filter(pet=obj) if ms.exists(): ms = ms[0] ms.delete() match = Match(pet=obj) # 特征 # match.character = 0x01 # match.wish = 0x01 match.save() return True
def test_add_match_success(self): day = MatchDay('Tuesday') avb = Match(Team('A'), Team('B')) output = day.add_match(avb) self.assertEqual(output, avb)