Add unit test mode to srdnsupdater

This makes it not send any messages to srdns, thereby not changing the
dns server. It logs everything, though.
This commit is contained in:
Nick Hurley 2013-02-01 15:32:53 -08:00
Родитель 4c1414c90e
Коммит 7a4bea0d65
1 изменённых файлов: 6 добавлений и 0 удалений

Просмотреть файл

@ -22,10 +22,12 @@ class StoneRidgeDnsUpdater(object):
else:
self.is_windows = False
self.netconfig = stoneridge.get_config('run', 'netconfig')
self.unittest = stoneridge.get_config_bool('stoneridge', 'unittest')
logging.debug('restore: %s' % (restore,))
logging.debug('peer: %s' % (self.peer,))
logging.debug('is windows: %s' % (self.is_windows,))
logging.debug('netconfig: %s' % (self.netconfig,))
logging.debug('unittest: %s' % (self.unittest,))
def _converse(self, msgtype, msgdata=None):
logging.debug('msgtype: %s' % (msgtype,))
@ -33,6 +35,10 @@ class StoneRidgeDnsUpdater(object):
if msgdata is None:
msgdata = ''
if self.unittest:
logging.debug('Not sending message: in unit test mode')
return
# Set up our connection
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(self.peer)