tests.unit_tests.db.test_yawning_titan_db.DemoDB#

class tests.unit_tests.db.test_yawning_titan_db.DemoDB(name)[source]#

Bases: YawningTitanDB

An implementation of YawningTitanDB.

Methods

all

Get all docs.

close

Close the db.

count

Count how many docs are in the db.

get

Get a dog from its uuid.

insert

Insert a doc and return the inserted doc.

is_locked

Check whether a doc is locked for editing or not.

remove

Remove a document with a given uuid.

remove_by_cond

Remove documents matching a query.

search

Search for docs using Query.

show

Show details of all entries in the db.

update

Update a doc by uuid.

upsert

Upsert a doc by uuid.

Attributes

db

The instance of TinyDB.

name

The DB name.

insert(doc, name=None, description=None, author=None)[source]#

Insert a doc and return the inserted doc.

all()[source]#

Get all docs.

get(uuid)[source]#

Get a dog from its uuid.

search(query)[source]#

Search for docs using Query.

update(doc, uuid, name=None, description=None, author=None)[source]#

Update a doc by uuid.

upsert(doc, uuid, name=None, description=None, author=None)[source]#

Upsert a doc by uuid.

remove_by_cond(cond)[source]#

Remove documents matching a query.

remove(uuid)[source]#

Remove a document with a given uuid.

close()#

Close the db.

count(cond=None)#

Count how many docs are in the db. Extends tinydb.table.Table.count.

A YawningTitanQuery can be used to filter the count.

Parameters:

cond – An optional YawningTitanQuery. Has a default value of None.

Returns:

The number of docs counted.

property db#

The instance of TinyDB.

classmethod is_locked(doc)#

Check whether a doc is locked for editing or not.

Parameters:

doc – A doc.

Returns:

True if the doc is locked, otherwise False.

property name#

The DB name.

show(verbose=False)#

Show details of all entries in the db.

Parameters:

verbose – If True, all doc metadata details are shown, otherwise just the name is shown.