def test_cache_config_from_sis_with_cl_update(self): ''' Test config from command line and SIS server. ''' test_commandline = "--port=4000 --directory=test_cache --torrentdir=test_torrent_dir " + \ "--downlimit=256 --uplimit=256 --spacelimit=4000 --conlimit=20 " + \ "--logfile=test_cache.log --id=34 --neighbour_selection=enable " + \ "--ranking_source=ip_pre --sis_url=http://localhost:8080/sis " + \ "--report_to=http://localhost:8444 --console --loglevel=DEBUG" cache_config = CacheConfiguration() used_sis = cache_config.update_from_cl(test_commandline.split(" ")) self.assertTrue(used_sis) self.assertEquals(4000, cache_config.get_port()) self.assertEquals("test_cache", cache_config.get_directory()) self.assertEquals("test_torrent_dir", cache_config.get_torrent_directory()) self.assertEquals(256, cache_config.get_download_limit()) self.assertEquals(256, cache_config.get_upload_limit()) self.assertEquals(4000, cache_config.get_space_limit()) self.assertEquals(20, cache_config.get_connection_limit()) self.assertEquals("test_cache.log", cache_config.get_logfile()) self.assertEquals(34, cache_config.get_id()) self.assertEquals(constants.NS_MODE_ENABLE, cache_config.get_ns_mode()) self.assertEquals(constants.RS_IP_PRE, cache_config.get_ranking_source()) self.assertEquals("http://localhost:8080/sis", cache_config.get_sis_url()) self.assertEquals("http://localhost:8080/sis/IoPEndpoint", cache_config.get_sis_iop_url()) self.assertEquals("http://localhost:8444", cache_config.get_report_to()) self.assertEquals(True, cache_config.has_cache_console())
def test_cache_update_from_sis_only(self): ''' Test config from config file and SIS. ''' test_commandline = "--sis_url=http://localhost:8080/sis" cache_config = CacheConfiguration() used_sis = cache_config.update_from_cl(test_commandline.split(" ")) self.assertTrue(used_sis) print "No way to obtain meaningful iop parameters from SIS right now, Skip assertions." return self.assertEquals(300, cache_config.get_torrent_selection_interval()) self.assertEquals(1024, cache_config.get_upload_limit()) self.assertEquals(2048, cache_config.get_download_limit()) self.assertEquals(5, cache_config.get_connection_limit()) self.assertEquals(True, cache_config.establish_remote_connections())