<commit_before>from ddt import ddt, data
from rest_framework import test, status

from nodeconductor.structure.tests import factories as structure_factories

from . import PackageTemplateFactory


@ddt
class PackageTemplateListTest(test.APITransactionTestCase):
    def setUp(self):
        self.staff = structure_factories.UserFactory(is_staff=True)
        self.user = structure_factories.UserFactory()

    @data('staff', 'user')
    def test_user_can_list_package_templates(self, user):
        self.client.force_authenticate(user=getattr(self, user))

        response = self.client.get(PackageTemplateFactory.get_list_url())
        self.assertEqual(response.status_code, status.HTTP_200_OK)


@ddt
class PackageTemplateRetreiveTest(test.APITransactionTestCase):
    def setUp(self):
        self.staff = structure_factories.UserFactory(is_staff=True)
        self.user = structure_factories.UserFactory()

    @data('staff', 'user')
    def test_user_can_retrieve_package_template(self, user):
        package_template = PackageTemplateFactory()
        self.client.force_authenticate(user=getattr(self, user))

        response = self.client.get(PackageTemplateFactory.get_url(package_template))
        self.assertEqual(response.status_code, status.HTTP_200_OK)<commit_msg>Fix imports in test_package_templates<commit_after>from ddt import ddt, data
from rest_framework import test, status

from nodeconductor.structure.tests import factories as structure_factories

from . import factories


@ddt
class PackageTemplateListTest(test.APITransactionTestCase):
    def setUp(self):
        self.staff = structure_factories.UserFactory(is_staff=True)
        self.user = structure_factories.UserFactory()

    @data('staff', 'user')
    def test_user_can_list_package_templates(self, user):
        self.client.force_authenticate(user=getattr(self, user))

        response = self.client.get(factories.PackageTemplateFactory.get_list_url())
        self.assertEqual(response.status_code, status.HTTP_200_OK)


@ddt
class PackageTemplateRetreiveTest(test.APITransactionTestCase):
    def setUp(self):
        self.staff = structure_factories.UserFactory(is_staff=True)
        self.user = structure_factories.UserFactory()

    @data('staff', 'user')
    def test_user_can_retrieve_package_template(self, user):
        package_template = factories.PackageTemplateFactory()
        self.client.force_authenticate(user=getattr(self, user))

        response = self.client.get(factories.PackageTemplateFactory.get_url(package_template))
        self.assertEqual(response.status_code, status.HTTP_200_OK)
{'fraction_non_alphanumeric': 0.090978886756238, 'fraction_numerical': 0.004606525911708253, 'mean_word_length': 4.856179775280899, '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': '681396', 'n_tokens_mistral': 782, 'n_tokens_neox': 744, 'n_words': 124}