Blame tests/test_fnmatch.py

Pierre-Yves Chibon e1d70f
#!/usr/bin/env python
Pierre-Yves Chibon e1d70f
# -*- coding: utf-8 -*-
Pierre-Yves Chibon e1d70f
Pierre-Yves Chibon e1d70f
"""
Pierre-Yves Chibon e1d70f
 (c) 2017 - Copyright Red Hat Inc
Pierre-Yves Chibon e1d70f
Pierre-Yves Chibon e1d70f
 Authors:
Pierre-Yves Chibon e1d70f
   Pierre-Yves Chibon <pingou@pingoured.fr></pingou@pingoured.fr>
Pierre-Yves Chibon e1d70f
Pierre-Yves Chibon e1d70f
Tests the fnmatch method of the stdlib to ensure it works as expected
Pierre-Yves Chibon e1d70f
elsewhere in the code.
Pierre-Yves Chibon e1d70f
Pierre-Yves Chibon e1d70f
"""
Pierre-Yves Chibon e1d70f
Aurélien Bompard dcf6f6
from __future__ import unicode_literals
Aurélien Bompard dcf6f6
Pierre-Yves Chibon e1d70f
import os
Pierre-Yves Chibon e1d70f
import sys
Pierre-Yves Chibon e1d70f
import unittest
Pierre-Yves Chibon e1d70f
Pierre-Yves Chibon e1d70f
import fnmatch
Pierre-Yves Chibon e1d70f
Pierre-Yves Chibon e1d70f
Pierre-Yves Chibon e1d70f
class FnmatchTests(unittest.TestCase):
Pierre-Yves Chibon e1d70f
    """Tests for the streaming server."""
Pierre-Yves Chibon e1d70f
Pierre-Yves Chibon e1d70f
    def test_fnmatch(self):
Pierre-Yves Chibon e1d70f
        """ Test the matching done by fnmatch. """
Pierre-Yves Chibon e1d70f
        matrix = [
Pierre-Yves Chibon e1d70f
            ['pagure', '*', True],
Pierre-Yves Chibon e1d70f
            ['ns/pagure', '*', True],
Pierre-Yves Chibon e1d70f
            ['forks/user/ns/pagure', '*', True],
Pierre-Yves Chibon e1d70f
            ['forks/user/pagure', '*', True],
Pierre-Yves Chibon e1d70f
            ['pagure', 'rpms/*', False],
Pierre-Yves Chibon e1d70f
            ['rpms/pagure', 'rpms/*', True],
Pierre-Yves Chibon e1d70f
            ['forks/user/pagure', 'rpms/*', False],
Pierre-Yves Chibon e1d70f
            ['forks/user/pagure', 'rpms/*', False],
Pierre-Yves Chibon e1d70f
            ['pagure', 'pagure', True],
Pierre-Yves Chibon e1d70f
            ['rpms/pagure', 'pagure', False],
Pierre-Yves Chibon e1d70f
            ['forks/user/pagure', 'pagure', False],
Pierre-Yves Chibon e1d70f
            ['forks/user/pagure', 'pagure', False],
Pierre-Yves Chibon e1d70f
            ['pagure', 'pag*', True],
Pierre-Yves Chibon e1d70f
            ['rpms/pagure', 'pag*', False],
Pierre-Yves Chibon e1d70f
            ['forks/user/pagure', 'pag*', False],
Pierre-Yves Chibon e1d70f
            ['forks/user/pagure', 'pag*', False],
Pierre-Yves Chibon e1d70f
        ]
Pierre-Yves Chibon e1d70f
        for row in matrix:
Pierre-Yves Chibon e1d70f
            self.assertEqual(fnmatch.fnmatch(row[0], row[1]), row[2])
Pierre-Yves Chibon e1d70f
Pierre-Yves Chibon e1d70f
Pierre-Yves Chibon e1d70f
if __name__ == '__main__':
Pierre-Yves Chibon e1d70f
    unittest.main(verbosity=2)