def test_metrics_get_endpoints(self): # # Test for defaults when --start is not supplied # class FakeOptions(object): start = end = None days = 5 options = FakeOptions() start, end = commands._metrics_get_endpoints(options) self.assertEqual((end - start).days, options.days) # # Test that --start and --end have to be passed together # policy = { 'policies': [{ 'name': 'metrics-test', 'resource': 'ec2', 'query': [{ "instance-state-name": "running" }], }] } yaml_file = self.write_policy_file(policy) self.run_and_expect_failure( ['custodian', 'metrics', '--start', '1', yaml_file], 1)
def test_metrics_get_endpoints(self): # # Test for defaults when --start is not supplied # class FakeOptions: start = end = None days = 5 options = FakeOptions() start, end = commands._metrics_get_endpoints(options) self.assertEqual((end - start).days, options.days) # # Test that --start and --end have to be passed together # policy = { "policies": [{ "name": "metrics-test", "resource": "ec2", "query": [{ "instance-state-name": "running" }], }] } yaml_file = self.write_policy_file(policy) self.run_and_expect_failure( ["custodian", "metrics", "--start", "1", yaml_file], 1)
def test_metrics_get_endpoints(self): # # Test for defaults when --start is not supplied # class FakeOptions(object): start = end = None days = 5 options = FakeOptions() start, end = commands._metrics_get_endpoints(options) self.assertEqual((end - start).days, options.days) # # Test that --start and --end have to be passed together # policy = { 'policies': [{ 'name': 'metrics-test', 'resource': 'ec2', 'query': [{"instance-state-name": "running"}], }] } yaml_file = self.write_policy_file(policy) self.run_and_expect_failure( ['custodian', 'metrics', '--start', '1', yaml_file], 1 )
def test_metrics_get_endpoints(self): # # Test for defaults when --start is not supplied # class FakeOptions(object): start = end = None days = 5 options = FakeOptions() start, end = commands._metrics_get_endpoints(options) self.assertEqual((end - start).days, options.days) # # Test that --start and --end have to be passed together # policy = { "policies": [ { "name": "metrics-test", "resource": "ec2", "query": [{"instance-state-name": "running"}], } ] } yaml_file = self.write_policy_file(policy) self.run_and_expect_failure( ["custodian", "metrics", "--start", "1", yaml_file], 1 )