<commit_before>from rest_framework import status, test

from nodeconductor.cloud.tests import factories as cloud_factories
from nodeconductor.structure.models import CustomerRole, ProjectRole
from nodeconductor.structure.tests import factories as structure_factories


class IpMappingPermissionTest(test.APISimpleTestCase):
    def setUp(self):
        self.users = {
            'owner': structure_factories.UserFactory(),
            'manager': structure_factories.UserFactory(),
            'admin': structure_factories.UserFactory(),
        }

        self.staff_user = structure_factories.UserFactory(is_staff=True)

        self.project = structure_factories.ProjectFactory()
        self.project.add_user(self.users['manager'], ProjectRole.MANAGER)
        self.project.add_user(self.users['admin'], ProjectRole.ADMINISTRATOR)

        self.project.customer.add_user(self.users['owner'], CustomerRole.OWNER)

        self.ip_mapping = cloud_factories.IpMappingFactory(project=self.project)

    # List filtration tests
    def test_user_cannot_list_ip_mappings_of_project_he_has_no_role_in(self):<commit_msg>Change test case to transactional<commit_after>from rest_framework import status, test

from nodeconductor.cloud.tests import factories as cloud_factories
from nodeconductor.structure.models import CustomerRole, ProjectRole
from nodeconductor.structure.tests import factories as structure_factories


class IpMappingPermissionTest(test.APITransactionTestCase):
    def setUp(self):
        self.users = {
            'owner': structure_factories.UserFactory(),
            'manager': structure_factories.UserFactory(),
            'admin': structure_factories.UserFactory(),
        }

        self.staff_user = structure_factories.UserFactory(is_staff=True)

        self.project = structure_factories.ProjectFactory()
        self.project.add_user(self.users['manager'], ProjectRole.MANAGER)
        self.project.add_user(self.users['admin'], ProjectRole.ADMINISTRATOR)

        self.project.customer.add_user(self.users['owner'], CustomerRole.OWNER)

        self.ip_mapping = cloud_factories.IpMappingFactory(project=self.project)

    # List filtration tests
    def test_user_cannot_list_ip_mappings_of_project_he_has_no_role_in(self):
{'fraction_non_alphanumeric': 0.08772707133362871, 'fraction_numerical': 0.0, 'mean_word_length': 4.389021479713604, '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': '4032668', 'n_tokens_mistral': 651, 'n_tokens_neox': 614, 'n_words': 103}