from ploneintranet.patches.pas_groupmanager import COLLECTIVE_WORKSPACE_GROUPID_PATTERN

import unittest


class TestPatternTestCase(unittest.TestCase):
    def test_pattern(self):
        valid_gid = "Admins:005da1f1caea47f9b2b823c567b5b1e9"
        self.assertTrue(COLLECTIVE_WORKSPACE_GROUPID_PATTERN.match(valid_gid))

        # Test invalid group ids
        for gid in [
            "",
            valid_gid.lower(),
            valid_gid.replace("e", "z"),
            valid_gid + "1",
            valid_gid.replace(":", ""),
            valid_gid.replace(":", "::"),
        ]:
            self.assertFalse(COLLECTIVE_WORKSPACE_GROUPID_PATTERN.match(gid))
