예제 #1
0
    def test_is_readable_keen_var(self):
        """Test keenio.is_readable() with keen vars"""
        # only set project id, check should fail
        keen.project_id = "1234abcd"
        self.assertFalse(keenio.is_readable())

        # set read_key
        keen.read_key = "4567abcd5678efgh"
        self.assertTrue(keenio.is_readable())
예제 #2
0
    def test_is_readable_env_vars(self):
        """Test keenio.is_readable() with env vars"""
        # only set project id, check should fail
        os.environ["KEEN_PROJECT_ID"] = "1234abcd"
        self.assertFalse(keenio.is_readable())

        # set read_key
        os.environ["KEEN_READ_KEY"] = "4567abcd5678efgh"
        self.assertTrue(keenio.is_readable())
예제 #3
0
    def test_is_readable_env_vars(self):
        """Test keenio.is_readable() with env vars"""
        # only set project id, check should fail
        os.environ["KEEN_PROJECT_ID"] = "1234abcd"
        self.assertFalse(keenio.is_readable())

        # set read_key
        os.environ["KEEN_READ_KEY"] = "4567abcd5678efgh"
        self.assertTrue(keenio.is_readable())
예제 #4
0
    def test_is_readable_keen_var(self):
        """Test keenio.is_readable() with keen vars"""
        # only set project id, check should fail
        keen.project_id = "1234abcd"
        self.assertFalse(keenio.is_readable())

        # set read_key
        keen.read_key = "4567abcd5678efgh"
        self.assertTrue(keenio.is_readable())
예제 #5
0
    def test_load_settings(self):
        """Test Settings.load_settings()"""
        # checking if Keen.io configuration is not set (yet)
        self.assertEqual(None, keen.project_id)
        self.assertEqual(None, keen.write_key)
        self.assertEqual(None, keen.read_key)
        self.assertEqual(None, keen.master_key)

        scriptname = "script.py"
        expected_ci = "travis"
        expected_project_name = "test/project"

        argv = [
            scriptname, "--ci={0!s}".format(expected_ci),
            "--repo={0!s}".format(expected_project_name), "argument"
        ]

        exp_config = os.environ["BUILD_TREND_CONFIGFILE"] = "test/config.js"

        # load settings (config file, env vars and cli parameters)
        self.assertListEqual(["argument"],
                             self.settings.load_settings(
                                 argv, constants.TEST_SAMPLE_CONFIG_FILE))
        self.assertDictEqual(
            {
                "project_name": expected_project_name,
                "ci_platform": expected_ci,
                "mode_native": True,
                "mode_keen": False,
                "loglevel": "INFO",
                "data_detail": "extended",
                'repo_data_detail': {
                    'user1/': 'full',
                    'user2': 'extended',
                    'test/repo': 'basic'
                },
                "setting1": "test_value1",
                "dashboard_sample_configfile":
                constants.DASHBOARD_SAMPLE_CONFIG_FILE,
                "dashboard_configfile": exp_config,
                "task_queue": {
                    "backend": "amqp",
                    "broker_url": "amqp://user@localhost"
                },
                "multi_import": {
                    "max_builds": 150,
                    "delay": 6
                }
            }, self.settings.settings.get_items())

        # checking if Keen.io configuration is set
        self.assertEqual("1234", keen.project_id)
        self.assertEqual("12345678", keen.write_key)
        self.assertEqual("abcdefg", keen.read_key)
        self.assertEqual("7890abcd", keen.master_key)
        self.assertTrue(keenio.is_readable())
        self.assertTrue(keenio.is_writable())

        del os.environ["BUILD_TREND_CONFIGFILE"]
예제 #6
0
    def test_novalues(self):
        """Test initial state the function and classs instances."""
        self.assertEqual(None, keen.project_id)
        self.assertEqual(None, keen.write_key)
        self.assertEqual(None, keen.read_key)
        self.assertEqual(None, keen.master_key)

        self.assertFalse(keenio.has_project_id())
        self.assertFalse(keenio.has_master_key())
        self.assertFalse(keenio.has_write_key())
        self.assertFalse(keenio.has_read_key())
        self.assertFalse(keenio.is_writable())
        self.assertFalse(keenio.is_readable())
예제 #7
0
    def test_novalues(self):
        """Test initial state the function and classs instances."""
        self.assertEqual(None, keen.project_id)
        self.assertEqual(None, keen.write_key)
        self.assertEqual(None, keen.read_key)
        self.assertEqual(None, keen.master_key)

        self.assertFalse(keenio.has_project_id())
        self.assertFalse(keenio.has_master_key())
        self.assertFalse(keenio.has_write_key())
        self.assertFalse(keenio.has_read_key())
        self.assertFalse(keenio.is_writable())
        self.assertFalse(keenio.is_readable())
예제 #8
0
    def test_load_config_file(self):
        """Test Settings.load_config_file()"""
        # checking if Keen.io configuration is not set (yet)
        self.assertEqual(None, keen.project_id)
        self.assertEqual(None, keen.write_key)
        self.assertEqual(None, keen.read_key)
        self.assertEqual(None, keen.master_key)

        # load sample config file
        self.assertTrue(
            self.settings.load_config_file(constants.TEST_SAMPLE_CONFIG_FILE)
        )
        self.assertDictEqual(
            {
                "project_name": "test_project",
                "mode_native": True,
                "mode_keen": False,
                "loglevel": "INFO",
                "data_detail": "extended",
                'repo_data_detail': {
                    'user1/': 'full',
                    'user2': 'extended',
                    'test/repo': 'basic'
                },
                "setting1": "test_value1",
                "dashboard_sample_configfile":
                constants.DASHBOARD_SAMPLE_CONFIG_FILE,
                "dashboard_configfile": "test/dashboard/config.js",
                "task_queue": {
                    "backend": "amqp",
                    "broker_url": "amqp://user@localhost"
                },
                "multi_import": {
                    "max_builds": 150,
                    "delay": 6
                }
            },
            self.settings.settings.get_items())

        # checking if Keen.io configuration is set
        self.assertEqual("1234", keen.project_id)
        self.assertEqual("12345678", keen.write_key)
        self.assertEqual("abcdefg", keen.read_key)
        self.assertEqual("7890abcd", keen.master_key)
        self.assertTrue(keenio.is_readable())
        self.assertTrue(keenio.is_writable())
예제 #9
0
    def test_load_config_file(self):
        """Test Settings.load_config_file()"""
        # checking if Keen.io configuration is not set (yet)
        self.assertEqual(None, keen.project_id)
        self.assertEqual(None, keen.write_key)
        self.assertEqual(None, keen.read_key)
        self.assertEqual(None, keen.master_key)

        # load sample config file
        self.assertTrue(
            self.settings.load_config_file(constants.TEST_SAMPLE_CONFIG_FILE))
        self.assertDictEqual(
            {
                "project_name": "test_project",
                "mode_native": True,
                "mode_keen": False,
                "loglevel": "INFO",
                "data_detail": "extended",
                'repo_data_detail': {
                    'user1/': 'full',
                    'user2': 'extended',
                    'test/repo': 'basic'
                },
                "setting1": "test_value1",
                "dashboard_sample_configfile":
                constants.DASHBOARD_SAMPLE_CONFIG_FILE,
                "dashboard_configfile": "test/dashboard/config.js",
                "task_queue": {
                    "backend": "amqp",
                    "broker_url": "amqp://user@localhost"
                },
                "multi_import": {
                    "max_builds": 150,
                    "delay": 6
                }
            }, self.settings.settings.get_items())

        # checking if Keen.io configuration is set
        self.assertEqual("1234", keen.project_id)
        self.assertEqual("12345678", keen.write_key)
        self.assertEqual("abcdefg", keen.read_key)
        self.assertEqual("7890abcd", keen.master_key)
        self.assertTrue(keenio.is_readable())
        self.assertTrue(keenio.is_writable())
예제 #10
0
    def test_load_settings(self):
        """Test Settings.load_settings()"""
        # checking if Keen.io configuration is not set (yet)
        self.assertEqual(None, keen.project_id)
        self.assertEqual(None, keen.write_key)
        self.assertEqual(None, keen.read_key)
        self.assertEqual(None, keen.master_key)

        scriptname = "script.py"
        expected_ci = "travis"
        expected_project_name = "test/project"

        argv = [
            scriptname,
            "--ci={0!s}".format(expected_ci),
            "--repo={0!s}".format(expected_project_name),
            "argument"
        ]

        exp_config = os.environ["BUILD_TREND_CONFIGFILE"] = "test/config.js"

        # load settings (config file, env vars and cli parameters)
        self.assertListEqual(
            ["argument"],
            self.settings.load_settings(argv,
                                        constants.TEST_SAMPLE_CONFIG_FILE)
        )
        self.assertDictEqual(
            {
                "project_name": expected_project_name,
                "ci_platform": expected_ci,
                "mode_native": True,
                "mode_keen": False,
                "loglevel": "INFO",
                "data_detail": "extended",
                'repo_data_detail': {
                    'user1/': 'full',
                    'user2': 'extended',
                    'test/repo': 'basic'
                },
                "setting1": "test_value1",
                "dashboard_sample_configfile":
                constants.DASHBOARD_SAMPLE_CONFIG_FILE,
                "dashboard_configfile": exp_config,
                "task_queue": {
                    "backend": "amqp",
                    "broker_url": "amqp://user@localhost"
                },
                "multi_import": {
                    "max_builds": 150,
                    "delay": 6
                }
            },
            self.settings.settings.get_items())

        # checking if Keen.io configuration is set
        self.assertEqual("1234", keen.project_id)
        self.assertEqual("12345678", keen.write_key)
        self.assertEqual("abcdefg", keen.read_key)
        self.assertEqual("7890abcd", keen.master_key)
        self.assertTrue(keenio.is_readable())
        self.assertTrue(keenio.is_writable())

        del os.environ["BUILD_TREND_CONFIGFILE"]