Module: check_mk
Branch: master
Commit: 15dd9d3fd573d750ac42c7bbb18b957122782e00
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=15dd9d3fd573d7…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Wed Apr 24 11:13:37 2019 +0200
Cleaned up AWS CE test
Change-Id: Ia07d172b0f190352740958983e21cac00786fcd6
---
.../agent_aws/agent_aws_fake_clients.py | 29 +++++++++++++++
.../agent_aws/test_agent_aws_costs_and_usage.py | 41 ++--------------------
2 files changed, 32 insertions(+), 38 deletions(-)
diff --git a/tests/unit/cmk/special_agents/agent_aws/agent_aws_fake_clients.py
b/tests/unit/cmk/special_agents/agent_aws/agent_aws_fake_clients.py
index aff7c14..036ff69 100644
--- a/tests/unit/cmk/special_agents/agent_aws/agent_aws_fake_clients.py
+++ b/tests/unit/cmk/special_agents/agent_aws/agent_aws_fake_clients.py
@@ -271,3 +271,32 @@ class CloudwatchDescribeAlarmsInstanceCreator(InstanceCreator):
Str('Label'),
BoolChoice('ReturnData'),
))
+
+
+#.
+# .--CE-------------------------------------------------------------------
+
+
+class CEGetCostsAndUsageInstanceCreator(InstanceCreator):
+ def _fill_instance(self):
+ self.add(Dict(
+ 'TimePeriod',
+ Str('Start'),
+ Str('End'),
+ ))
+ self.add(Dict('Total', Dict(
+ 'string',
+ Str('Amount'),
+ Str('Unit'),
+ )))
+ self.add(
+ List(
+ 'Groups',
+ Enum('Keys'),
+ Dict('Metrics', Dict(
+ 'string',
+ Str('Amount'),
+ Str('Unit'),
+ )),
+ ))
+ self.add(BoolChoice('Estimated'))
diff --git a/tests/unit/cmk/special_agents/agent_aws/test_agent_aws_costs_and_usage.py
b/tests/unit/cmk/special_agents/agent_aws/test_agent_aws_costs_and_usage.py
index b951188..7b1e487 100644
--- a/tests/unit/cmk/special_agents/agent_aws/test_agent_aws_costs_and_usage.py
+++ b/tests/unit/cmk/special_agents/agent_aws/test_agent_aws_costs_and_usage.py
@@ -1,23 +1,12 @@
# encoding: utf-8
-import pytest
-
+from agent_aws_fake_clients import (
+ CEGetCostsAndUsageInstanceCreator,)
from cmk.special_agents.agent_aws import (
AWSConfig,
CostsAndUsage,
)
-#TODO what about enums?
-
-# .--fake client---------------------------------------------------------.
-# | __ _ _ _ _ |
-# | / _| __ _| | _____ ___| (_) ___ _ __ | |_ |
-# | | |_ / _` | |/ / _ \ / __| | |/ _ \ '_ \| __| |
-# | | _| (_| | < __/ | (__| | | __/ | | | |_ |
-# | |_| \__,_|_|\_\___| \___|_|_|\___|_| |_|\__| |
-# | |
-# '----------------------------------------------------------------------'
-
class FakeCEClient(object):
def get_cost_and_usage(self, TimePeriod, Granularity, Metrics, GroupBy):
@@ -27,34 +16,10 @@ class FakeCEClient(object):
'Type': "'DIMENSION' | 'TAG'",
'Key': 'string'
},],
- 'ResultsByTime': [{
- 'TimePeriod': {
- 'Start': 'string',
- 'End': 'string'
- },
- 'Total': {
- 'string': {
- 'Amount': 'string',
- 'Unit': 'string'
- }
- },
- 'Groups': [{
- 'Keys': ['string',],
- 'Metrics': {
- 'string': {
- 'Amount': 'string',
- 'Unit': 'string'
- }
- }
- },],
- 'Estimated': "True | False",
- },]
+ 'ResultsByTime':
CEGetCostsAndUsageInstanceCreator.create_instances(amount=1),
}
-#.
-
-
def test_agent_aws_costs_and_usage():
region = 'us-east-1'
config = AWSConfig('hostname', (None, None))