Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions rhc/database/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
THE SOFTWARE.
'''
import pymysql
import threading


class _DB(object):
Expand Down Expand Up @@ -55,7 +54,7 @@ def setup(self, dirty=False, database_map=None, commit=True, close=False, delta=
return self

@property
def delta(self):
def delta(self):
''' only specify changed columns on update '''
return self.__delta

Expand Down
20 changes: 20 additions & 0 deletions rhc/database/test/test_basic.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import absolute_import
import pytest
import weakref

from rhc.database.dao import DAO

Expand Down Expand Up @@ -103,3 +104,22 @@ def test_join(data):
assert len(names) == 2
assert 'fred' in names
assert 'sally' in names


def test_dao_cleanup_from_save(db):
obj = Parent(foo=1, bar=2).save()
ref = weakref.ref(obj)
assert obj is ref()
obj = 0 # dereference
assert ref() is None


def test_dao_cleanup_from_load(db):
# save object and remember id
obj_id = Parent(foo=1, bar=2).save().id
assert obj_id
obj = Parent.load(obj_id)
ref = weakref.ref(obj)
assert ref() is obj
obj = 0
assert ref() is None