Skip to content
This repository has been archived by the owner on Nov 9, 2020. It is now read-only.

Commit

Permalink
Fix local cache delete issue and add more unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: Sihan Wang <wsihan@vmware.com>
  • Loading branch information
sihanwang41 authored and ericwb committed Aug 8, 2017
1 parent ee8f0df commit 477182f
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion column/api/backend/cache/local_mem.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def _is_full(self):

def _evict(self):
del_key = self._key_queue.popleft()
self._del[del_key]
self._del(del_key)
return del_key

def _keys(self):
Expand Down
2 changes: 1 addition & 1 deletion tests/api/controllers/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def test_null_parameter_in_payload(self):
self._wait_for_run_complete(res_dict['id'])

def test_delete_running_job(self):
pb = 'tests/fixtures/playbooks/hello_world.yml'
pb = 'tests/fixtures/playbooks/hello_world_with_sleep.yml'
response = self.app.post(
'/runs',
data=json.dumps(dict(playbook_path=pb,
Expand Down
Empty file added tests/cache/__init__.py
Empty file.
19 changes: 19 additions & 0 deletions tests/cache/test_cache.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import testtools

from column.api import backend


class TestLocalMemoryCache(testtools.TestCase):

def setUp(self):
super(TestLocalMemoryCache, self).setUp()
self.store = backend.get_store()

def test_add_runs(self):
self.assertTrue(self.store.create_run('key1', {'id': '1'}))
self.assertEqual({'id': '1'}, self.store.get_run('key1'))

def test_update_run(self):
self.store.create_run('key5', {'id': '5'})
self.store.update_run('key5', {'id': '55'})
self.assertEqual({'id': '55'}, self.store.get_run('key5'))
7 changes: 7 additions & 0 deletions tests/fixtures/playbooks/hello_world_with_sleep.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
- hosts: all
tasks:
- shell: sleep 10
- hosts: all
tasks:
- shell: echo "hello world"

0 comments on commit 477182f

Please sign in to comment.