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." )
def deselect_property(index): connection = get_database_connection() with connection: set_property_selected_false(connection, index) return ""
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.")
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." )
def selected(): connection = get_database_connection() with connection: return json.dumps(get_selected_properties(connection))
def search(string): connection = get_database_connection() with connection: return json.dumps(get_properties_by_address_or_description_fragment(connection, string))
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)