# coding=utf8

# Copyright 2018 JDCLOUD.COM
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# NOTE: This class is auto generated by the jdcloud code generator program.

import unittest
import os
import json


class JcqTest(unittest.TestCase):

    def test_describe_access_point(self):
        cmd = """python ../../main.py jcq describe-access-point  --topic-name 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

        print(content)
        result = json.loads(content)
        self.assertIsInstance(result, dict)

    def test_describe_topics(self):
        cmd = """python ../../main.py jcq describe-topics """
        with os.popen(cmd) as f:
            content = f.read()

        print(content)
        result = json.loads(content)
        self.assertIsInstance(result, dict)

    def test_create_topic(self):
        cmd = """python ../../main.py jcq create-topic  --topic-name 'xxx' --type 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

        print(content)
        result = json.loads(content)
        self.assertIsInstance(result, dict)

    def test_describe_topic(self):
        cmd = """python ../../main.py jcq describe-topic  --topic-name 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

        print(content)
        result = json.loads(content)
        self.assertIsInstance(result, dict)

    def test_delete_topic(self):
        cmd = """python ../../main.py jcq delete-topic  --topic-name 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

        print(content)
        result = json.loads(content)
        self.assertIsInstance(result, dict)

    def test_describe_dead_letter_numbers(self):
        cmd = """python ../../main.py jcq describe-dead-letter-numbers """
        with os.popen(cmd) as f:
            content = f.read()

        print(content)
        result = json.loads(content)
        self.assertIsInstance(result, dict)

    def test_describe_dead_letter_numbers_with_topic(self):
        cmd = """python ../../main.py jcq describe-dead-letter-numbers-with-topic  --topic-name 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

        print(content)
        result = json.loads(content)
        self.assertIsInstance(result, dict)

    def test_list_dead_letters(self):
        cmd = """python ../../main.py jcq list-dead-letters  --topic-name 'xxx' --consumer-group-id 'xxx' --start-time 'xxx' --end-time 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

        print(content)
        result = json.loads(content)
        self.assertIsInstance(result, dict)

    def test_delete_dead_letters(self):
        cmd = """python ../../main.py jcq delete-dead-letters  --topic-name 'xxx' --consumer-group-id 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

        print(content)
        result = json.loads(content)
        self.assertIsInstance(result, dict)

    def test_resend_dead_letters(self):
        cmd = """python ../../main.py jcq resend-dead-letters  --topic-name 'xxx' --consumer-group-id 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

        print(content)
        result = json.loads(content)
        self.assertIsInstance(result, dict)

    def test_describe_permission(self):
        cmd = """python ../../main.py jcq describe-permission  --topic-name 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

        print(content)
        result = json.loads(content)
        self.assertIsInstance(result, dict)

    def test_add_permission(self):
        cmd = """python ../../main.py jcq add-permission  --topic-name 'xxx' --permission 'xxx' --target-user-id 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

        print(content)
        result = json.loads(content)
        self.assertIsInstance(result, dict)

    def test_remove_permission(self):
        cmd = """python ../../main.py jcq remove-permission  --topic-name 'xxx' --permission 'xxx' --target-user-id 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

        print(content)
        result = json.loads(content)
        self.assertIsInstance(result, dict)

    def test_describe_consumer_group_ids(self):
        cmd = """python ../../main.py jcq describe-consumer-group-ids """
        with os.popen(cmd) as f:
            content = f.read()

        print(content)
        result = json.loads(content)
        self.assertIsInstance(result, dict)

    def test_describe_subscriptions(self):
        cmd = """python ../../main.py jcq describe-subscriptions  --topic-name 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

        print(content)
        result = json.loads(content)
        self.assertIsInstance(result, dict)

    def test_create_subscription(self):
        cmd = """python ../../main.py jcq create-subscription  --topic-name 'xxx' --consumer-group-id 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

        print(content)
        result = json.loads(content)
        self.assertIsInstance(result, dict)

    def test_describe_subscription(self):
        cmd = """python ../../main.py jcq describe-subscription  --topic-name 'xxx' --consumer-group-id 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

        print(content)
        result = json.loads(content)
        self.assertIsInstance(result, dict)

    def test_modify_subscription_attribute(self):
        cmd = """python ../../main.py jcq modify-subscription-attribute  --topic-name 'xxx' --consumer-group-id 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

        print(content)
        result = json.loads(content)
        self.assertIsInstance(result, dict)

    def test_delete_subscription(self):
        cmd = """python ../../main.py jcq delete-subscription  --topic-name 'xxx' --consumer-group-id 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

        print(content)
        result = json.loads(content)
        self.assertIsInstance(result, dict)

    def test_clean_messages(self):
        cmd = """python ../../main.py jcq clean-messages  --topic-name 'xxx' --consumer-group-id 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

        print(content)
        result = json.loads(content)
        self.assertIsInstance(result, dict)

    def test_reset_consume_offset(self):
        cmd = """python ../../main.py jcq reset-consume-offset  --topic-name 'xxx' --consumer-group-id 'xxx' --time 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

        print(content)
        result = json.loads(content)
        self.assertIsInstance(result, dict)

    def test_describe_messages(self):
        cmd = """python ../../main.py jcq describe-messages  --topic-name 'xxx' --start-time 'xxx' --end-time 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

        print(content)
        result = json.loads(content)
        self.assertIsInstance(result, dict)

    def test_describe_message(self):
        cmd = """python ../../main.py jcq describe-message  --topic-name 'xxx' --message-id 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

        print(content)
        result = json.loads(content)
        self.assertIsInstance(result, dict)

    def test_describe_message_trace(self):
        cmd = """python ../../main.py jcq describe-message-trace  --topic-name 'xxx' --message-id 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

        print(content)
        result = json.loads(content)
        self.assertIsInstance(result, dict)

    def test_describe_messages_by_business_id(self):
        cmd = """python ../../main.py jcq describe-messages-by-business-id  --topic-name 'xxx' --business-id 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

        print(content)
        result = json.loads(content)
        self.assertIsInstance(result, dict)

