예제 #1
0
 def test_execute_query_10_day_parameters_only_keys(self):
     """Test that the execute query runs properly with 10 day query."""
     url = "?filter[time_scope_units]=day&filter[time_scope_value]=-10&filter[resolution]=daily&key_only=True"
     query_params = self.mocked_query_params(url, GCPTagView)
     handler = GCPTagQueryHandler(query_params)
     query_output = handler.execute_query()
     self.assertIsNotNone(query_output.get("data"))
     self.assertEqual(handler.time_scope_units, "day")
     self.assertEqual(handler.time_scope_value, -10)
예제 #2
0
 def test_execute_query_two_month_parameters(self):
     """Test that the execute query runs properly with two month query."""
     url = "?filter[time_scope_units]=month&filter[time_scope_value]=-2&filter[resolution]=monthly"
     query_params = self.mocked_query_params(url, GCPTagView)
     handler = GCPTagQueryHandler(query_params)
     query_output = handler.execute_query()
     self.assertIsNotNone(query_output.get("data"))
     self.assertEqual(handler.time_scope_units, "month")
     self.assertEqual(handler.time_scope_value, -2)
예제 #3
0
 def test_execute_query_no_query_parameters(self):
     """Test that the execute query runs properly with no query."""
     url = "?"
     query_params = self.mocked_query_params(url, GCPTagView)
     handler = GCPTagQueryHandler(query_params)
     query_output = handler.execute_query()
     self.assertIsNotNone(query_output.get("data"))
     self.assertEqual(handler.time_scope_units, "day")
     self.assertEqual(handler.time_scope_value, -10)
예제 #4
0
    def test_execute_query_for_project(self):
        """Test that the execute query runs properly with project query."""
        account = None
        with tenant_context(self.tenant):
            obj = GCPCostEntryLineItemDailySummary.objects.values(
                "account_id").first()
            account = obj.get("account_id")

        url = f"?filter[time_scope_units]=day&filter[time_scope_value]=-10&filter[resolution]=daily&filter[account]={account}"  # noqa: E501
        query_params = self.mocked_query_params(url, GCPTagView)
        handler = GCPTagQueryHandler(query_params)
        query_output = handler.execute_query()
        self.assertIsNotNone(query_output.get("data"))
        self.assertEqual(handler.time_scope_units, "day")
        self.assertEqual(handler.time_scope_value, -10)