Exemplo n.º 1
0
    def test_check_path_with_relative_path_to_incorrect_file(self):
        filename = 'something.str'
        path = './path/to/' + filename
        expectedresult = False
        result = check_path(path, filename)

        self.assertEqual(expectedresult, result)
Exemplo n.º 2
0
    def test_check_path_with_absolute_path_to_incorrect_file(self):
        filename = 'something.py'
        path = '/path/to/something.str'
        expectedresult = False
        result = check_path(path, filename)

        self.assertEqual(expectedresult, result)
Exemplo n.º 3
0
    def test_check_path_with_absolute_path_to_incorrect_file(self):
        filename = 'something.py'
        path = '/path/to/something.str'
        expectedresult = False
        result = check_path(path, filename)

        self.assertEqual(expectedresult, result)
Exemplo n.º 4
0
    def test_check_path_with_relative_path_to_incorrect_file(self):
        filename = 'something.str'
        path = './path/to/' + filename
        expectedresult = False
        result = check_path(path, filename)

        self.assertEqual(expectedresult, result)
Exemplo n.º 5
0
    def test_isfile_with_side_effects(self, mock_isfile):
        """Mocking os.path.isfile with using side_effect
        """
        def side_effect(filename):
            if filename == '/path/to/real/file/config.py':
                return True
            else:
                return False

        mock_isfile.side_effect = side_effect

        correctpath = '/path/to/real/file/'
        correctfile = 'config.py'
        incorrectfile = 'foo.txt'

        self.assertTrue(check_path(correctpath + correctfile, correctfile))
        self.assertFalse(check_path(correctpath + incorrectfile, incorrectfile))
Exemplo n.º 6
0
    def test_isfile_with_side_effects(self, mock_isfile):
        """Mocking os.path.isfile with using side_effect
        """
        def side_effect(filename):
            if filename == '/path/to/real/file/config.py':
                return True
            else:
                return False

        mock_isfile.side_effect = side_effect

        correctpath = '/path/to/real/file/'
        correctfile = 'config.py'
        incorrectfile = 'foo.txt'

        self.assertTrue(check_path(correctpath + correctfile, correctfile))
        self.assertFalse(check_path(correctpath + incorrectfile,
                                    incorrectfile))
Exemplo n.º 7
0
# contact with [email protected]
#
import os
import httplib
from flask import Flask, jsonify, make_response
from flask.ext.sqlalchemy import SQLAlchemy
from fiwareglancesync.app.settings.settings import logger_api
from fiwareglancesync.utils.checkpath import check_path


# Defile the WGSI application object
app = Flask(__name__, instance_relative_config=True)

# Configurations
configfile = os.environ.get("GLANCESYNCAPP_CONFIG")
if configfile and check_path(configfile, 'config.py'):
    app.config.from_envvar('GLANCESYNCAPP_CONFIG')
else:
    msg = '\nERROR: There is not defined GLANCESYNCAPP_CONFIG environment variable ' \
          '\n       pointing to config.py path file' \
          '\n       Please correct at least one of them to execute the program.'
    exit(msg)

# Define the database object which is imported
# by modules and controllers
db = SQLAlchemy(app, session_options={'expire_on_commit': False})


# Import a module / component using its blueprint handler variable (mod_auth)
from mod_auth.controllers import mod_auth as auth_module    # noqa: ignore=E402
from mod_info.controllers import mod_info as info_module    # noqa: ignore=E402
Exemplo n.º 8
0
# For those usages not covered by the Apache version 2.0 License please
# contact with [email protected]
#
import os
import httplib
from flask import Flask, jsonify, make_response
from flask.ext.sqlalchemy import SQLAlchemy
from fiwareglancesync.app.settings.settings import logger_api
from fiwareglancesync.utils.checkpath import check_path

# Defile the WGSI application object
app = Flask(__name__, instance_relative_config=True)

# Configurations
configfile = os.environ.get("GLANCESYNCAPP_CONFIG")
if configfile and check_path(configfile, 'config.py'):
    app.config.from_envvar('GLANCESYNCAPP_CONFIG')
else:
    msg = '\nERROR: There is not defined GLANCESYNCAPP_CONFIG environment variable ' \
          '\n       pointing to config.py path file' \
          '\n       Please correct at least one of them to execute the program.'
    exit(msg)

# Define the database object which is imported
# by modules and controllers
db = SQLAlchemy(app, session_options={'expire_on_commit': False})

# Import a module / component using its blueprint handler variable (mod_auth)
from mod_auth.controllers import mod_auth as auth_module  # noqa: ignore=E402
from mod_info.controllers import mod_info as info_module  # noqa: ignore=E402
from fiwareglancesync.app.settings.settings import CONTENT_TYPE, SERVER, SERVER_HEADER, JSON_TYPE  # noqa: ignore=E402