Пример #1
0
    def test_no_change(self):
        group_matches = Match.ready_group_matches()
        data = create_empty_match_post_data(group_matches)

        formset = UpcomingMatchesFromset(data)
        self.assertTrue(formset.is_valid())

        formset.save()
        self.assertEqual(len(group_matches), len(Match.ready_group_matches()))
Пример #2
0
    def test_assigning_table(self):
        group_matches = list(Match.ready_group_matches())
        data = create_empty_match_post_data(group_matches)
        data['form-0-table'] = u'5'

        formset = UpcomingMatchesFromset(data)
        self.assertTrue(formset.is_valid())

        formset.save()
        self.assertEqual(len(group_matches) - 1, len(Match.ready_group_matches()))
Пример #3
0
    def test_assigning_multiple_tables(self):
        data = create_empty_match_post_data(Match.ready_group_matches())
        data['form-0-table'] = u'5'
        data['form-1-table'] = u'6'

        formset = UpcomingMatchesFromset(data)
        self.assertTrue(formset.is_valid())

        formset.save()
        self.assertEqual(0, len(Match.ready_group_matches()))
        pass
Пример #4
0
def upcoming_matches(context):
    if 'formset' in context:
        formset = context['formset']
    else:
        formset = UpcomingMatchesFromset(
            queryset=Match.ready_group_matches() | Match.ready_bracket_matches() | Match.ready_doubles_matches())
    context.update({
        'formset': formset,
        'matches': chain(Match.ready_group_matches(),
                                   Match.ready_bracket_matches(),
                                   Match.ready_doubles_matches())
    })
    return context
Пример #5
0
    def test_assigning_same_table_to_different_matches(self):
        data = create_empty_match_post_data(Match.ready_group_matches())
        data['form-0-table'] = u'4'
        data['form-1-table'] = u'4'

        formset = UpcomingMatchesFromset(data)

        self.assertEqual(formset.is_valid(), False)
Пример #6
0
def upcoming_matches(request):
    response_data = []
    response_data.extend([
        dict(id=match.id,
             type='Group',
             group=unicode(match.group))
        for match in Match.ready_group_matches()
    ])
    response_data.extend([
        dict(id=match.id,
             type='Bracket',
             player1=unicode(match.player1),
             player2=unicode(match.player2))
        for match in Match.ready_bracket_matches()
    ])
    response_data.extend([
        dict(id=match.id,
             type='Double',
             player1=unicode(match.player1),
             player2=unicode(match.player2))
        for match in Match.ready_doubles_matches()
    ])
    return HttpResponse(json.dumps(response_data),
                        content_type="application/json")
Пример #7
0
    def test_create_groups_creates_group_matches(self):
        category = Category.objects.get(description="Category without clubs")

        category.create_groups(number_of_groups=4)

        self.assertEqual(len(Match.ready_group_matches()), 4)
Пример #8
0
 def test_ready_group_matches_is_efficient(self):
     with self.assertNumQueries(1):
         group_matches = Match.ready_group_matches()
         for match in group_matches:
             match.description()