def test_should_increase_pair_times(self): programmers = [Programmer(name = 'm1'), Programmer(name = 'm2')] pair = Pair(programmer_one = programmers[0].name, programmer_two = programmers[1].name, times = 0) pair.save() self.driver.get('http://localhost:8000/increase_pair_times/m1/m2/') pair = Pair.objects.filter(programmer_one = 'm1', programmer_two = 'm2')[0] self.assertEqual(1, pair.times)
def _populate_pairs(): programmer_list = Programmer.objects.all().order_by("id") for mainIndex in range(len(programmer_list)): for secondIndex in range(mainIndex+1, len(programmer_list)): pair = Pair(programmer_one = programmer_list[mainIndex].name, programmer_two = programmer_list[secondIndex]) pair.save()