예제 #1
0
def write(field, i):
    """Write the given value to the pickled db."""
    PickledDB.instance = None
    orion_db = PickledDB(host='orion_db.pkl')
    try:
        orion_db.write('concurrent', {field: i})
    except DuplicateKeyError:
        print('dup')
        pass

    print(field, i)
예제 #2
0
    def test_instantiation_and_singleton(self):
        """Test create just one object, that object persists between calls."""
        database = Database(of_type="PickledDB", name="orion_test")

        assert isinstance(database, PickledDB)
        assert database is PickledDB()
        assert database is Database()

        with pytest.raises(SingletonAlreadyInstantiatedError):
            Database("fire", [], {"it_matters": "it's singleton"})
예제 #3
0
def orion_db():
    """Return PickledDB wrapper instance initiated with test opts."""
    PickledDB.instance = None
    orion_db = PickledDB(host='orion_db.pkl')
    yield orion_db