Skip to content
This repository has been archived by the owner on Mar 24, 2021. It is now read-only.

Commit

Permalink
Improvement to storage test
Browse files Browse the repository at this point in the history
Mostly around allowing the storage engine query method to return a
generator. Also some formatting tidy up.
  • Loading branch information
robyoung committed Aug 25, 2014
1 parent 44af08a commit 32526f4
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions tests/core/storage/test_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ def test_create_and_delete(self):
def test_simple_saving_and_finding(self):
self._save_all('foo_bar', {'foo': 'bar'})

assert_that(self.engine.execute_query('foo_bar', Query.create()),
contains(has_entries({'foo': 'bar'})))
assert_that(
self.engine.execute_query('foo_bar', Query.create()),
contains(has_entries({'foo': 'bar'})))

def test_saving_a_record_adds_an_updated_at(self):
self._save_all('foo_bar', {'_id': 'first'})
Expand All @@ -85,14 +86,16 @@ def test_get_last_updated(self):
is_(d_tz(2012, 12, 12)))

def test_get_last_updated_returns_none_if_there_is_none(self):
assert_that(self.engine.get_last_updated('foo_bar'), is_(None))
assert_that(
self.engine.get_last_updated('foo_bar'),
is_(None))

def test_saving_a_record_with_an_id_updates_it(self):
self._save_all('foo_bar',
{'_id': 'first', 'foo': 'bar'},
{'_id': 'first', 'foo': 'foo'})

results = self.engine.execute_query('foo_bar', Query.create())
results = list(self.engine.execute_query('foo_bar', Query.create()))

assert_that(len(results), is_(1))
assert_that(results, contains(has_entries({'foo': 'foo'})))
Expand All @@ -103,20 +106,23 @@ def test_capped_data_set_is_capped(self):
for i in range(100):
self.engine.save_record('foo_bar', {'foo': i})

result = self.engine.execute_query('foo_bar', Query.create())
assert_that(
len(self.engine.execute_query('foo_bar', Query.create())),
len(list(result)),
less_than(70))

def test_empty_a_data_set(self):
self._save_all('foo_bar',
{'foo': 'bar'}, {'bar': 'foo'})

assert_that(len(self.engine.execute_query('foo_bar', Query.create())), is_(2))
result = self.engine.execute_query('foo_bar', Query.create())
assert_that(len(list(result)), is_(2))

# TODO: fix inconsistency
self.engine.empty_data_set('foo_bar')

assert_that(len(self.engine.execute_query('foo_bar', Query.create())), is_(0))
result = self.engine.execute_query('foo_bar', Query.create())
assert_that(len(list(result)), is_(0))

def test_datetimes_are_returned_as_utc(self):
self._save_all('foo_bar',
Expand Down

0 comments on commit 32526f4

Please sign in to comment.