def test_log_state_change(self): _eq = self.assertEquals h = SyncMessageTest.basic_hash state_master = MockStateMaster() worker = MockIOWorker() controller = "c1" speaker = STSSyncProtocolSpeaker(controller=controller, state_master=state_master, json_io_worker=worker) worker.receive(h) _eq(1, len(state_master.changes)) _eq( (controller, SyncTime(**h['time']), h['fingerPrint'], h['name'], h['value']), state_master.changes[0])
def get_time(self): """ Hack alert: python logging use time.time(). That means that log statements in the determinism protocols are going to invoke get_time again. Solve by returning the real time if we (get_time) are in the stacktrace """ if self._in_get_time: return time._orig_time() try: self._in_get_time = True time_array = self.connection.request("DeterministicValue", "gettimeofday") sync_time = SyncTime(*time_array) return sync_time.as_float() finally: self._in_get_time = False
def extract_label_time(json_hash): assert_fields_exist(json_hash, 'label', 'time') label = json_hash['label'] time = SyncTime(json_hash['time'][0], json_hash['time'][1]) return (label, time)
def test_basic(self): t = SyncTime(**{"seconds": 1347830756, "microSeconds": 474865})
def test_basic(self): # TODO(cs): test something t = SyncTime(**{"seconds": 1347830756, "microSeconds": 474865})