def main() : """ Mess with dates for testing purposes """ # Get the command line arguments p = optparse.OptionParser() p.add_option("--source_dir", action="store", dest="source_dir") p.add_option("--test_name", action="store", dest="test_name") opts, source_file_args = p.parse_args() #pylint: disable-msg=W0612 hostname = socket.gethostname().split('.')[0] while True : print "Enter Data or Alert D|A -> " mode = sys.stdin.readline() print "Enter New Date -> " date_string = sys.stdin.readline() date_object = datetime.strptime(date_string.rstrip(), '%Y %m %d %H:%M') if mode.rstrip() == 'D' : sync_data = SyncData(hostname, opts.source_dir, opts.test_name) sync_data.variable = date_object sync_data.write() else : sync_alert = SyncDataAlert(hostname, opts.source_dir, opts.test_name) sync_alert.variable = date_object sync_alert.write()
def test_clockdrift_SyncData(self) : """ Check that delay checks are properly implemented """ sync_data = SyncData(HOST_NAME, GOOD_TEST_PATH, TEST_NAME) sync_data.set_last_stored() sync_data.last_stored = sync_data.last_stored + GOOD_DIFF_TIME sync_data.variable = sync_data.last_stored sync_data.write() sync_data = SyncData( HOST_NAME, GOOD_TEST_PATH, TEST_NAME) self.assertEquals(sync_data.is_sync_late(2), POTENTIAL_CLOCK_DRIFT)
def test_islate_SyncData(self) : """ Check that delay checks are properly implemented """ sync_data = SyncData(HOST_NAME, GOOD_TEST_PATH, TEST_NAME) self.assertEquals(sync_data.is_sync_late(2), SYNC_LATE) sync_data.set_last_stored() self.assertEquals(sync_data.is_sync_late(2), SYNC_OK) sync_data.last_stored = sync_data.last_stored - GOOD_DIFF_TIME sync_data.variable = sync_data.last_stored sync_data.write() sync_data = SyncData( HOST_NAME, GOOD_TEST_PATH, TEST_NAME) self.assertEquals(sync_data.is_sync_late(1.9), SYNC_LATE)