File tree 3 files changed +27
-1
lines changed
3 files changed +27
-1
lines changed Original file line number Diff line number Diff line change 3
3
# SPDX-License-Identifier: Apache-2.0
4
4
#
5
5
"""AWS views."""
6
+ from rest_framework .exceptions import NotFound
7
+
6
8
from api .common .permissions .aws_access import AwsAccessPermission
7
9
from api .common .permissions .aws_access import AWSOUAccessPermission
8
10
from api .models import Provider
9
11
from api .report .aws .query_handler import AWSReportQueryHandler
10
12
from api .report .aws .serializers import AWSEC2ComputeQueryParamSerializer
11
13
from api .report .aws .serializers import AWSQueryParamSerializer
12
14
from api .report .view import ReportView
15
+ from masu .processor import is_feature_cost_4403_ec2_compute_cost_enabled
13
16
14
17
15
18
class AWSView (ReportView ):
@@ -45,3 +48,8 @@ class AWSEC2ComputeView(AWSView):
45
48
46
49
report = "ec2_compute"
47
50
serializer = AWSEC2ComputeQueryParamSerializer
51
+
52
+ def get (self , request , ** kwargs ):
53
+ if not is_feature_cost_4403_ec2_compute_cost_enabled (request .user .customer .schema_name ):
54
+ raise NotFound ()
55
+ return super ().get (request , ** kwargs )
Original file line number Diff line number Diff line change 4
4
#
5
5
"""Test the AWS Report views."""
6
6
import copy
7
+ from unittest .mock import patch
7
8
8
9
from django .urls import reverse
9
10
from rest_framework import status
@@ -601,6 +602,23 @@ def test_invalid_aws_category_key(self):
601
602
response = self .client .get (url , ** self .headers )
602
603
self .assertEqual (response .status_code , status .HTTP_400_BAD_REQUEST )
603
604
605
+ def test_ec2_compute_view_unleashed (self ):
606
+ """Test EC2 compute view returns correct repsonses depending on unleash."""
607
+ url = reverse ("reports-aws-ec2-compute" )
608
+ with patch (
609
+ "api.report.aws.view.is_feature_cost_4403_ec2_compute_cost_enabled" ,
610
+ return_value = False ,
611
+ ):
612
+ response = self .client .get (url , ** self .headers )
613
+ self .assertEqual (response .status_code , status .HTTP_404_NOT_FOUND )
614
+
615
+ with patch (
616
+ "api.report.aws.view.is_feature_cost_4403_ec2_compute_cost_enabled" ,
617
+ return_value = True ,
618
+ ):
619
+ response = self .client .get (url , ** self .headers )
620
+ self .assertEqual (response .status_code , status .HTTP_200_OK )
621
+
604
622
def test_ec2_compute_view_returns_default_time_period_params (self ):
605
623
"""Test EC2 compute view returns HTTP 200 and valid default meta filter."""
606
624
Original file line number Diff line number Diff line change 1
1
[tox]
2
- envlist = py39
2
+ envlist = py311
3
3
skipsdist = True
4
4
5
5
[flake8]
You can’t perform that action at this time.
0 commit comments