def setup_configuration_file(self):
        """Creates the config.txt file, which contains the metrics
        which are possible to monitor.
        In order to deactivate one metric, write FALSE instead of TRUE"""

        with open(self.config_path, "w+") as f_config:

            f_config.write(get_configuration_file_form())
예제 #2
0
    def get_send_time(self):
        """Tests if the get_send_time() reads the send time correctly"""

        with open(self.config_path, "w") as f_config:
            f_config.write(get_configuration_file_form())

        self.assertEqual(self.reader.get_send_time(), "2")
        self.assertNotEqual(self.reader.get_send_time(), "666")
예제 #3
0
    def test_get_ip(self):
        """Tests if the get_ip() reads the ip correctly"""

        with open(self.config_path, "w") as f_config:
            f_config.write(get_configuration_file_form())

        self.assertEqual(self.reader.get_port(), "5672")
        self.assertNotEqual(self.reader.get_port(), "666")
예제 #4
0
    def test_get_address(self):
        """Tests if the get_address() reads the address correctly"""

        with open(self.config_path, "w") as f_config:
            f_config.write(get_configuration_file_form())

        self.assertEqual(self.reader.get_address(), "localhost")
        self.assertNotEqual(self.reader.get_address(), "bad bad bad")
예제 #5
0
    def test_get_flask_port(self):
        """Tests whether the get_flask_port function works."""

        with open(self.config_path, "w") as f_config:
            f_config.write(get_configuration_file_form())

        expected_value = "500"

        self.assertEqual(self.read_handler.get_flask_port(), expected_value)
        self.assertNotEqual(self.read_handler.get_flask_port(), "not tea")
예제 #6
0
    def test_get_flask_address(self):
        """Tests whether the get_flask_address function works."""

        with open(self.config_path, "w") as f_config:
            f_config.write(get_configuration_file_form())

        expected_value = "localhost"

        self.assertEqual(self.read_handler.get_flask_address(), expected_value)
        self.assertNotEqual(self.read_handler.get_flask_address(), "coffee")
예제 #7
0
    def test_get_mongodb_link(self):
        """Tests whether the get_mongodb_link function works."""

        with open(self.config_path, "w") as f_config:
            f_config.write(get_configuration_file_form())

        expected_value = "database_link"

        self.assertEqual(self.read_handler.get_mongodb_uri(), expected_value)
        self.assertNotEqual(self.read_handler.get_mongodb_uri(), "cake")
    def test_check_configuration(self):
        """Tests if the initialise_configuration_id() function creates,
        verifies and writes the file correctly."""

        self.test.check_configuration()
        self.assertEqual(os.path.isfile(self.config_path), 1)

        f_config = open(self.config_path, "r+")
        self.assertEqual(f_config.read(), get_configuration_file_form())

        f_config.close()
예제 #9
0
    def test_get_metrics(self):
        """Tests if get_metrics() reads the options of the metrics
        from the configuration file correctly."""

        f_config = open(self.config_path, "w")
        f_config.write(get_configuration_file_form())
        f_config.close()

        metric_values_1 = ['TRUE', 'TRUE', 'TRUE', 'TRUE']
        metric_values_2 = ['FALSE', 'TRUE', 'TRUE', 'TRUE']

        self.assertEqual(self.reader.get_metrics(), metric_values_1)
        self.assertNotEqual(self.reader.get_metrics(), metric_values_2)
    def test_validate_structure(self):
        """Tests if the validate_structure() function
        the file structure is correctly handled."""

        with open(self.config_path, "w") as f_config:
            f_config.write(get_configuration_file_form())

        self.assertEqual(self.test.validate_configuration_file(), True)

        with open(self.config_path, "w") as f_config:
            f_config.write("This will be bad.")

        self.assertEqual(self.test.validate_configuration_file(), False)