Ejemplo n.º 1
0
    def test_set_property_selected_false(self):
        connection = get_database_connection(IN_MEMORY_DB_NAME)

        with connection:
            create_database(connection)

            set_property_selected_true(connection, 0)

            selected_properties = get_selected_properties(connection)

            self.assertEqual(
                len(selected_properties), 1,
                "There was not exactly one selected property. This is unexpected."
            )
            self.assertEqual(
                selected_properties[0]["index"], 0,
                "The selected property's index was not zero. This is unexpected."
            )

            set_property_selected_false(connection, 0)

            selected_properties_2 = get_selected_properties(connection)

            self.assertEqual(
                len(selected_properties_2), 0,
                "There was not exactly zero selected properties. This is unexpected."
            )
Ejemplo n.º 2
0
def deselect_property(index):
    connection = get_database_connection()

    with connection:
        set_property_selected_false(connection, index)

    return ""
Ejemplo n.º 3
0
    def test_get_properties_by_address_or_description_fragment(self):
        connection = get_database_connection(IN_MEMORY_DB_NAME)

        with connection:
            create_database(connection)

            properties = get_properties_by_address_or_description_fragment(
                connection, "six")

            self.assertGreater(
                len(properties), 0,
                "Zero properties were returned. This is unexpected.")
Ejemplo n.º 4
0
    def test_create_database(self):
        connection = get_database_connection(IN_MEMORY_DB_NAME)

        with connection:
            create_database(connection)

            cursor = connection.cursor()

            cursor.execute(get_show_tables_command_string())

            response = cursor.fetchall()

            if len(response) > 0:
                self.assertEqual(
                    response[0][0], "properties",
                    "The correct database table was not created.")
            else:
                self.fail(
                    "There appears to be no database tables. This is unexpected."
                )
Ejemplo n.º 5
0
def selected():
    connection = get_database_connection()

    with connection:
        return json.dumps(get_selected_properties(connection))
Ejemplo n.º 6
0
def search(string):
    connection = get_database_connection()

    with connection:
        return json.dumps(get_properties_by_address_or_description_fragment(connection, string))
Ejemplo n.º 7
0
import logging

from flask import Flask
from app.util import configure_logging
from app.apis import register_apis_blueprint
from app.views import register_views_blueprint

from app.db import (create_database,
                    get_database_connection)

logger = logging.getLogger(__name__)

configure_logging()

flask_application = Flask("enodo", static_folder="app/static")

connection = get_database_connection()
with connection:
    create_database(connection)

register_views_blueprint(flask_application)
register_apis_blueprint(flask_application)

flask_application.run(port=8080, debug=True)