コード例 #1
0
 def test_slo_detail_with_method_not_allowed(self):
     """ Test that POST requests to slo_detail() return METHOD_NOT_ALLOWED """
     dsl_filter = 'bandwidth'
     slo_name = 'get_bw'
     target = 'AUTH_0123456789abcdef#1'
     request = self.factory.post('/filters/slo/' + dsl_filter + '/' + slo_name + '/' + target)
     response = slo_detail(request, dsl_filter, slo_name, target)
     self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)
コード例 #2
0
    def test_slo_detail_when_does_not_exist(self):
        """ Test that a GET request to slo_detail() returns 404 if the slo does not exist """

        dsl_filter = 'bandwidth'
        slo_name = 'get_bw'
        target = 'inexistent'
        request = self.factory.get('/filters/slo/' + dsl_filter + '/' + slo_name + '/' + target)
        response = slo_detail(request, dsl_filter, slo_name, target)
        self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
コード例 #3
0
    def test_update_slo_ok(self):
        """ Test that a PUT request to slo_detail() returns OK """

        dsl_filter = 'bandwidth'
        slo_name = 'get_bw'
        target = 'AUTH_0123456789abcdef#2'
        new_value = '60'
        slo_data = {'value': new_value}
        request = self.factory.put('/filters/slo/' + dsl_filter + '/' + slo_name + '/' + target, slo_data, format='json')

        response = slo_detail(request, dsl_filter, slo_name, target)
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)

        # Verify the SLO was updated
        request = self.factory.get('/filters/slo/' + dsl_filter + '/' + slo_name + '/' + target)
        response = slo_detail(request, dsl_filter, slo_name, target)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        json_data = json.loads(response.content)
        self.assertEqual(json_data['value'], new_value)
コード例 #4
0
ファイル: tests.py プロジェクト: cy0713/controller
    def test_slo_detail_when_does_not_exist(self):
        """ Test that a GET request to slo_detail() returns 404 if the slo does not exist """

        dsl_filter = 'bandwidth'
        slo_name = 'get_bw'
        target = 'inexistent'
        request = self.factory.get('/filters/slo/' + dsl_filter + '/' +
                                   slo_name + '/' + target)
        response = slo_detail(request, dsl_filter, slo_name, target)
        self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
コード例 #5
0
ファイル: tests.py プロジェクト: cy0713/controller
 def test_slo_detail_with_method_not_allowed(self):
     """ Test that POST requests to slo_detail() return METHOD_NOT_ALLOWED """
     dsl_filter = 'bandwidth'
     slo_name = 'get_bw'
     target = 'AUTH_0123456789abcdef#1'
     request = self.factory.post('/filters/slo/' + dsl_filter + '/' +
                                 slo_name + '/' + target)
     response = slo_detail(request, dsl_filter, slo_name, target)
     self.assertEqual(response.status_code,
                      status.HTTP_405_METHOD_NOT_ALLOWED)
コード例 #6
0
ファイル: tests.py プロジェクト: cy0713/controller
    def test_update_slo_ok(self):
        """ Test that a PUT request to slo_detail() returns OK """

        dsl_filter = 'bandwidth'
        slo_name = 'get_bw'
        target = 'AUTH_0123456789abcdef#2'
        new_value = '60'
        slo_data = {'value': new_value}
        request = self.factory.put('/filters/slo/' + dsl_filter + '/' +
                                   slo_name + '/' + target,
                                   slo_data,
                                   format='json')

        response = slo_detail(request, dsl_filter, slo_name, target)
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)

        # Verify the SLO was updated
        request = self.factory.get('/filters/slo/' + dsl_filter + '/' +
                                   slo_name + '/' + target)
        response = slo_detail(request, dsl_filter, slo_name, target)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        json_data = json.loads(response.content)
        self.assertEqual(json_data['value'], new_value)
コード例 #7
0
    def test_slo_detail_ok(self):
        """ Test that a GET request to slo_detail() returns OK """

        # mock_get_project_list.return_value = {'0123456789abcdef': 'tenantA', 'abcdef0123456789': 'tenantB'}
        dsl_filter = 'bandwidth'
        slo_name = 'get_bw'
        target = 'AUTH_0123456789abcdef#2'
        request = self.factory.get('/filters/slo/' + dsl_filter + '/' + slo_name + '/' + target)
        response = slo_detail(request, dsl_filter, slo_name, target)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        json_data = json.loads(response.content)
        self.assertEqual(json_data['dsl_filter'], dsl_filter)
        self.assertEqual(json_data['slo_name'], slo_name)
        self.assertEqual(json_data['target'], target)
        self.assertEqual(json_data['value'], '20')
コード例 #8
0
ファイル: tests.py プロジェクト: cy0713/controller
    def test_slo_detail_ok(self):
        """ Test that a GET request to slo_detail() returns OK """

        # mock_get_project_list.return_value = {'0123456789abcdef': 'tenantA', 'abcdef0123456789': 'tenantB'}
        dsl_filter = 'bandwidth'
        slo_name = 'get_bw'
        target = 'AUTH_0123456789abcdef#2'
        request = self.factory.get('/filters/slo/' + dsl_filter + '/' +
                                   slo_name + '/' + target)
        response = slo_detail(request, dsl_filter, slo_name, target)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        json_data = json.loads(response.content)
        self.assertEqual(json_data['dsl_filter'], dsl_filter)
        self.assertEqual(json_data['slo_name'], slo_name)
        self.assertEqual(json_data['target'], target)
        self.assertEqual(json_data['value'], '20')
コード例 #9
0
    def test_delete_slo_ok(self):
        """ Test that a DELETE request to slo_detail() returns OK """

        dsl_filter = 'bandwidth'
        slo_name = 'get_bw'
        target = 'AUTH_0123456789abcdef#2'
        request = self.factory.delete('/filters/slo/' + dsl_filter + '/' + slo_name + '/' + target)

        response = slo_detail(request, dsl_filter, slo_name, target)
        self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)

        # Verify the SLO was deleted
        request = self.factory.get('/filters/slos')
        response = slo_list(request)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        json_data = json.loads(response.content)
        self.assertEqual(len(json_data), 5)  # 6 --> 5
コード例 #10
0
ファイル: tests.py プロジェクト: cy0713/controller
    def test_delete_slo_ok(self):
        """ Test that a DELETE request to slo_detail() returns OK """

        dsl_filter = 'bandwidth'
        slo_name = 'get_bw'
        target = 'AUTH_0123456789abcdef#2'
        request = self.factory.delete('/filters/slo/' + dsl_filter + '/' +
                                      slo_name + '/' + target)

        response = slo_detail(request, dsl_filter, slo_name, target)
        self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)

        # Verify the SLO was deleted
        request = self.factory.get('/filters/slos')
        response = slo_list(request)
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        json_data = json.loads(response.content)
        self.assertEqual(len(json_data), 5)  # 6 --> 5