<commit_before>from collections import OrderedDict
from .fixture import AppTestCase


class TestMatches(AppTestCase):

    ORDER = 4

    def test_matches_all(self):
        cases = [
            ("/matches/", 0, None, 2),
            ("/matches/1/", 1, None, 2),
            ("/matches/ad/", 0, "ad", 1),
            ("/matches/ad/1/", 1, "ad", 1),
            ("/matches/tdm/", 0, "tdm", 1),
            ("/matches/player/76561198260599288/", 0, None, 1)
        ]
        for case in cases:
            uri = case[0]
            page = case[1]
            gametype = case[2]
            page_count = case[3]
            resp = self.get(uri)
            self.assertEqual(resp.template.name, "match_list.html")

            context = resp.context
            self.assertIn('request', context)
            self.assertIn('current_page', context)
            self.assertIn('gametype', context)
            self.assertIn('page_count', context)
            self.assertEqual(context['current_page'], page)
            self.assertEqual(context['gametype'], gametype)
            self.assertEqual(context['page_count'], page_count)

            sample_filename = "match_list_{}".format(cases.index(case)+1)
            self.assertEqual(
                context['matches'],
                self.read_json_sample(sample_filename)
            )

    def test_old_routes(self):
        assert 0
        resp = self.test_cli.get("/player/123/matches/blablabla/456/", allow_redirects=False)
        self.assertTrue(resp.headers['Location'].endswith("/matches/player/123/blablabla/456"))

        resp = self.test_cli.get("/player/123/matches/blablabla/456/", allow_redirects=False)
        self.assertTrue(resp.headers['Location'].endswith("/matches/player/123/blablabla/456"))<commit_msg>test_matches: implement tests for old routes<commit_after>from collections import OrderedDict
from .fixture import AppTestCase


class TestMatches(AppTestCase):

    ORDER = 4

    def test_matches_all(self):
        cases = [
            ("/matches/", 0, None, 2),
            ("/matches/1/", 1, None, 2),
            ("/matches/ad/", 0, "ad", 1),
            ("/matches/ad/1/", 1, "ad", 1),
            ("/matches/tdm/", 0, "tdm", 1),
            ("/matches/player/76561198260599288/", 0, None, 1)
        ]
        for case in cases:
            uri = case[0]
            page = case[1]
            gametype = case[2]
            page_count = case[3]
            resp = self.get(uri)
            self.assertEqual(resp.template.name, "match_list.html")

            context = resp.context
            self.assertIn('request', context)
            self.assertIn('current_page', context)
            self.assertIn('gametype', context)
            self.assertIn('page_count', context)
            self.assertEqual(context['current_page'], page)
            self.assertEqual(context['gametype'], gametype)
            self.assertEqual(context['page_count'], page_count)

            sample_filename = "match_list_{}".format(cases.index(case)+1)
            self.assertEqual(
                context['matches'],
                self.read_json_sample(sample_filename)
            )

    def test_old_routes(self):
        pairs = [
            ("/player/123/matches", "/matches/player/123/"),
            ("/player/123/matches/", "/matches/player/123/"),
            ("/player/123/matches/456/", "/matches/player/123/456/"),
            ("/player/123/matches/blablabla/456/", "/matches/player/123/blablabla/456/")
        ]
        for pair in pairs:
            old_uri = pair[0]
            new_uri = pair[1]
            resp = self.get(old_uri, 302)
            self.assertTrue(resp.headers['Location'].endswith(new_uri))
{'fraction_non_alphanumeric': 0.1452922077922078, 'fraction_numerical': 0.03787878787878788, 'mean_word_length': 1.9983779399837793, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4082011', 'n_tokens_mistral': 1206, 'n_tokens_neox': 1069, 'n_words': 191}