def test_to_json(self):
        # type: () -> None
        """
        Test string generated from to_json method
        """
        test_obj = DashboardESDocument(dashboard_group='test_dashboard_group',
                                       dashboard_name='test_dashboard_name',
                                       description='test_description',
                                       product='mode',
                                       dashboard_group_description='work space group',
                                       total_usage=10,
                                       tags=['test'])

        expected_document_dict = {"dashboard_group": "test_dashboard_group",
                                  "dashboard_name": "test_dashboard_name",
                                  "description": "test_description",
                                  "product": "mode",
                                  "dashboard_group_description": "work space group",
                                  "total_usage": 10,
                                  "tags": ["test"]
                                  }

        result = test_obj.to_json()
        results = result.split("\n")

        # verify two new line characters in result
        self.assertEqual(len(results), 2, "Result from to_json() function doesn't have a newline!")
        self.assertDictEqual(json.loads(results[0]), expected_document_dict)
    def test_to_json(self):
        # type: () -> None
        """
        Test string generated from to_json method
        """
        test_obj = DashboardESDocument(
            dashboard_group='test_dashboard_group',
            dashboard_name='test_dashboard_name',
            description='test_description',
            last_reload_time='test_last_reload_time',
            user_id='test_user_id',
            user_name='test_user_name',
            tags=['test'])

        expected_document_dict = {
            "dashboard_group": "test_dashboard_group",
            "dashboard_name": "test_dashboard_name",
            "description": "test_description",
            "last_reload_time": "test_last_reload_time",
            "user_id": "test_user_id",
            "user_name": "test_user_name",
            "tags": ["test"]
        }

        result = test_obj.to_json()
        results = result.split("\n")

        # verify two new line characters in result
        self.assertEqual(
            len(results), 2,
            "Result from to_json() function doesn't have a newline!")
        self.assertDictEqual(json.loads(results[0]), expected_document_dict)
Exemplo n.º 3
0
    def test_to_json(self) -> None:
        """
        Test string generated from to_json method
        """
        test_obj = DashboardESDocument(
            group_name='test_dashboard_group',
            name='test_dashboard_name',
            description='test_description',
            product='mode',
            cluster='gold',
            group_description='work space group',
            query_names=['query1'],
            chart_names=['chart1'],
            group_url='mode_group_url',
            url='mode_report_url',
            uri='mode_dashboard://gold.cluster/dashboard_group/dashboard',
            last_successful_run_timestamp=10,
            total_usage=10,
            tags=['test'],
            badges=['test_badge'])

        expected_document_dict = {
            "group_name": "test_dashboard_group",
            "name": "test_dashboard_name",
            "description": "test_description",
            "product": "mode",
            "cluster": "gold",
            "group_url": "mode_group_url",
            "url": "mode_report_url",
            "uri": "mode_dashboard://gold.cluster/dashboard_group/dashboard",
            "query_names": ['query1'],
            "chart_names": ['chart1'],
            "last_successful_run_timestamp": 10,
            "group_description": "work space group",
            "total_usage": 10,
            "tags": ["test"],
            "badges": ["test_badge"],
        }

        result = test_obj.to_json()
        results = result.split("\n")

        # verify two new line characters in result
        self.assertEqual(
            len(results), 2,
            "Result from to_json() function doesn't have a newline!")
        self.assertDictEqual(json.loads(results[0]), expected_document_dict)