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

Commit

Permalink
Add helpful utility functions to MockEtcd
Browse files Browse the repository at this point in the history
  • Loading branch information
a5huynh committed Feb 12, 2016
1 parent cced318 commit 72823e2
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,28 @@
# @Author: ahuynh
# @Date: 2016-01-28 10:04:58
# @Last Modified by: ahuynh
# @Last Modified time: 2016-02-11 14:30:08
# @Last Modified time: 2016-02-11 17:25:54
import etcd


class MockEtcd( object ):
def delete( self, value ):
pass

def write( self, value, ttl ):
pass
def __init__( self, raise_exception=False ):
self._reset()
self.raise_exception = raise_exception

def _check_raise( self ):
if self.raise_exception:
raise etcd.EtcdException( 'Test Exception' )

def _reset( self ):
self.deleted = set([])
self.written = {}

def delete( self, key ):
self._check_raise()
self.deleted.add( key )

def write( self, key, value, ttl ):
self._check_raise()
self.written[ key ] = value

0 comments on commit 72823e2

Please sign in to comment.