tests package

Submodules

tests.basetest module

Created on 2021-08-19

@author: wf

class tests.basetest.Basetest(methodName='runTest')[source]

Bases: unittest.case.TestCase

base test case

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

static inPublicCI()[source]

are we running in a public Continuous Integration Environment?

static isUser(name: str)[source]

Checks if the system has the given name

setUp(debug=False, profile=True)[source]

setUp test environment

tearDown()[source]

Hook method for deconstructing the test fixture after testing it.

class tests.basetest.Profiler(msg, profile=True)[source]

Bases: object

simple profiler

construct me with the given msg and profile active flag

Parameters:
  • msg (str) – the message to show if profiling is active
  • profile (bool) – True if messages should be shown
time(extraMsg='')[source]

time the action and print if profile is active

tests.testEntityManager module

tests.testJson module

Created on 2020-09-12

@author: wf

class tests.testJson.ServerConfig[source]

Bases: lodstorage.jsonable.JSONAble

class tests.testJson.TestJsonAble(methodName='runTest')[source]

Bases: tests.basetest.Basetest

test JSON serialization with JsonAble mixin

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

check(manager, manager1, listName, debugLimit)[source]

check that the list of the two managers are the same

dumpListOfDicts(listOfDicts, limit)[source]
setUp()[source]

setUp test environment

testIssue22()[source]

https://github.com/WolfgangFahl/pyLoDStorage/issues/22 Regression: storeToJsonFile and restoreFromJsonFile missing in JSONAble

testIssue27_Lookup()[source]

add Lookup map option

testIssue30_SampleLimited()[source]

tests if the json export is correctly limited to the fields that are used in the samples

testJsonAble()[source]

test JSONAble

testPluralName()[source]
testRestoreFromJsonStr()[source]

Tests restoring a JsonAbleList form a json string

testRoyals()[source]

test Royals example

testSingleQuoteToDoubleQuoteStackoverflow()[source]
see
testSingleToDoubleQuote()[source]
testStoreAndRestore()[source]

test storing and restoring from a JSON file https://github.com/WolfgangFahl/pyLoDStorage/issues/21

tests.testPandas module

tests.testSPARQL module

tests.testSqlite3 module

Created on 2020-08-24

@author: wf

class tests.testSqlite3.TestSQLDB(methodName='runTest')[source]

Bases: tests.basetest.Basetest

Test the SQLDB database wrapper

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

checkListOfRecords(listOfRecords, entityName, primaryKey=None, executeMany=True, fixNone=False, fixDates=False, debug=False, doClose=True)[source]

check the handling of the given list of Records

Parameters:
  • listOfRecords (list) – a list of dicts that contain the data to be stored
  • entityName (string) – the name of the entity type to be used as a table name
  • primaryKey (string) – the name of the key / column to be used as a primary key
  • executeMany (boolean) – True if executeMany mode of sqlite3 should be used
  • fixNone (boolean) – fix dict entries that are undefined to have a “None” entry
  • debug (boolean) – True if debug information e.g. CREATE TABLE and INSERT INTO commands should be shown
  • doClose (boolean) – True if the connection should be closed
static getSampleTableDB(withDrop=False, debug=False, failIfTooFew=False, sampleSize=1000)[source]
testBackup()[source]

test creating a backup of the SQL database

testBindingError()[source]

test list of Records with incomplete record leading to “You did not supply a value for binding 2” see https://bugs.python.org/issue41638

testCopy()[source]

test copying databases into another database

testEntityInfo()[source]

test creating entityInfo from the sample record

testIssue110()[source]

https://github.com/WolfgangFahl/pyLoDStorage/issues/110

testIssue13_setNoneValue()[source]

https://github.com/WolfgangFahl/pyLoDStorage/issues/13 set None value for undefined LoD entries

testIssue14_execute()[source]

https://github.com/WolfgangFahl/pyLoDStorage/issues/14

offer execute wrapper directly via sqlDB

testIssue15()[source]

https://github.com/WolfgangFahl/pyLoDStorage/issues/15

auto create view ddl in mergeschema

testIssue16()[source]

https://github.com/WolfgangFahl/pyLoDStorage/issues/16 allow to only warn if samplerecordcount is higher than number of available records

testIssue18()[source]

https://github.com/WolfgangFahl/pyLoDStorage/issues/18

testIssue41()[source]

https://github.com/WolfgangFahl/pyLoDStorage/issues/41 improve error message when create table command fails

testIssue87AllowUsingQueryWithGenerator()[source]

test the query gen approach

testListOfCities()[source]

test sqlite3 with some 120000 city records

testQueryParams()[source]

test Query Params

testSqlite3()[source]

test sqlite3 with a few records from the royal family

testSqllite3Speed()[source]

test sqlite3 speed with some 100000 artificial sample records consisting of two columns with a running index

testUniqueConstraint()[source]

test for https://github.com/WolfgangFahl/pyLoDStorage/issues/4 sqlite3.IntegrityError: UNIQUE constraint failed: … show debug info

tests.testTrulyTabular module

tests.test_Plot module

tests.test_Tabulate module

tests.test_csv module

class tests.test_csv.TestCSV(methodName='runTest')[source]

Bases: tests.basetest.Basetest

Tests functionalities for the conversion between csv and list od dicts (LoD)

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

setUp()[source]

setUp test environment

tearDown() → None[source]

Hook method for deconstructing the test fixture after testing it.

testCsvFromJSONAble()[source]

tests generation of csv from list of JSONAble object

testCsvFromJSONAbleExcludeFields()[source]

tests generation of csv from list of JSONAble object with excluding specific fields (negative list)

testCsvFromJSONAbleIncludeFields()[source]

tests generation of csv from list of JSONAble object with including only specified fields (positive list)

testRoyals()[source]

test conversion of royals

test_from_csv()[source]

tests if the csv is correctly parsed to an LoD

test_from_csv_without_header()[source]

tests if csv string without embedded headers is parsed correctly

test_restore_from_csvfile()[source]

tests if the lod is correctly restored from csv file

test_round_trip()[source]

tests the csv round trip: dict -> csv -> dict Note: the inital dict has missing values it is expected that the final dict has the missing keys with None as value

test_store_to_csvfile()[source]

tests if LoD is correctly stored as csv file

test_to_csv()[source]

tests if LoD is correctly converted to csv str

test_to_csv_delimiter_in_value()[source]

tests if delimiter in dict value will not result in incorrect values

test_to_csv_incomplete_dicts()[source]

tests if the LoD is correctly converted to csv even if some dicts are incomplete Note: incomplete dicts can lead to changes of the column orders of the csv string

tests.test_lod module

Created on 2021-06-11

@author: wf

class tests.test_lod.TestLOD(methodName='runTest')[source]

Bases: tests.basetest.Basetest

test list of dicts base functionality

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

checkHandleListTypeResult(lod, expectedLen, expected)[source]

check the result of the handleListType function

Parameters:
  • lod (list) – the list of dicts to check
  • expectedLen (int) – the expected Length
  • expected (str) – the expected entry for the München,Munich Q1524 record with a list
testGetFields()[source]

tests field extraction from list of JSONAble objects and LoD

testGetLookupIssue31And32()[source]

test for https://github.com/WolfgangFahl/pyLoDStorage/issues/31 test for https://github.com/WolfgangFahl/pyLoDStorage/issues/32

testListHandlingIssue33()[source]

test for handling list

testListIntersect()[source]

test a list intersection

tests.test_queries module

Module contents