def test_presence(self): ''' Test for presence retrieving. ''' presence = Presence([('127.0.0.1', True)]) server = start_test_server() try: self.assertTrue( presence.is_absent('mcihar', datetime.date(2013, 7, 15)) is None) self.assertFalse( presence.is_absent('mcihar', datetime.date(2013, 10, 28)) is None) finally: stop_test_server(*server)
def test_presence(self): ''' Test for presence retrieving. ''' presence = Presence([('127.0.0.1', True)]) server = start_test_server() try: self.assertTrue( presence.is_absent('mcihar', datetime.date(2013, 7, 15)) is None ) self.assertFalse( presence.is_absent('mcihar', datetime.date(2013, 10, 28)) is None ) finally: stop_test_server(*server)
def test_presence(self): presence = Presence([('127.0.0.1', True)]) SocketServer.TCPServer.allow_reuse_address = True server = SocketServer.TCPServer(('127.0.0.1', 9874), MyTCPHandler) server_thread = threading.Thread(target=server.serve_forever) server_thread.daemon = False server_thread.start() try: self.assertTrue( presence.is_absent('mcihar', datetime.date(2013, 7, 15)) is None ) self.assertFalse( presence.is_absent('mcihar', datetime.date(2013, 10, 28)) is None ) finally: server.shutdown() server_thread.join()
def run(self): servers = [] for server in self.config.get('presence', 'servers').split(','): server = server.strip() if not server: continue nosend = False if server.endswith('/nosend'): server = server[:-7] nosend = True servers.append((server, nosend)) for absence in Presence(servers).get_presence_data(self.args.value[0]): self.println('{0} - {1}'.format(absence[0], absence[1]))
def test_presence(self): ''' Test for presence retrieving. ''' presence = Presence([('127.0.0.1', True)]) SocketServer.TCPServer.allow_reuse_address = True server = SocketServer.TCPServer(('127.0.0.1', 9874), MyTCPHandler) server_thread = threading.Thread(target=server.serve_forever) server_thread.daemon = False server_thread.start() try: self.assertTrue( presence.is_absent('mcihar', datetime.date(2013, 7, 15)) is None ) self.assertFalse( presence.is_absent('mcihar', datetime.date(2013, 10, 28)) is None ) finally: server.shutdown() server_thread.join()