<commit_before>from django.test import TestCase
from django.contrib.auth.models import User, Group
from osmaxx.contrib.auth.frontend_permissions import user_in_osmaxx_group, FRONTEND_USER_GROUP


class TestFrontendPermissions(TestCase):
    def test_superuser_can_access_frontend_even_if_not_in_osmaxx_group(self):
        an_admin = User.objects.create_superuser('<NAME>', '<EMAIL>', 'password')
        self.assertTrue(user_in_osmaxx_group(an_admin))

    def test_user_can_access_frontend_when_in_osmaxx_group(self):
        a_user = User.objects.create_user('<NAME>', '<EMAIL>', 'password')
        a_user.groups.add(Group.objects.get(name=FRONTEND_USER_GROUP))
        self.assertTrue(user_in_osmaxx_group(a_user))<commit_msg>Test that users can not access frontend by default<commit_after>from django.test import TestCase
from django.contrib.auth.models import User, Group
from osmaxx.contrib.auth.frontend_permissions import user_in_osmaxx_group, FRONTEND_USER_GROUP


class TestFrontendPermissions(TestCase):
    def test_user_can_not_access_frontend_by_default(self):
        a_user = User.objects.create_user('<NAME>', '<EMAIL>', 'password')
        self.assertFalse(user_in_osmaxx_group(a_user))

    def test_superuser_can_access_frontend_even_if_not_in_osmaxx_group(self):
        an_admin = User.objects.create_superuser('<NAME>', '<EMAIL>', 'password')
        self.assertTrue(user_in_osmaxx_group(an_admin))

    def test_user_can_access_frontend_when_in_osmaxx_group(self):
        a_user = User.objects.create_user('<NAME>', '<EMAIL>', 'password')
        a_user.groups.add(Group.objects.get(name=FRONTEND_USER_GROUP))
        self.assertTrue(user_in_osmaxx_group(a_user))
{'fraction_non_alphanumeric': 0.10236686390532544, 'fraction_numerical': 0.0, 'mean_word_length': 6.016597510373444, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '5759932', 'n_tokens_mistral': 563, 'n_tokens_neox': 573, 'n_words': 76}