def test_organize_same_times(self): servers, entries, clock_skew, db = self.db_setup() logger = logging.getLogger(__name__) original_date = datetime.now() entries.insert(self.generate_doc("status", "apple", "STARTUP2", 5, "pear", original_date)) entries.insert(self.generate_doc("status", "apple", "STARTUP2", 5, "pear", original_date)) entries.insert(self.generate_doc("status", "pear", "STARTUP2", 5, "apple", original_date)) entries.insert(self.generate_doc("status", "pear", "STARTUP2", 5, "apple", original_date)) entries.insert(self.generate_doc("status", "plum", "STARTUP2", 5, "apple", original_date)) entries.insert(self.generate_doc("status", "plum", "STARTUP2", 5, "apple", original_date)) servers.insert(self.generate_server_doc("status", "plum", "STARTUP2", 5, "apple", original_date)) servers.insert(self.generate_server_doc("status", "apple", "STARTUP2", 5, "plum", original_date)) servers.insert(self.generate_server_doc("status", "pear", "STARTUP2", 5, "apple", original_date)) organized_servers = organize_servers(db, "fruit") logger.debug("Organized servers Printing: {}".format(organized_servers)) for server_name in organized_servers: logger.debug("Server Name: {}".format(server_name)) first = True for item in organized_servers[server_name]: logger.debug("Item list: {}".format(item)) if first: past_date = item["date"] first = False continue current_date = item["date"] assert past_date <= current_date past_date = current_date
def test_organize_two_servers(self): logger = logging.getLogger(__name__) servers, entries, clock_skew, db = self.db_setup() original_date = datetime.now() entries.insert( self.generate_doc("status", "apple", "STARTUP2", 5, "pear", original_date)) entries.insert( self.generate_doc("status", "pear", "STARTUP2" "", 5, "apple", original_date + timedelta(seconds=5))) assign_address(self, 1, "apple", servers) assign_address(self, 2, "pear", servers) organized_servers = organize_servers(db, "fruit") logger.debug( "Organized servers Printing: {}".format(organized_servers)) for server_name in organized_servers: logger.debug("Server Name: {}".format(server_name)) for item in organized_servers[server_name]: logger.debug("Item list: {}".format(item)) logger.debug("Item: {}".format(item)) assert item
def test_organizing_three_servers(self): servers, entries, clock_skew, db = self.db_setup() logger = logging.getLogger(__name__) original_date = datetime.now() entries.insert( self.generate_doc("status", "apple", "STARTUP2", 5, "pear", original_date)) entries.insert( self.generate_doc("status", "apple", "STARTUP2" "", 5, "pear", original_date + timedelta(seconds=14))) entries.insert( self.generate_doc("status", "pear", "STARTUP2" "", 5, "apple", original_date + timedelta(seconds=5))) entries.insert( self.generate_doc("status", "pear", "STARTUP2" "", 5, "apple", original_date + timedelta(seconds=15))) entries.insert( self.generate_doc("status", "plum", "STARTUP2" "", 5, "apple", original_date + timedelta(seconds=9))) entries.insert( self.generate_doc("status", "plum", "STARTUP2" "", 5, "apple", original_date + timedelta(seconds=11))) servers.insert( self.generate_server_doc("status", "plum", "STARTUP2", 5, "apple", original_date)) servers.insert( self.generate_server_doc("status", "apple", "STARTUP2" "", 5, "plum", original_date + timedelta(seconds=9))) servers.insert( self.generate_server_doc("status", "pear", "STARTUP2" "", 5, "apple", original_date + timedelta(seconds=6))) organized_servers = organize_servers(db, "fruit") logger.debug( "Organized servers Printing: {}".format(organized_servers)) for server_name in organized_servers: logger.debug("Server Name: {}".format(server_name)) first = True for item in organized_servers[server_name]: logger.debug("Item list: {}".format(item)) if first: past_date = item["date"] first = False continue current_date = item["date"] assert past_date <= current_date past_date = current_date
def test_organize_two_servers(self): logger = logging.getLogger(__name__) servers, entries, clock_skew, db = db_setup() original_date = datetime.now() entries.insert(self.generate_doc( "status", "apple", "STARTUP2", 5, "pear", original_date)) entries.insert(self.generate_doc("status", "pear", "STARTUP2" "", 5, "apple", original_date + timedelta(seconds=5))) assign_address(1, "apple", servers) assign_address(2, "pear", servers) organized_servers = organize_servers(db, "fruit") logger.debug("Organized servers Printing: {}".format(organized_servers)) for server_name in organized_servers: logger.debug("Server Name: {}".format(server_name)) for item in organized_servers[server_name]: logger.debug("Item list: {}".format(item)) logger.debug("Item: {}".format(item)) assert item