Beispiel #1
0
    def _insert_config(self):
        """Insert first config in the database.

        Args:
            None

        Returns:
            None

        """
        # Initialize key variables
        key_values = [('version', '0.0.0.0')]

        # Cycle through all the key value pairs
        for item in key_values:
            key = item[0]
            value = item[1]

            # Check if value exists and insert if not
            if db_configuration.config_key_exists(key) is False:
                record = Configuration(
                    config_key=general.encode(key),
                    config_value=general.encode(value))
                database = db.Database()
                database.add(record, 1108)
def setup_db_IDXConfiguration():
    """Create the database for Configuration table testing.

    Args:
        None

    Returns:
        None

    """
    # Initialize key variables
    idx_configuration = 1

    # Get Configuration
    config_key = general.hashstring('_INFOSET_TEST_')
    config_value = general.hashstring('_INFOSET_TEST_VALUE_')

    # Create a dict of all the expected values
    expected = {
        'config_key': config_key,
        'config_value': config_value,
        'idx_configuration': idx_configuration,
        'enabled': 1,
        'exists': True
    }

    # Drop the database and create tables
    initialize_db()

    # Insert data into database
    data = Configuration(
        config_key=general.encode(expected['config_key']),
        config_value=general.encode(expected['config_value']),
        enabled=expected['enabled'])
    database = db.Database()
    database.add_all([data], 1045)

    # Return
    return expected