autowisp.tests.test_bui_db_config module

Class Inheritance Diagram

Inheritance diagram of DbConfigTestCase, Path, TestDefaultDatabase, TestDiscovery, TestMysqlDriver, TestUrlTranslation

Tests for resolving which database the browser interface uses.

These exercise django_project.db_config directly rather than through settings, because the setting is read once at import time and cannot be re-resolved afterwards.

class autowisp.tests.test_bui_db_config.DbConfigTestCase(methodName='runTest')[source]

Bases: TestCase

Inheritance diagram of autowisp.tests.test_bui_db_config.DbConfigTestCase

Base giving each test an empty data directory and no environment.

_restore_env()[source]

Put back whatever the environment held before the test.

setUp()[source]

Hook method for setting up the test fixture before exercising it.

write_url_file(url)[source]

Write url to the data directory’s URL file.

class autowisp.tests.test_bui_db_config.TestDefaultDatabase(methodName='runTest')[source]

Bases: DbConfigTestCase

Inheritance diagram of autowisp.tests.test_bui_db_config.TestDefaultDatabase

An unconfigured installation keeps working untouched.

test_defaults_to_sqlite_in_the_data_directory()[source]

This is what every existing installation already has.

class autowisp.tests.test_bui_db_config.TestDiscovery(methodName='runTest')[source]

Bases: DbConfigTestCase

Inheritance diagram of autowisp.tests.test_bui_db_config.TestDiscovery

Where the URL is looked for, and in what order.

test_empty_values_are_ignored()[source]

An empty variable or file falls through to the default.

test_environment_wins()[source]

The environment takes precedence over the file.

test_nothing_configured()[source]

No environment and no file means no URL.

test_url_file()[source]

A URL file is read, and surrounding whitespace ignored.

class autowisp.tests.test_bui_db_config.TestMysqlDriver(methodName='runTest')[source]

Bases: DbConfigTestCase

Inheritance diagram of autowisp.tests.test_bui_db_config.TestMysqlDriver

Django’s MySQL backend is made to work with the driver present.

test_pymysql_is_accepted()[source]

AutoWISP documents mysql+pymysql but depends on no driver.

Django’s backend imports MySQLdb, so pymysql has to be installed under that name; skipped where neither is present.

class autowisp.tests.test_bui_db_config.TestUrlTranslation(methodName='runTest')[source]

Bases: DbConfigTestCase

Inheritance diagram of autowisp.tests.test_bui_db_config.TestUrlTranslation

A URL becomes Django’s DATABASES dictionary.

test_mariadb_uses_the_same_backend()[source]

MariaDB is MySQL as far as Django is concerned.

test_mysql_url_is_mapped_field_by_field()[source]

The spelling matches the project database’s own URLs.

test_sqlite_url_supplies_the_path()[source]

An explicit SQLite file may live outside the data directory.

test_unsupported_backend_is_refused()[source]

Refused rather than half-supported.

core.timestamp_triggers implements modified triggers for SQLite and MySQL only, so accepting another backend would leave the column silently unmaintained.

translate(url)[source]

Return the default entry url maps to, driver aside.

Whether a driver can be loaded is TestMysqlDriver’s question, and it is stubbed out here so that this one – pure string handling – is answered everywhere rather than only where a driver happens to be installed. Which is one cell of the test grid: pip install . brings neither mysqlclient nor pymysql, a MySQL browser-interface database being an option rather than the default.