Example #1
0
    def test_load_configuration_incomplete(self):
        "Raises proper errors for an incomplete configuration"

        temp_file = tempfile.NamedTemporaryFile()
        test_conf = {
            "business": {
                "name": "Foo Bar",
                "notification_address": "*****@*****.**"
            }
        }
        temp_file.write(json.dumps(test_conf))
        temp_file.seek(0)

        with pytest.raises(Exception):
            load_configuration(temp_file.name)
Example #2
0
    def test_load_configuration_incomplete(self):
        "Raises proper errors for an incomplete configuration"

        temp_file = tempfile.NamedTemporaryFile()
        test_conf = {
            "business": {
                "name": "Foo Bar",
                "notification_address": "*****@*****.**"
            }
        }
        temp_file.write(json.dumps(test_conf))
        temp_file.seek(0)

        with pytest.raises(Exception):
            load_configuration(temp_file.name)
Example #3
0
 def setup_method(self, method):
     app.config['TESTING'] = True
     app.config['DEBUG'] = True
     app.config['email'] = load_configuration(
         os.path.join("test/fixtures/", "configuration.json"))
     # Attach the client
     self.client = app.test_client()
     # Turn on HTTP mocking
     httpretty.enable()
Example #4
0
 def setup_method(self, method):
     app.config['TESTING'] = True
     app.config['DEBUG'] = True
     app.config['email'] = load_configuration(
         os.path.join("test/fixtures/", "configuration.json"))
     # Attach the client
     self.client = app.test_client()
     # Turn on HTTP mocking
     httpretty.enable()
Example #5
0
    def test_load_configuration(self):
        "Tests that the load_coniguration method loads the config correctly"

        temp_file = tempfile.NamedTemporaryFile()
        test_conf = {
            "business": {
                "email_address": "*****@*****.**",
                "name": "Foo Bar",
                "notification_address": "*****@*****.**"
            }
        }
        temp_file.write(json.dumps(test_conf))
        temp_file.seek(0)

        conf = load_configuration(temp_file.name)
        assert conf == test_conf
Example #6
0
    def test_load_configuration(self):
        "Tests that the load_coniguration method loads the config correctly"

        temp_file = tempfile.NamedTemporaryFile()
        test_conf = {
            "business": {
                "email_address": "*****@*****.**",
                "name": "Foo Bar",
                "notification_address": "*****@*****.**"
            }
        }
        temp_file.write(json.dumps(test_conf))
        temp_file.seek(0)

        conf = load_configuration(temp_file.name)
        assert conf == test_conf
Example #7
0
import os
from shared.helpers import load_configuration
from flask import Flask

# The instance path has to be absolute so lets get the absolute path to our
# root directory.
my_directory = os.path.dirname(__file__)
root_directory = os.path.abspath(os.path.join(my_directory, ".."))

# Create the app and configure
app = Flask(__name__,
            instance_path=root_directory,
            instance_relative_config=True)

app.config.from_pyfile("settings.py")

path = os.path.join(my_directory, "../configuration.json")

app.config["email"] = load_configuration(path)