# 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 IotcoreTest(unittest.TestCase):

    def test_list_product_abilities(self):
        cmd = """python ../../main.py iotcore list-product-abilities  --instance-id 'xxx' --product-key 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_import_thing_model(self):
        cmd = """python ../../main.py iotcore import-thing-model  --instance-id 'xxx' --product-key 'xxx' --thing-model '{"":""}'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_export_thing_model(self):
        cmd = """python ../../main.py iotcore export-thing-model  --instance-id 'xxx' --product-key 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_invoke_thing_topic(self):
        cmd = """python ../../main.py iotcore invoke-thing-topic  --instance-id 'xxx' --identifier 'xxx' --product-key 'xxx' --topic-short-name 'xxx' --topic-message 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_describe_thing_shadow(self):
        cmd = """python ../../main.py iotcore describe-thing-shadow  --instance-id 'xxx' --identifier 'xxx' --product-key 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_update_thing_shadow(self):
        cmd = """python ../../main.py iotcore update-thing-shadow  --instance-id 'xxx' --identifier 'xxx' --product-key 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_invoke_thing_service(self):
        cmd = """python ../../main.py iotcore invoke-thing-service  --instance-id 'xxx' --identifier 'xxx' --product-key 'xxx' --name 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_add_device_links(self):
        cmd = """python ../../main.py iotcore add-device-links  --instance-id 'xxx' --parent-id 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_query_device_page(self):
        cmd = """python ../../main.py iotcore query-device-page  --instance-id 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_update_device(self):
        cmd = """python ../../main.py iotcore update-device  --instance-id 'xxx' --device-id 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_add_device(self):
        cmd = """python ../../main.py iotcore add-device  --instance-id 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_query_device_detail(self):
        cmd = """python ../../main.py iotcore query-device-detail  --device-name 'xxx' --instance-id 'xxx' --product-key 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_remove_device(self):
        cmd = """python ../../main.py iotcore remove-device  --device-name 'xxx' --instance-id 'xxx' --product-key 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_list_products(self):
        cmd = """python ../../main.py iotcore list-products  --instance-id 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_create_product(self):
        cmd = """python ../../main.py iotcore create-product  --instance-id 'xxx' --product-name 'xxx' --product-type '5'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_describe_product(self):
        cmd = """python ../../main.py iotcore describe-product  --instance-id 'xxx' --product-key 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_update_product(self):
        cmd = """python ../../main.py iotcore update-product  --instance-id 'xxx' --product-key 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_delete_product(self):
        cmd = """python ../../main.py iotcore delete-product  --instance-id 'xxx' --product-key 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_update_loo_device(self):
        cmd = """python ../../main.py iotcore update-loo-device  --instance-id 'xxx' --device-id 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_add_loo_device(self):
        cmd = """python ../../main.py iotcore add-loo-device  --instance-id 'xxx' --pre-order-id 'xxx' --user-pin-param 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_loongray_query_page(self):
        cmd = """python ../../main.py iotcore loongray-query-page  --instance-id 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_query_admin_statistics(self):
        cmd = """python ../../main.py iotcore query-admin-statistics  --instance-id 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_remove_loongray_device(self):
        cmd = """python ../../main.py iotcore remove-loongray-device  --device-name 'xxx' --instance-id 'xxx' --product-key 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_register_device(self):
        cmd = """python ../../main.py iotcore register-device  --instance-id 'xxx' --device-info-vo '{"":""}'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_download_device_certificate(self):
        cmd = """python ../../main.py iotcore download-device-certificate  --instance-id 'xxx' --device-id 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_delete_device(self):
        cmd = """python ../../main.py iotcore delete-device  --instance-id 'xxx' --device-id 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_describe_device(self):
        cmd = """python ../../main.py iotcore describe-device  --instance-id 'xxx' --device-id 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_describe_thing_type_list(self):
        cmd = """python ../../main.py iotcore describe-thing-type-list  --instance-id 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_describe_thing_type(self):
        cmd = """python ../../main.py iotcore describe-thing-type  --instance-id 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_describe_thing_model(self):
        cmd = """python ../../main.py iotcore describe-thing-model  --instance-id 'xxx' --thing-type-code 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_set_device_property(self):
        cmd = """python ../../main.py iotcore set-device-property  --instance-id 'xxx' --device-property-vo '{"":""}'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_invoke_function(self):
        cmd = """python ../../main.py iotcore invoke-function  --instance-id 'xxx' --device-function-vo '{"":""}'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_describe_event_list(self):
        cmd = """python ../../main.py iotcore describe-event-list  --instance-id 'xxx' --event-report-page-bo '{"":""}'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_describe_function_list(self):
        cmd = """python ../../main.py iotcore describe-function-list  --instance-id 'xxx' --function-call-page-bo '{"":""}'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_describe_property(self):
        cmd = """python ../../main.py iotcore describe-property  --instance-id 'xxx' --device-id 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_describe_property_snapshot(self):
        cmd = """python ../../main.py iotcore describe-property-snapshot  --instance-id 'xxx' --device-snapshot-request-vo '{"":""}'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_create_device_topo(self):
        cmd = """python ../../main.py iotcore create-device-topo  --instance-id 'xxx' --device-topo-info-vo '{"":""}'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_describe_device_topo(self):
        cmd = """python ../../main.py iotcore describe-device-topo  --instance-id 'xxx' --device-topo-page-bo '{"":""}'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_update_device_topo(self):
        cmd = """python ../../main.py iotcore update-device-topo  --instance-id 'xxx' --device-topo-info-vo '{"":""}'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_delete_device_topo(self):
        cmd = """python ../../main.py iotcore delete-device-topo  --instance-id 'xxx' --device-topo-info-vo '{"":""}'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_describe_product_with_admin(self):
        cmd = """python ../../main.py iotcore describe-product-with-admin  --instance-id 'xxx' --product-key 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_update_product_with_admin(self):
        cmd = """python ../../main.py iotcore update-product-with-admin  --instance-id 'xxx' --product-key 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_delete_product_with_admin(self):
        cmd = """python ../../main.py iotcore delete-product-with-admin  --instance-id 'xxx' --product-key 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_list_products_with_admin(self):
        cmd = """python ../../main.py iotcore list-products-with-admin  --instance-id 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_create_admin_product(self):
        cmd = """python ../../main.py iotcore create-admin-product  --instance-id 'xxx' --product-name 'xxx' --product-type '5' --coll-device-type 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_describe_product_topics(self):
        cmd = """python ../../main.py iotcore describe-product-topics  --instance-id 'xxx' --product-key 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_create_product_topic(self):
        cmd = """python ../../main.py iotcore create-product-topic  --instance-id 'xxx' --product-key 'xxx' --topic-short-name 'xxx' --topic-operation 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_describe_product_topic(self):
        cmd = """python ../../main.py iotcore describe-product-topic  --instance-id 'xxx' --product-key 'xxx' --topic-id 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_get_device_group(self):
        cmd = """python ../../main.py iotcore get-device-group  --instance-id 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_get_device_group_list(self):
        cmd = """python ../../main.py iotcore get-device-group-list  --instance-id 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_find_device_group_link_page(self):
        cmd = """python ../../main.py iotcore find-device-group-link-page  --instance-id 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_elevator_operating_status(self):
        cmd = """python ../../main.py iotcore elevator-operating-status  --instance-id 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_collector_read_message(self):
        cmd = """python ../../main.py iotcore collector-read-message  --instance-id 'xxx' --identifier 'xxx' --protocol 'xxx'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_read_holding_registers(self):
        cmd = """python ../../main.py iotcore read-holding-registers  --instance-id 'xxx' --identifier 'xxx' --address-of-first-register '5' --number-of-registers '5'"""
        with os.popen(cmd) as f:
            content = f.read()

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

    def test_collector_write_message(self):
        cmd = """python ../../main.py iotcore collector-write-message  --instance-id 'xxx' --identifier 'xxx' --data '{"":""}'"""
        with os.popen(cmd) as f:
            content = f.read()

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

