aboutsummaryrefslogtreecommitdiffstats
path: root/app/test/api/responders_test/resource/test_aggregates.py
diff options
context:
space:
mode:
authorKoren Lev <korenlev@gmail.com>2017-07-27 15:04:07 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-07-27 15:04:07 +0000
commit162c03ef301396072c1934e7e7e0c40a841b4fe2 (patch)
tree7a2a2781949252436450ff5832962785061a774a /app/test/api/responders_test/resource/test_aggregates.py
parentb88c78e3cf2bef22aa2f1c4d0bf305e303bc15f0 (diff)
parent7e83d0876ddb84a45e130eeba28bc40ef53c074b (diff)
Merge "Calipso initial release for OPNFV"
Diffstat (limited to 'app/test/api/responders_test/resource/test_aggregates.py')
-rw-r--r--app/test/api/responders_test/resource/test_aggregates.py103
1 files changed, 103 insertions, 0 deletions
diff --git a/app/test/api/responders_test/resource/test_aggregates.py b/app/test/api/responders_test/resource/test_aggregates.py
new file mode 100644
index 0000000..1b642e0
--- /dev/null
+++ b/app/test/api/responders_test/resource/test_aggregates.py
@@ -0,0 +1,103 @@
+###############################################################################
+# Copyright (c) 2017 Koren Lev (Cisco Systems), Yaron Yogev (Cisco Systems) #
+# and others #
+# #
+# All rights reserved. This program and the accompanying materials #
+# are made available under the terms of the Apache License, Version 2.0 #
+# which accompanies this distribution, and is available at #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+###############################################################################
+from test.api.test_base import TestBase
+from test.api.responders_test.test_data import base
+from test.api.responders_test.test_data import aggregates
+from unittest.mock import patch
+
+
+class TestAggregates(TestBase):
+
+ def test_get_aggregate_without_type(self):
+ self.validate_get_request(aggregates.URL,
+ params={},
+ expected_code=base.BAD_REQUEST_CODE)
+
+ def test_get_aggregate_with_wrong_filter(self):
+ self.validate_get_request(aggregates.URL,
+ params={
+ "unknown": "unknown"
+ },
+ expected_code=base.BAD_REQUEST_CODE)
+
+ def test_get_environment_aggregates_without_env_name(self):
+ self.validate_get_request(aggregates.URL,
+ params={
+ "type": aggregates.ENV_TYPE
+ },
+ expected_code=base.BAD_REQUEST_CODE)
+
+ @patch(base.RESPONDER_BASE_CHECK_ENVIRONMENT_NAME)
+ def test_get_environment_aggregates_with_unknown_env_name(self,
+ check_env_name):
+ self.validate_get_request(aggregates.URL,
+ params={
+ "type": aggregates.ENV_TYPE,
+ "env_name": base.UNKNOWN_ENV
+ },
+ mocks={
+ check_env_name: False
+ },
+ expected_code=base.BAD_REQUEST_CODE)
+
+ @patch(base.RESPONDER_BASE_CHECK_ENVIRONMENT_NAME)
+ @patch(base.RESPONDER_BASE_AGGREGATE)
+ def test_get_environment_aggregates_with_env_name(self, aggregates_method,
+ check_env_name):
+ self.validate_get_request(aggregates.URL,
+ params={
+ "type": aggregates.ENV_TYPE,
+ "env_name": base.ENV_NAME
+ },
+ mocks={
+ check_env_name: True,
+ aggregates_method:
+ aggregates.ENVIRONMENT_AGGREGATES
+ },
+ expected_code=base.SUCCESSFUL_CODE,
+ expected_response=
+ aggregates.ENVIRONMENT_AGGREGATES_RESPONSE
+ )
+
+ @patch(base.RESPONDER_BASE_AGGREGATE)
+ def test_get_message_aggregates(self, aggregate):
+ self.validate_get_request(aggregates.URL,
+ params={
+ "type": aggregates.MESSAGE_TYPE
+ },
+ side_effects={aggregate: [
+ aggregates.MESSAGE_ENV_AGGREGATES,
+ aggregates.MESSAGE_LEVEL_AGGREGATES]
+ },
+ expected_code=base.SUCCESSFUL_CODE,
+ expected_response=
+ aggregates.MESSAGE_AGGREGATES_RESPONSE
+ )
+
+ @patch(base.RESPONDER_BASE_AGGREGATE)
+ def test_get_constant_aggregates(self, aggregate):
+ self.validate_get_request(aggregates.URL,
+ params={
+ "type": aggregates.CONSTANT_TYPE
+ },
+ mocks={
+ aggregate: aggregates.CONSTANT_AGGREGATES
+ },
+ expected_code=base.SUCCESSFUL_CODE,
+ expected_response=
+ aggregates.CONSTANT_AGGREGATES_RESPONSE
+ )
+
+ def test_get_unknown_aggregates(self):
+ self.validate_get_request(aggregates.URL,
+ params={
+ "type": aggregates.UNKNOWN_TYPE
+ },
+ expected_code=base.BAD_REQUEST_CODE)