aboutsummaryrefslogtreecommitdiffstats
path: root/app/test/api/responders_test/resource/test_aggregates.py
diff options
context:
space:
mode:
authorYaron Yogev <yaronyogev@gmail.com>2017-07-27 09:02:54 +0300
committerYaron Yogev <yaronyogev@gmail.com>2017-07-27 14:56:25 +0300
commit7e83d0876ddb84a45e130eeba28bc40ef53c074b (patch)
tree47d76239ae7658d87c66abd142df92709427e7dd /app/test/api/responders_test/resource/test_aggregates.py
parent378ecbd8947589b9cbb39013a0c2e2aa201e03bd (diff)
Calipso initial release for OPNFV
Change-Id: I7210c244b0c10fa80bfa8c77cb86c9d6ddf8bc88 Signed-off-by: Yaron Yogev <yaronyogev@gmail.com>
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)