Esempio n. 1
0
    def setUp(self):
        """Sets up new mock and test objects for each test."""

        self.mock = mock.Mock()
        self.test = packets.Packet()
        self.config = configurator.Config()
        self.config.set_config()
Esempio n. 2
0
    def setUp(self):
        """Initialises a mocker and a Metric object
        to be tested."""

        self.mock = mock.Mock()
        self.test = metrics.Metric()
        self.config = configurator.Config()
Esempio n. 3
0
    def setUp(self):
        """Initialises the Reader object
        to be tested and Mock."""

        self.test = reader.Reader()
        self.config = configurator.Config()
        self.config.set_config()
        self.mock = mock.Mock()
Esempio n. 4
0
    def validate_config(self):
        """Validates the parser.ini file before
        reading from it."""

        parser = configurator.Config()
        is_valid = self.validator.check_config()

        if is_valid is False:
            parser.set_config()
Esempio n. 5
0
def start():
    """It first validates the config.ini file.
       It sets connection to the RabbitMQ queue to send the metrics.
       Sets the machine id.
       It starts the Flask server, then the client and server thread
       on send and consume side of RabbitMQ."""

    configurator.Config()
    identifier.Identifier()
    reader.Reader()

    metrics = packets.Packet()
    machine_id = metrics.machine_id

    rabbit_connection = metrics.set_connection()

    app.start_app()

    start_threads(rabbit_connection, app.APP, machine_id)
Esempio n. 6
0
    def setUp(self):
        """Calls the Config object to handle
        parser.ini file, and Mock."""

        self.mock = mock.Mock()
        self.test = configurator.Config()
Esempio n. 7
0
    def tearDown(self):
        """Creates a new config.ini file after each test."""

        self.config = configurator.Config()
        self.config.set_config()
Esempio n. 8
0
    def setUp(self):
        """Initialises the validator and configurator
        for each test."""

        self.config = configurator.Config()
        self.test = validator.Validator()
Esempio n. 9
0
    def tearDown(self):
        """After each test, a new config.ini file is created."""

        self.config = configurator.Config()
        self.config.set_config()
Esempio n. 10
0
"""Module which uses Flask to get the packets out of the database
and make them available to web use."""
import flask
from util import configurator
from util import reader
from server import database, flask_server

APP = flask.Flask(__name__, template_folder="templates")
CONFIG = configurator.Config()
READ = reader.Reader()
DATABASE = database.Database(APP)


def start_app():
    """Starts the thread which runs Flask APP."""

    thread = flask_server.FlaskThread(APP)
    thread.setDaemon(True)
    thread.start()


@APP.route('/')
def main_page_route():
    """Displays the main page and the types of information
     you can get the server to display."""

    return flask.render_template("main_page.html")


@APP.route('/supported_metrics')
def supported_metrics_route():