Example #1
0
    def setUp(self):
        self.token = create_credentials()
        self.view = views.ListRepos.as_view()
        self.factory = TenantRequestFactory(self.tenant)
        self.url = '/api/v2/repos'

        mock_db_for_repos_tests()
Example #2
0
class ListTokensAPIViewTests(TenantTestCase):
    def setUp(self):
        self.factory = TenantRequestFactory(self.tenant)
        self.view = views.ListTokens.as_view()
        self.url = '/api/v2/internal/tokens/'
        self.user = CustUser.objects.create(username='******')

        key1 = APIKey.objects.create(client_id='EGI')
        self.token1 = key1.token
        key2 = APIKey.objects.create(client_id='EUDAT')
        self.token2 = key2.token

    def test_permission_denied_in_case_no_authorization(self):
        request = self.factory.get(self.url)
        response = self.view(request)
        self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)

    def test_get_get_list_of_tokens(self):
        request = self.factory.get(self.url)
        force_authenticate(request, user=self.user)
        response = self.view(request)
        # Those created later are listed first
        self.assertEqual(response.data, [{
            'name': 'EUDAT',
            'token': self.token2
        }, {
            'name': 'EGI',
            'token': self.token1
        }])
Example #3
0
class ListUsersAPIViewTests(TenantTestCase):
    def setUp(self):
        self.factory = TenantRequestFactory(self.tenant)
        self.view = views.ListUsers.as_view()
        self.url = '/api/v2/internal/users/'
        self.user = CustUser.objects.create_user(username='******',
                                                 first_name='Test',
                                                 last_name='User',
                                                 email='*****@*****.**')

        CustUser.objects.create_user(username='******',
                                     first_name='Another',
                                     last_name='User',
                                     email='*****@*****.**')

    def test_get_users(self):
        request = self.factory.get(self.url)
        force_authenticate(request, user=self.user)
        response = self.view(request)
        self.assertEqual(response.data,
                         {'result': ['another_user', 'testuser']})

    def test_get_users_permission_denied_in_case_no_authorization(self):
        request = self.factory.get(self.url)
        response = self.view(request)
        self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
Example #4
0
    def setUp(self):
        self.token = create_credentials()
        self.view = views.ListMetrics.as_view()
        self.factory = TenantRequestFactory(self.tenant)
        self.url = '/api/v2/metrics'

        mock_db_for_tagged_metrics_tests()
Example #5
0
class ListTokenForTenantAPIViewTests(TenantTestCase):
    def setUp(self):
        self.factory = TenantRequestFactory(self.tenant)
        self.view = views.ListTokenForTenant.as_view()
        self.url_base = '/api/v2/internal/tokens/'
        self.user = CustUser.objects.create(username='******')

        tenant1 = APIKey.objects.create(client_id='EGI')
        self.token1 = tenant1.token
        tenant2 = APIKey.objects.create(client_id='EUDAT')
        self.token2 = tenant2.token

    def test_permission_denied_in_case_no_authorization(self):
        request = self.factory.get(self.url_base + 'EGI')
        response = self.view(request, 'EGI')
        self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)

    def test_get_token_for_a_given_tenant(self):
        request1 = self.factory.get(self.url_base + 'EGI')
        request2 = self.factory.get(self.url_base + 'EUDAT')
        force_authenticate(request1, user=self.user)
        force_authenticate(request2, user=self.user)
        response1 = self.view(request1, 'EGI')
        response2 = self.view(request2, 'EUDAT')
        self.assertEqual(response1.data, self.token1)
        self.assertEqual(response2.data, self.token2)

    def test_get_token_in_case_tenant_is_nonexistent(self):
        request = self.factory.get(self.url_base + 'nonexisting')
        force_authenticate(request, user=self.user)
        response = self.view(request, 'nonexisting')
        self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
        self.assertEqual(response.data, {'detail': 'Tenant not found'})
Example #6
0
    def setUp(self):
        self.token = create_credentials()
        self.view = views.DetailProfile.as_view()
        self.factory = TenantRequestFactory(self.tenant)
        self.url_base = '/api/v2/profiles/'

        mock_db_for_profile_testing()
Example #7
0
    def setUp(self):
        self.factory = TenantRequestFactory(self.tenant)
        self.view = views.ListTokenForTenant.as_view()
        self.url_base = '/api/v2/internal/tokens/'
        self.user = CustUser.objects.create(username='******')

        tenant1 = APIKey.objects.create(client_id='EGI')
        self.token1 = tenant1.token
        tenant2 = APIKey.objects.create(client_id='EUDAT')
        self.token2 = tenant2.token
Example #8
0
    def setUp(self):
        self.factory = TenantRequestFactory(self.tenant)
        self.view = views.Profiles.as_view()

        self.profile = Profile.objects.create(
            name='ARGO_MON',
            version='1.0',
            vo='ops',
            description='Central ARGO-MON profile.',
            groupname='ARGO',
        )
Example #9
0
    def setUp(self):
        self.factory = TenantRequestFactory(self.tenant)
        self.view = views.MetricsInGroup.as_view()

        metric1 = Metrics.objects.create(name='org.apel.APEL-Pub', )

        metric2 = Metrics.objects.create(name='org.apel.APEL-Sync', )

        group = GroupOfMetrics.objects.create(name='EOSC', )
        group.metrics.create(name=metric1.name)
        group.metrics.create(name=metric2.name)

        GroupOfMetrics.objects.create(name='Empty_group', )
Example #10
0
    def setUp(self):
        self.factory = TenantRequestFactory(self.tenant)
        self.view = views.ListUsers.as_view()
        self.url = '/api/v2/internal/users/'
        self.user = CustUser.objects.create_user(username='******',
                                                 first_name='Test',
                                                 last_name='User',
                                                 email='*****@*****.**')

        CustUser.objects.create_user(username='******',
                                     first_name='Another',
                                     last_name='User',
                                     email='*****@*****.**')
Example #11
0
class MetricsInGroupViewTests(TenantTestCase):
    def setUp(self):
        self.factory = TenantRequestFactory(self.tenant)
        self.view = views.MetricsInGroup.as_view()

        metric1 = Metrics.objects.create(name='org.apel.APEL-Pub', )

        metric2 = Metrics.objects.create(name='org.apel.APEL-Sync', )

        group = GroupOfMetrics.objects.create(name='EOSC', )
        group.metrics.create(name=metric1.name)
        group.metrics.create(name=metric2.name)

        GroupOfMetrics.objects.create(name='Empty_group', )

    def test_get_metrics_in_group_for_a_given_group(self):

        request = self.factory.get(
            '/api/0.2/json/metrics_in_group/?group=EOSC')
        response = self.view(request)

        data = json.loads(response.content)

        self.assertEqual(
            data, {'result': ['org.apel.APEL-Pub', 'org.apel.APEL-Sync']})

    def test_get_metrics_in_group_if_no_group(self):

        request = self.factory.get('/api/0.2/json/metrics_in_group/')
        response = self.view(request)
        data = response.content

        self.assertEqual(data, b'Need the name of group')

    def test_get_metrics_in_group_if_invalid_group_name(self):

        request = self.factory.get(
            '/api/0.2/json/metrics_in_group/?group=invalidname')
        response = self.view(request)
        data = response.content

        self.assertEqual(data, b'Not a valid group.')

    def test_get_metrics_in_group_if_empty_group(self):
        request = self.factory.get(
            '/api/0.2/json/metrics_in_group/?group=Empty_group')
        response = self.view(request)
        data = json.loads(response.content)

        self.assertEqual(data, {'result': []})
Example #12
0
    def setUp(self):
        self.factory = TenantRequestFactory(self.tenant)
        self.view = views.ListMetricsInGroup.as_view()
        self.url = '/api/v2/internal/metrics/EOSC'
        self.user = CustUser.objects.create(username='******')

        metric1 = Metrics.objects.create(name='org.apel.APEL-Pub')
        metric2 = Metrics.objects.create(name='org.apel.APEL-Sync')

        group1 = GroupOfMetrics.objects.create(name='EOSC')
        group1.metrics.create(name=metric1.name)
        group1.metrics.create(name=metric2.name)

        GroupOfMetrics.objects.create(name='Empty_group')
Example #13
0
    def setUp(self):
        self.factory = TenantRequestFactory(self.tenant)
        self.view = views.ListProbes.as_view()
        self.url_base = '/api/v2/internal/probes/'
        self.user = CustUser.objects.create(username='******')

        Probe.objects.create(
            name='ams-probe',
            version='0.1.7',
            description='Probe is inspecting AMS service by trying to publish '
            'and consume randomly generated messages.',
            comment='Initial version.',
            repository='https://github.com/ARGOeu/nagios-plugins-argo',
            docurl='https://github.com/ARGOeu/nagios-plugins-argo/blob/master/'
            'README.md',
            group='ARGOTEST')
Example #14
0
class ListProbesAPIViewTests(TenantTestCase):
    def setUp(self):
        self.factory = TenantRequestFactory(self.tenant)
        self.view = views.ListProbes.as_view()
        self.url_base = '/api/v2/internal/probes/'
        self.user = CustUser.objects.create(username='******')

        Probe.objects.create(
            name='ams-probe',
            version='0.1.7',
            description='Probe is inspecting AMS service by trying to publish '
            'and consume randomly generated messages.',
            comment='Initial version.',
            repository='https://github.com/ARGOeu/nagios-plugins-argo',
            docurl='https://github.com/ARGOeu/nagios-plugins-argo/blob/master/'
            'README.md',
            group='ARGOTEST')

    def test_get_probe(self):
        request = self.factory.get(self.url_base + 'ams-probe')
        force_authenticate(request, user=self.user)
        response = self.view(request, 'ams-probe')
        self.assertEqual(
            response.data, {
                'id':
                1,
                'name':
                'ams-probe',
                'description':
                'Probe is inspecting AMS service by trying to '
                'publish and consume randomly generated '
                'messages.',
                'comment':
                'Initial version.'
            })

    def test_get_probe_permission_denied_in_case_of_no_authorization(self):
        request = self.factory.get(self.url_base + 'ams-probe')
        response = self.view(request, 'ams-probe')
        self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)

    def test_get_probe_empty_dict_in_case_of_nonexisting_probe(self):
        request = self.factory.get(self.url_base + 'nonexisting_probe')
        force_authenticate(request, user=self.user)
        response = self.view(request, 'nonexisting_probe')
        self.assertEqual(response.data, {})
Example #15
0
class ListProfileAPIViewTests(TenantTestCase):
    def setUp(self):
        self.token = create_credentials()
        self.view = views.ListProfile.as_view()
        self.factory = TenantRequestFactory(self.tenant)
        self.url = '/api/v2/profiles'

        mock_db_for_profile_testing()

    def test_list_profile_403_in_case_of_wrong_token(self):
        request = self.factory.get(self.url,
                                   **{'HTTP_X_API_KEY': 'wrong_token'})
        response = self.view(request)
        self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)

    def test_get_profiles(self):
        request = self.factory.get(self.url, **{'HTTP_X_API_KEY': self.token})
        response = self.view(request)
        self.assertEqual(response.data, [{
            'name':
            'ARGO_MON',
            'vo':
            'ops',
            'description':
            'Central ARGO-MON profile',
            'metric_instances': [{
                'metric': 'org.apel.APEL-Pub',
                'service_flavour': 'APEL'
            }, {
                'metric': 'org.apel.APEL-Sync',
                'service_flavour': 'APEL'
            }]
        }, {
            'name':
            'ARGO_MON_BIOMED',
            'vo':
            'biomed',
            'description':
            'Central ARGO-MON profile for Biomed vo',
            'metric_instances': [{
                'metric': 'org.nordugrid.ARC-CE-ARIS',
                'service_flavour': 'ARC_CE'
            }]
        }])
Example #16
0
class ListMetricsInGroupAPIViewTests(TenantTestCase):
    def setUp(self):
        self.factory = TenantRequestFactory(self.tenant)
        self.view = views.ListMetricsInGroup.as_view()
        self.url = '/api/v2/internal/metrics/EOSC'
        self.user = CustUser.objects.create(username='******')

        metric1 = Metrics.objects.create(name='org.apel.APEL-Pub')
        metric2 = Metrics.objects.create(name='org.apel.APEL-Sync')

        group1 = GroupOfMetrics.objects.create(name='EOSC')
        group1.metrics.create(name=metric1.name)
        group1.metrics.create(name=metric2.name)

        GroupOfMetrics.objects.create(name='Empty_group')

    def test_permission_denied_in_case_no_authorization(self):
        request = self.factory.get(self.url)
        response = self.view(request)
        self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)

    def test_status_code_in_case_nonexisting_site(self):
        url = '/api/v2/internal/metrics/fake_group'
        request = self.factory.get(url)
        force_authenticate(request, user=self.user)
        response = self.view(request, 'fake_group')
        self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)

    def test_get_metrics_in_group_for_a_given_group(self):
        request = self.factory.get(self.url)
        force_authenticate(request, user=self.user)
        response = self.view(request, 'EOSC')
        self.assertEqual(
            response.data,
            {'result': ['org.apel.APEL-Pub', 'org.apel.APEL-Sync']})

    def test_get_metrics_in_group_if_empty_group(self):
        url = '/api/v2/internal/metrics/Empty_group'
        request = self.factory.get(url)
        force_authenticate(request, user=self.user)
        response = self.view(request, 'Empty_group')
        self.assertEqual(response.data, {'result': []})
Example #17
0
class DetailProfileAPIViewTests(TenantTestCase):
    def setUp(self):
        self.token = create_credentials()
        self.view = views.DetailProfile.as_view()
        self.factory = TenantRequestFactory(self.tenant)
        self.url_base = '/api/v2/profiles/'

        mock_db_for_profile_testing()

    def test_detail_profile_403_in_case_of_wrong_token(self):
        request = self.factory.get(self.url_base + 'ARGO_MON',
                                   **{'HTTP_X_API_KEY': 'wrong_token'})
        response = self.view(request, 'ARGO_MON')
        self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)

    def test_get_detail_profile(self):
        request = self.factory.get(self.url_base + 'ARGO_MON',
                                   **{'HTTP_X_API_KEY': self.token})
        response = self.view(request, **{'name': 'ARGO_MON'})
        self.assertEqual(
            response.data, {
                'name':
                'ARGO_MON',
                'vo':
                'ops',
                'description':
                'Central ARGO-MON profile',
                'metric_instances': [{
                    'metric': 'org.apel.APEL-Pub',
                    'service_flavour': 'APEL'
                }, {
                    'metric': 'org.apel.APEL-Sync',
                    'service_flavour': 'APEL'
                }]
            })

    def test_detail_profile_404_code_if_wrong_name(self):
        request = self.factory.get(self.url_base + 'FAKE_GROUP',
                                   **{'HTTP_X_API_KEY': self.token})
        response = self.view(request, **{'name': 'FAKE_GROUP'})
        self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
Example #18
0
class ListMetricsAPIViewTests(TenantTestCase):
    def setUp(self):
        self.token = create_credentials()
        self.view = views.ListMetrics.as_view()
        self.factory = TenantRequestFactory(self.tenant)
        self.url = '/api/v2/metrics'

        mock_db_for_tagged_metrics_tests()

    def test_list_metrics_if_wrong_token(self):
        request = self.factory.get(self.url,
                                   **{'HTTP_X_API_KEY': 'wrong_token'})
        response = self.view(request)
        self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)

    def test_list_metrics(self):
        request = self.factory.get(self.url, **{'HTTP_X_API_KEY': self.token})
        response = self.view(request)
        self.assertEqual(response.data, [{
            'argo.AMS-Check': {
                'probe':
                'ams-probe',
                'config': {
                    'maxCheckAttempts': '3',
                    'timeout': '60',
                    'path': '/usr/libexec/argo-monitoring/probes/argo',
                    'interval': '5',
                    'retryInterval': '3'
                },
                'flags': {
                    'OBSESS': '1'
                },
                'dependency': {
                    'argo.AMS-Check': '1'
                },
                'attribute': {
                    'argo.ams_TOKEN': '--token'
                },
                'parameter': {
                    '--project': 'EGI'
                },
                'file_parameter': {
                    'FILE_SIZE_KBS': '1000'
                },
                'file_attribute': {
                    'UCC_CONFIG': 'UCC_CONFIG'
                },
                'parent':
                'org.nagios.CDMI-TCP',
                'docurl':
                'https://github.com/ARGOeu/nagios-plugins-argo'
                '/blob/master/README.md'
            }
        }, {
            'argo.AMSPublisher-Check': {
                'probe': '',
                'config': {},
                'flags': {},
                'dependency': {},
                'attribute': {},
                'parameter': {},
                'file_parameter': {},
                'file_attribute': {},
                'parent': '',
                'docurl': ''
            }
        }])
Example #19
0
    def setUp(self):

        self.factory = TenantRequestFactory(self.tenant)
        self.view = views.Metrics.as_view()

        user = CustUser.objects.create_user(username='******')

        tag = Tags.objects.create(name='prod', )

        tag2 = Tags.objects.create(name='test_none', )

        Tags.objects.create(name='test_empty', )

        metrictype = MetricType.objects.create(name='active', )

        Revision.objects.create(
            id=1,
            comment='Initial_version',
            date_created=datetime.datetime(2015, 1, 1, 0, 0, 0),
            user_id=user.id,
        )

        probekey = Version.objects.create(
            object_repr='ams_probe (0.1.7)',
            serialized_data=json.dumps([{
                'model': 'poem.probe',
                'fields': {
                    'comment':
                    'Initial version',
                    'group':
                    'EOSC',
                    'version':
                    '0.1.7',
                    'docurl':
                    'https://github.com/ARGOeu/nagios-plugins-argo'
                    '/blob/master/README.md'
                }
            }]),
            content_type_id='1',
            revision_id='1',
        )

        metric = Metric.objects.create(
            name='argo.AMS-Check',
            tag=tag,
            mtype=metrictype,
            probekey=probekey,
        )

        metric2 = Metric.objects.create(
            name='argo.API-Check',
            tag=tag2,
            mtype=metrictype,
        )

        group = GroupOfMetrics.objects.create(name='EOSC', )
        group.metrics.create(name=metric.name)

        MetricParent.objects.create(
            metric=metric,
            value='org.nagios.CDMI-TCP',
        )

        MetricParent.objects.create(
            metric=metric2,
            value=None,
        )

        MetricProbeExecutable.objects.create(
            metric=metric,
            value='ams-probe',
        )

        MetricProbeExecutable.objects.create(
            metric=metric2,
            value=None,
        )

        MetricConfig.objects.create(
            key='maxCheckAttempts',
            value='3',
            metric=metric,
        )

        MetricConfig.objects.create(
            key='timeout',
            value='60',
            metric=metric,
        )

        MetricConfig.objects.create(
            key='path',
            value='/usr/libexec/argo-monitoring/probes/argo',
            metric=metric,
        )

        MetricConfig.objects.create(
            key='interval',
            value='5',
            metric=metric,
        )

        MetricConfig.objects.create(
            key='retryInterval',
            value='3',
            metric=metric,
        )

        MetricConfig.objects.create(
            key=None,
            value=None,
            metric=metric2,
        )

        MetricAttribute.objects.create(
            key='argo.ams_TOKEN',
            value='--token',
            metric=metric,
        )

        MetricDependancy.objects.create(
            key='argo.AMS-Check',
            value='1',
            metric=metric,
        )

        MetricFlags.objects.create(
            key='OBSESS',
            value='1',
            metric=metric,
        )

        MetricFiles.objects.create(
            key='UCC_CONFIG',
            value='UCC_CONFIG',
            metric=metric,
        )

        MetricParameter.objects.create(
            key='--project',
            value='EGI',
            metric=metric,
        )

        MetricFileParameter.objects.create(
            key='FILE_SIZE_KBS',
            value='1000',
            metric=metric,
        )
Example #20
0
class MetricsViewTests(TenantTestCase):
    def setUp(self):

        self.factory = TenantRequestFactory(self.tenant)
        self.view = views.Metrics.as_view()

        user = CustUser.objects.create_user(username='******')

        tag = Tags.objects.create(name='prod', )

        tag2 = Tags.objects.create(name='test_none', )

        Tags.objects.create(name='test_empty', )

        metrictype = MetricType.objects.create(name='active', )

        Revision.objects.create(
            id=1,
            comment='Initial_version',
            date_created=datetime.datetime(2015, 1, 1, 0, 0, 0),
            user_id=user.id,
        )

        probekey = Version.objects.create(
            object_repr='ams_probe (0.1.7)',
            serialized_data=json.dumps([{
                'model': 'poem.probe',
                'fields': {
                    'comment':
                    'Initial version',
                    'group':
                    'EOSC',
                    'version':
                    '0.1.7',
                    'docurl':
                    'https://github.com/ARGOeu/nagios-plugins-argo'
                    '/blob/master/README.md'
                }
            }]),
            content_type_id='1',
            revision_id='1',
        )

        metric = Metric.objects.create(
            name='argo.AMS-Check',
            tag=tag,
            mtype=metrictype,
            probekey=probekey,
        )

        metric2 = Metric.objects.create(
            name='argo.API-Check',
            tag=tag2,
            mtype=metrictype,
        )

        group = GroupOfMetrics.objects.create(name='EOSC', )
        group.metrics.create(name=metric.name)

        MetricParent.objects.create(
            metric=metric,
            value='org.nagios.CDMI-TCP',
        )

        MetricParent.objects.create(
            metric=metric2,
            value=None,
        )

        MetricProbeExecutable.objects.create(
            metric=metric,
            value='ams-probe',
        )

        MetricProbeExecutable.objects.create(
            metric=metric2,
            value=None,
        )

        MetricConfig.objects.create(
            key='maxCheckAttempts',
            value='3',
            metric=metric,
        )

        MetricConfig.objects.create(
            key='timeout',
            value='60',
            metric=metric,
        )

        MetricConfig.objects.create(
            key='path',
            value='/usr/libexec/argo-monitoring/probes/argo',
            metric=metric,
        )

        MetricConfig.objects.create(
            key='interval',
            value='5',
            metric=metric,
        )

        MetricConfig.objects.create(
            key='retryInterval',
            value='3',
            metric=metric,
        )

        MetricConfig.objects.create(
            key=None,
            value=None,
            metric=metric2,
        )

        MetricAttribute.objects.create(
            key='argo.ams_TOKEN',
            value='--token',
            metric=metric,
        )

        MetricDependancy.objects.create(
            key='argo.AMS-Check',
            value='1',
            metric=metric,
        )

        MetricFlags.objects.create(
            key='OBSESS',
            value='1',
            metric=metric,
        )

        MetricFiles.objects.create(
            key='UCC_CONFIG',
            value='UCC_CONFIG',
            metric=metric,
        )

        MetricParameter.objects.create(
            key='--project',
            value='EGI',
            metric=metric,
        )

        MetricFileParameter.objects.create(
            key='FILE_SIZE_KBS',
            value='1000',
            metric=metric,
        )

    def test_get_metric_for_a_given_tag_with_all_fields(self):
        request = self.factory.get('/api/0.2/json/metrics/?tag=prod')
        response = self.view(request)
        data = json.loads(response.content)

        self.assertEqual(data, [{
            'argo.AMS-Check': {
                'probe':
                'ams-probe',
                'config': {
                    'maxCheckAttempts': '3',
                    'timeout': '60',
                    'path': '/usr/libexec/argo-monitoring/probes/argo',
                    'interval': '5',
                    'retryInterval': '3'
                },
                'flags': {
                    'OBSESS': '1'
                },
                'dependency': {
                    'argo.AMS-Check': '1'
                },
                'attribute': {
                    'argo.ams_TOKEN': '--token'
                },
                'parameter': {
                    '--project': 'EGI'
                },
                'file_parameter': {
                    'FILE_SIZE_KBS': '1000'
                },
                'file_attribute': {
                    'UCC_CONFIG': 'UCC_CONFIG'
                },
                'parent':
                'org.nagios.CDMI-TCP',
                'docurl':
                'https://github.com/ARGOeu/nagios-plugins-argo'
                '/blob/master/README.md'
            }
        }])

    def test_get_metric_with_no_tag(self):
        request = self.factory.get('/api/0.2/json/metrics/')
        response = self.view(request)
        data = response.content

        self.assertEqual(data, b'Need the name of tag.')

    def test_get_metric_with_invalid_tag(self):
        request = self.factory.get('/api/0.2/json/metrics/?tag=invalidtag')
        response = self.view(request)
        data = response.content

        self.assertEqual(data, b'Not a valid tag.')

    def test_get_metric_with_all_empty_fields(self):
        request = self.factory.get('/api/0.2/json/metrics/?tag=test_none')
        response = self.view(request)
        data = json.loads(response.content)

        self.assertEqual(data, [{
            'argo.API-Check': {
                'probe': '',
                'config': {},
                'flags': {},
                'dependency': {},
                'attribute': {},
                'parameter': {},
                'file_parameter': {},
                'file_attribute': {},
                'parent': '',
                'docurl': ''
            }
        }])

    def test_get_metrics_if_tag_without_associated_metrics(self):
        request = self.factory.get('/api/0.2/json/metrics/?tag=test_empty')
        response = self.view(request)
        data = json.loads(response.content)

        self.assertEqual(data, [])
Example #21
0
    def setUp(self):
        self.factory = TenantRequestFactory(self.tenant)
        self.view = views.MetricsInProfiles.as_view()

        profile1 = Profile.objects.create(
            name='ARGO_MON_CRITICAL',
            description='Central ARGO-MON_CRITICAL profile.',
            vo='ops',
            groupname='ARGO',
        )

        profile2 = Profile.objects.create(
            name='ARGO_MON_BIOMED',
            description='Central ARGO-MON profile used for Biomed VO.',
            vo='biomed',
            groupname='ARGO',
        )

        profile3 = Profile.objects.create(
            name='ARGO_MON',
            description='Central ARGO-MON profile.',
            vo='ops',
            groupname='ARGO',
        )

        profile4 = Profile.objects.create(
            name='TEST_PROFILE',
            description=None,
            vo='test',
            groupname='ARGO',
        )

        Profile.objects.create(
            name='TEST_EMPTY_PROFILE',
            description='Profiles with no metrics associated with them.',
            vo='test_empty',
            groupname='ARGO',
        )

        MetricInstance.objects.create(
            profile=profile1,
            service_flavour='ARC-CE',
            metric='org.nordugrid.ARC-CE-ARIS',
            fqan=None,
        )

        MetricInstance.objects.create(
            profile=profile1,
            service_flavour='APEL',
            metric='org.apel.APEL-Pub',
            fqan=None,
        )

        MetricInstance.objects.create(
            profile=profile2,
            service_flavour='CREAM-CE',
            metric='emi.cream.CREAMCE-AllowedSubmission',
            fqan=None,
        )

        MetricInstance.objects.create(
            profile=profile3,
            service_flavour='APEL',
            metric='org.apel.APEL-Pub',
            fqan=None,
        )

        MetricInstance.objects.create(
            profile=profile4,
            service_flavour='TEST-FLAVOUR',
            metric='metric.for.testing',
            fqan=None,
        )
Example #22
0
class MetricsInProfilesVIewTests(TenantTestCase):
    def setUp(self):
        self.factory = TenantRequestFactory(self.tenant)
        self.view = views.MetricsInProfiles.as_view()

        profile1 = Profile.objects.create(
            name='ARGO_MON_CRITICAL',
            description='Central ARGO-MON_CRITICAL profile.',
            vo='ops',
            groupname='ARGO',
        )

        profile2 = Profile.objects.create(
            name='ARGO_MON_BIOMED',
            description='Central ARGO-MON profile used for Biomed VO.',
            vo='biomed',
            groupname='ARGO',
        )

        profile3 = Profile.objects.create(
            name='ARGO_MON',
            description='Central ARGO-MON profile.',
            vo='ops',
            groupname='ARGO',
        )

        profile4 = Profile.objects.create(
            name='TEST_PROFILE',
            description=None,
            vo='test',
            groupname='ARGO',
        )

        Profile.objects.create(
            name='TEST_EMPTY_PROFILE',
            description='Profiles with no metrics associated with them.',
            vo='test_empty',
            groupname='ARGO',
        )

        MetricInstance.objects.create(
            profile=profile1,
            service_flavour='ARC-CE',
            metric='org.nordugrid.ARC-CE-ARIS',
            fqan=None,
        )

        MetricInstance.objects.create(
            profile=profile1,
            service_flavour='APEL',
            metric='org.apel.APEL-Pub',
            fqan=None,
        )

        MetricInstance.objects.create(
            profile=profile2,
            service_flavour='CREAM-CE',
            metric='emi.cream.CREAMCE-AllowedSubmission',
            fqan=None,
        )

        MetricInstance.objects.create(
            profile=profile3,
            service_flavour='APEL',
            metric='org.apel.APEL-Pub',
            fqan=None,
        )

        MetricInstance.objects.create(
            profile=profile4,
            service_flavour='TEST-FLAVOUR',
            metric='metric.for.testing',
            fqan=None,
        )

    def test_get_metrics_for_a_given_vo(self):
        with mock.patch('Poem.poem.views.poem_namespace',
                        return_value='hr.cro-ngi.TEST'):
            request = self.factory.get(
                '/api/0.2/json/metrics_in_profiles/?vo_name=ops')
            response = self.view(request)
            data = json.loads(response.content)

            # sorting list of profiles because they are not always obtained in
            # the same order from api
            data[0]['profiles'] = sorted(data[0]['profiles'],
                                         key=lambda k: k['name'])
            self.assertEqual(data, [{
                'name': ['ops'],
                'profiles': [{
                    'name':
                    'ARGO_MON',
                    'namespace':
                    'hr.cro-ngi.TEST',
                    'description':
                    'Central ARGO-MON profile.',
                    'vo':
                    'ops',
                    'metrics': [{
                        'service_flavour': 'APEL',
                        'name': 'org.apel.APEL-Pub',
                        'fqan': ''
                    }]
                }, {
                    'name':
                    'ARGO_MON_CRITICAL',
                    'namespace':
                    'hr.cro-ngi.TEST',
                    'description':
                    'Central ARGO-MON_CRITICAL '
                    'profile.',
                    'vo':
                    'ops',
                    'metrics': [{
                        'service_flavour': 'APEL',
                        'name': 'org.apel.APEL-Pub',
                        'fqan': ''
                    }, {
                        'service_flavour': 'ARC-CE',
                        'name': 'org.nordugrid.ARC-CE-ARIS',
                        'fqan': ''
                    }]
                }]
            }])

    def test_get_metrics_for_multiple_vos(self):
        with mock.patch('Poem.poem.views.poem_namespace',
                        return_value='hr.cro-ngi.TEST'):
            request = self.factory.get(
                '/api/0.2/json/metrics_in_profiles/?vo_name=ops&vo_name=biomed'
            )
            response = self.view(request)
            data = json.loads(response.content)

            # sorting list of profiles because they are not always obtained in
            # the same order from api
            data[0]['profiles'] = sorted(data[0]['profiles'],
                                         key=lambda k: k['name'])

            self.assertEqual(data, [{
                'name': ['ops', 'biomed'],
                'profiles': [{
                    'name':
                    'ARGO_MON',
                    'namespace':
                    'hr.cro-ngi.TEST',
                    'description':
                    'Central ARGO-MON profile.',
                    'vo':
                    'ops',
                    'metrics': [{
                        'service_flavour': 'APEL',
                        'name': 'org.apel.APEL-Pub',
                        'fqan': ''
                    }]
                }, {
                    'name':
                    'ARGO_MON_BIOMED',
                    'namespace':
                    'hr.cro-ngi.TEST',
                    'description':
                    'Central ARGO-MON profile used '
                    'for Biomed VO.',
                    'vo':
                    'biomed',
                    'metrics': [{
                        'service_flavour': 'CREAM-CE',
                        'name': 'emi.cream.CREAMCE-'
                        'AllowedSubmission',
                        'fqan': ''
                    }]
                }, {
                    'name':
                    'ARGO_MON_CRITICAL',
                    'namespace':
                    'hr.cro-ngi.TEST',
                    'description':
                    'Central ARGO-MON_CRITICAL '
                    'profile.',
                    'vo':
                    'ops',
                    'metrics': [{
                        'service_flavour': 'APEL',
                        'name': 'org.apel.APEL-Pub',
                        'fqan': ''
                    }, {
                        'service_flavour': 'ARC-CE',
                        'name': 'org.nordugrid.ARC-CE-ARIS',
                        'fqan': ''
                    }]
                }]
            }])

    def test_get_metrics_for_a_given_vo_and_a_given_profile(self):
        with mock.patch('Poem.poem.views.poem_namespace',
                        return_value='hr.cro-ngi.TEST'):
            request = self.factory.get('/api/0.2/json/metrics_in_profiles/'
                                       '?vo_name=ops&profile=ARGO_MON')
            response = self.view(request)
            data = json.loads(response.content)

            self.assertEqual(data, [{
                'name': ['ops'],
                'profiles': [{
                    'name':
                    'ARGO_MON',
                    'namespace':
                    'hr.cro-ngi.TEST',
                    'description':
                    'Central ARGO-MON profile.',
                    'vo':
                    'ops',
                    'metrics': [{
                        'service_flavour': 'APEL',
                        'name': 'org.apel.APEL-Pub',
                        'fqan': ''
                    }]
                }]
            }])

    def test_get_metrics_for_a_given_vo_and_multiple_profiles(self):
        with mock.patch('Poem.poem.views.poem_namespace',
                        return_value='hr.cro-ngi.TEST'):
            request = self.factory.get(
                '/api/0.2/json/metrics_in_profiles/?vo_name=ops&profile='
                'ARGO_MON&profile=ARGO_MON_CRITICAL')
            response = self.view(request)
            data = json.loads(response.content)

            data[0]['profiles'] = sorted(data[0]['profiles'],
                                         key=lambda k: k['name'])

            self.assertEqual(data, [{
                'name': ['ops'],
                'profiles': [{
                    'name':
                    'ARGO_MON',
                    'namespace':
                    'hr.cro-ngi.TEST',
                    'description':
                    'Central ARGO-MON profile.',
                    'vo':
                    'ops',
                    'metrics': [{
                        'service_flavour': 'APEL',
                        'name': 'org.apel.APEL-Pub',
                        'fqan': ''
                    }]
                }, {
                    'name':
                    'ARGO_MON_CRITICAL',
                    'namespace':
                    'hr.cro-ngi.TEST',
                    'description':
                    'Central ARGO-MON_CRITICAL '
                    'profile.',
                    'vo':
                    'ops',
                    'metrics': [{
                        'service_flavour': 'APEL',
                        'name': 'org.apel.APEL-Pub',
                        'fqan': ''
                    }, {
                        'service_flavour': 'ARC-CE',
                        'name': 'org.nordugrid.ARC-CE-ARIS',
                        'fqan': ''
                    }]
                }]
            }])

    def test_get_metrics_for_multiple_vos_and_multiple_profiles(self):
        with mock.patch('Poem.poem.views.poem_namespace',
                        return_value='hr.cro-ngi.TEST'):
            request = self.factory.get(
                '/api/0.2/json/metrics_in_profiles/?vo_name=ops&vo_name=biomed'
                '&profile=ARGO_MON&profile=ARGO_MON_BIOMED')
            response = self.view(request)
            data = json.loads(response.content)

            data[0]['profiles'] = sorted(data[0]['profiles'],
                                         key=lambda k: k['name'])

            self.assertEqual(data, [{
                'name': ['ops', 'biomed'],
                'profiles': [{
                    'name':
                    'ARGO_MON',
                    'namespace':
                    'hr.cro-ngi.TEST',
                    'description':
                    'Central ARGO-MON profile.',
                    'vo':
                    'ops',
                    'metrics': [{
                        'service_flavour': 'APEL',
                        'name': 'org.apel.APEL-Pub',
                        'fqan': ''
                    }]
                }, {
                    'name':
                    'ARGO_MON_BIOMED',
                    'namespace':
                    'hr.cro-ngi.TEST',
                    'description':
                    'Central ARGO-MON profile '
                    'used for Biomed VO.',
                    'vo':
                    'biomed',
                    'metrics': [{
                        'service_flavour': 'CREAM-CE',
                        'name': 'emi.cream.CREAMCE-Allowed'
                        'Submission',
                        'fqan': ''
                    }]
                }]
            }])

    def test_get_metrics_without_vo(self):
        with mock.patch('Poem.poem.views.poem_namespace',
                        return_value='hr.cro-ngi.TEST'):
            request = self.factory.get('/api/0.2/json/metrics_in_profiles/')
            response = self.view(request)

            self.assertEqual(response.content, b'Need the name of VO')

    def test_get_metric_with_no_valid_vo(self):
        with mock.patch('Poem.poem.views.poem_namespace',
                        return_value='hr.cro-ngi.TEST'):
            request = self.factory.get(
                '/api/0.2/json/metrics_in_profiles/?vo_name=bla')
            response = self.view(request)

            self.assertEqual(response.content, b'Not valid VO')

    def test_get_metric_with_no_namespace(self):
        with mock.patch('Poem.poem.views.poem_namespace', return_value=None):
            request = self.factory.get(
                '/api/0.2/json/metrics_in_profiles/?vo_name=ops')
            response = self.view(request)

            data = json.loads(response.content)
            data[0]['profiles'] = sorted(data[0]['profiles'],
                                         key=lambda k: k['name'])
            self.assertEqual(data, [{
                'name': ['ops'],
                'profiles': [{
                    'name':
                    'ARGO_MON',
                    'namespace':
                    '',
                    'description':
                    'Central ARGO-MON profile.',
                    'vo':
                    'ops',
                    'metrics': [{
                        'service_flavour': 'APEL',
                        'name': 'org.apel.APEL-Pub',
                        'fqan': ''
                    }]
                }, {
                    'name':
                    'ARGO_MON_CRITICAL',
                    'namespace':
                    '',
                    'description':
                    'Central ARGO-MON_CRITICAL '
                    'profile.',
                    'vo':
                    'ops',
                    'metrics': [{
                        'service_flavour': 'APEL',
                        'name': 'org.apel.APEL-Pub',
                        'fqan': ''
                    }, {
                        'service_flavour': 'ARC-CE',
                        'name': 'org.nordugrid.ARC-CE-ARIS',
                        'fqan': ''
                    }]
                }]
            }])

    def test_get_metrics_with_no_profile_description(self):
        with mock.patch('Poem.poem.views.poem_namespace',
                        return_value='hr.cro-ngi.TEST'):
            request = self.factory.get(
                '/api/0.2/json/metrics_in_profiles/?vo_name=test')
            response = self.view(request)

            data = json.loads(response.content)

            self.assertEqual(data, [{
                'name': ['test'],
                'profiles': [{
                    'name':
                    'TEST_PROFILE',
                    'namespace':
                    'hr.cro-ngi.TEST',
                    'description':
                    '',
                    'vo':
                    'test',
                    'metrics': [{
                        'service_flavour': 'TEST-FLAVOUR',
                        'name': 'metric.for.testing',
                        'fqan': ''
                    }]
                }]
            }])

    def test_get_metrics_if_no_metrics_exist_for_the_given_vo(self):
        with mock.patch('Poem.poem.views.poem_namespace',
                        return_value='hr.cro-ngi.TEST'):
            request = self.factory.get(
                '/api/0.2/json/metrics_in_profiles/?vo_name=test_empty')
            response = self.view(request)
            data = json.loads(response.content)

            self.assertEqual(data, [{
                'name': ['test_empty'],
                'profiles': [{
                    'name': 'TEST_EMPTY_PROFILE',
                    'namespace': 'hr.cro-ngi.TEST',
                    'description': 'Profiles with no metrics '
                    'associated with them.',
                    'vo': 'test_empty',
                    'metrics': []
                }]
            }])
Example #23
0
class ProfileViewsTests(TenantTestCase):
    def setUp(self):
        self.factory = TenantRequestFactory(self.tenant)
        self.view = views.Profiles.as_view()

        self.profile = Profile.objects.create(
            name='ARGO_MON',
            version='1.0',
            vo='ops',
            description='Central ARGO-MON profile.',
            groupname='ARGO',
        )

    def test_get_profiles(self):

        MetricInstance.objects.create(
            profile=self.profile,
            service_flavour='APEL',
            metric='org.apel.APEL-Pub',
            vo='ops',
            fqan='fqan_text',
        )
        request = self.factory.get('/api/0.2/json/profiles')
        response = self.view(request)
        data = json.loads(response.content)
        self.assertEqual(data, [{
            'name':
            'ARGO_MON',
            'atp_vo':
            'ops',
            'version':
            '1.0',
            'description':
            'Central ARGO-MON profile.',
            'metric_instances': [{
                'metric': 'org.apel.APEL-Pub',
                'fqan': 'fqan_text',
                'vo': 'ops',
                'atp_service_type_flavour': 'APEL'
            }]
        }])

    def test_get_profiles_with_no_fqan(self):

        MetricInstance.objects.create(
            profile=self.profile,
            service_flavour='APEL',
            metric='org.apel.APEL-Pub',
            vo='ops',
            fqan=None,
        )
        request = self.factory.get('/api/0.2/json/profiles')
        response = self.view(request)
        data = json.loads(response.content)

        self.assertEqual(data, [{
            'name':
            'ARGO_MON',
            'atp_vo':
            'ops',
            'version':
            '1.0',
            'description':
            'Central ARGO-MON profile.',
            'metric_instances': [{
                'metric': 'org.apel.APEL-Pub',
                'fqan': '',
                'vo': 'ops',
                'atp_service_type_flavour': 'APEL'
            }]
        }])

    def test_get_profiles_with_no_profile_description(self):
        profile2 = Profile.objects.create(
            name='ARGO_MON_BIOMED',
            version='1.0',
            vo='biomed',
            description=None,
            groupname='ARGO',
        )

        MetricInstance.objects.create(
            profile=self.profile,
            service_flavour='APEL',
            metric='org.apel.APEL-Pub',
            vo='ops',
            fqan='fqan_text',
        )

        MetricInstance.objects.create(
            profile=profile2,
            service_flavour='APEL',
            metric='org.apel.APEL-Sync',
            fqan='something',
        )

        request = self.factory.get('/api/0.2/json/profiles')
        response = self.view(request)
        data = json.loads(response.content)

        # sorting list of profiles because they are not always obtained in
        # the same order from api
        data = sorted(data, key=lambda k: k['name'])

        self.assertEqual(data, [{
            'name':
            'ARGO_MON',
            'atp_vo':
            'ops',
            'version':
            '1.0',
            'description':
            'Central ARGO-MON profile.',
            'metric_instances': [{
                'metric': 'org.apel.APEL-Pub',
                'fqan': 'fqan_text',
                'vo': 'ops',
                'atp_service_type_flavour': 'APEL'
            }]
        }, {
            'name':
            'ARGO_MON_BIOMED',
            'atp_vo':
            'biomed',
            'version':
            '1.0',
            'description':
            '',
            'metric_instances': [{
                'metric': 'org.apel.APEL-Sync',
                'fqan': 'something',
                'vo': 'biomed',
                'atp_service_type_flavour': 'APEL'
            }]
        }])
Example #24
0
class ListReposAPIViewTests(TenantTestCase):
    def setUp(self):
        self.token = create_credentials()
        self.view = views.ListRepos.as_view()
        self.factory = TenantRequestFactory(self.tenant)
        self.url = '/api/v2/repos'

        mock_db_for_repos_tests()

    def test_list_repos_if_wrong_token(self):
        request = self.factory.get(
            self.url + '/centos7', **{
                'HTTP_X_API_KEY': 'wrong_token',
                'HTTP_PROFILES': '[ARGO-MON, MON-TEST]'
            })
        response = self.view(request, 'centos7')
        self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)

    @patch('Poem.api.views.get_metrics_from_profile',
           side_effect=mock_function)
    def test_list_repos(self, func):
        request = self.factory.get(
            self.url + '/centos7', **{
                'HTTP_X_API_KEY': self.token,
                'HTTP_PROFILES': '[ARGO-MON, MON-TEST]'
            })
        response = self.view(request, 'centos7')
        test_data = response.data
        test_data[0]['repo-1']['packages'] = sorted(
            test_data[0]['repo-1']['packages'], key=lambda k: k['name'])
        self.assertEqual(test_data, [{
            'repo-1': {
                'content':
                'content3\ncontent4\n',
                'packages': [{
                    'name': 'nagios-plugins-argo',
                    'version': '0.1.11'
                }, {
                    'name': 'nagios-plugins-seadatacloud-nvs2',
                    'version': '1.0.1'
                }]
            },
            'repo-2': {
                'content': 'content7\ncontent8',
                'packages': [{
                    'name': 'nagios-plugins-http',
                    'version': 'present'
                }]
            }
        }])

    def test_list_repos_if_no_profile_or_tag(self):
        request = self.factory.get(
            self.url, **{
                'HTTP_X_API_KEY': self.token,
                'HTTP_PROFILES': '[ARGO-MON, MON-TEST]'
            })
        response = self.view(request)
        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
        self.assertEqual(response.data, {'detail': 'You must define OS!'})

    def test_list_repos_if_no_profile_defined(self):
        request = self.factory.get(self.url + '/centos7',
                                   **{'HTTP_X_API_KEY': self.token})
        response = self.view(request, 'centos7')
        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
        self.assertEqual(response.data, {'detail': 'You must define profile!'})

    @patch('Poem.api.views.get_metrics_from_profile',
           side_effect=mock_function)
    def test_list_repos_if_passive_metric_present(self, func):
        request = self.factory.get(
            self.url + '/centos6', **{
                'HTTP_X_API_KEY': self.token,
                'HTTP_PROFILES': '[ARGO-MON, MON-TEST]'
            })
        response = self.view(request, 'centos6')
        self.assertEqual(response.data, [{
            'repo-1': {
                'content': 'content1\ncontent2\n',
                'packages': [{
                    'name': 'nagios-plugins-argo',
                    'version': '0.1.11'
                }]
            },
            'repo-2': {
                'content': 'content5\ncontent6',
                'packages': [{
                    'name': 'nagios-plugins-http',
                    'version': 'present'
                }]
            }
        }])

    @patch('Poem.api.views.get_metrics_from_profile',
           side_effect=mock_function)
    def test_empty_repo_list(self, func):
        request = self.factory.get(
            self.url + '/centos6', **{
                'HTTP_X_API_KEY': self.token,
                'HTTP_PROFILES': '[EMPTY]'
            })
        response = self.view(request, 'centos6')
        self.assertEqual(response.data, [])

    @patch('Poem.api.views.get_metrics_from_profile',
           side_effect=mock_function)
    def test_list_repos_if_nonexisting_tag(self, func):
        request = self.factory.get(
            self.url + '/nonexisting', **{
                'HTTP_X_API_KEY': self.token,
                'HTTP_PROFILES': '[ARGO-MON, MON-TEST]'
            })
        response = self.view(request, 'nonexisting')
        self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
        self.assertEqual(response.data, {'detail': 'YUM repo tag not found.'})

    @patch('Poem.api.views.get_metrics_from_profile',
           side_effect=mock_function)
    def test_list_repos_if_function_return_metric_does_not_exist(self, func):
        request = self.factory.get(
            self.url + '/centos6', **{
                'HTTP_X_API_KEY': self.token,
                'HTTP_PROFILES': '[ARGO-MON, MON-TEST, TEST-NONEXISTING]'
            })
        response = self.view(request, 'centos6')
        self.assertEqual(response.data, [{
            'repo-1': {
                'content': 'content1\ncontent2\n',
                'packages': [{
                    'name': 'nagios-plugins-argo',
                    'version': '0.1.11'
                }]
            },
            'repo-2': {
                'content': 'content5\ncontent6',
                'packages': [{
                    'name': 'nagios-plugins-http',
                    'version': 'present'
                }]
            }
        }])

    @patch('Poem.api.views.get_metrics_from_profile',
           side_effect=mock_function)
    def test_list_repos_if_version_is_the_right_os(self, func):
        request = self.factory.get(
            self.url + '/centos6', **{
                'HTTP_X_API_KEY': self.token,
                'HTTP_PROFILES': '[TEST_PROMOO]'
            })
        response = self.view(request, 'centos6')
        self.assertEqual(response.data, [{
            'promoo': {
                'content': 'content9\ncontent10',
                'packages': [{
                    'name': 'nagios-promoo',
                    'version': '1.4.0'
                }]
            }
        }])

    @patch('Poem.api.views.get_metrics_from_profile',
           side_effect=mock_function)
    def test_list_repos_if_version_is_wrong_os(self, func):
        request = self.factory.get(
            self.url + '/centos6', **{
                'HTTP_X_API_KEY': self.token,
                'HTTP_PROFILES': '[TEST_PROMOO]'
            })
        response = self.view(request, 'centos7')
        self.assertEqual(response.data, [])