def assert_download_incomplete(self, num_chunks, chunk_pos): assert debugtools.compare_dict(self.file.serialize(), {'working': False, 'substate': [None], 'name': '10mb.bin', 'last_error': None, 'hash_type': None, 'state': 'download', 'approx_size': None, 'hash_value': None, 'size': 10485760}) assert len(self.file.chunks) == num_chunks for chunk in self.file.chunks: assert debugtools.compare_dict(chunk.serialize(), {'state': 'download', 'file': self.file.id}) if chunk_pos == '>': assert chunk.pos > chunk.begin elif chunk_pos == '==': assert chunk.pos == chunk.begin elif chunk_pos == '>=': assert chunk.pos >= chunk.begin assert self.file.chunks[-1].end == self.file.size
def _test_source(self, url, config_url): assert patch.sources == {} interface.call('patch', 'add_source', url=url) source = patch.sources['hoster'] data = source.serialize() debugtools.compare_dict(data, {'branches': [], 'config_url': config_url, 'url': 'http://github.com/downloadam/hoster.git', 'last_error': None, 'enabled': True, 'version': '0000000', 'id': 'hoster'}) try: with Timeout(10): patch.patch_all(external_loaded=False) except Timeout: print "WARNING: patch timed out. ignoring error" return data = source.serialize() debugtools.compare_dict(data, {'config_url': config_url, 'url': 'http://github.com/downloadam/hoster.git', 'last_error': None, 'enabled': True, 'id': 'hoster'}) assert 'master' in data['branches'] assert data['version'] != '0'*7
def _test_source(self, url, config_url): assert patch.sources == {} interface.call("patch", "add_source", url=url) source = patch.sources["hoster"] data = source.serialize() debugtools.compare_dict( data, { "branches": [], "config_url": config_url, "url": "http://github.com/downloadam/hoster.git", "last_error": None, "enabled": True, "version": "0000000", "id": "hoster", }, ) try: with Timeout(10): patch.patch_all(external_loaded=False) except Timeout: print "WARNING: patch timed out. ignoring error" return data = source.serialize() debugtools.compare_dict( data, { "config_url": config_url, "url": "http://github.com/downloadam/hoster.git", "last_error": None, "enabled": True, "id": "hoster", }, ) assert "master" in data["branches"] assert data["version"] != "0" * 7
def test_proxy(): return #ssh -v -N -D 127.0.0.1:1080 test.domain.com api.init() listener = scheme.PassiveListener('api') scheme.register(listener) type, host, port = 'socks5', '127.0.0.1', 1080 def check_output(text): wc = plugintools.wildcard('<html><head><title>Current IP Check</title></head><body>Current IP Address: *</body></html>') return wc.match(text) resp = requests.get('http://checkip.dyndns.org/') proxyless_text = resp.text.strip() assert check_output(proxyless_text) interface.call('proxy', 'set', type=type, host=host, port=port) data = listener.pop().values()[0] debugtools.compare_dict(data, {'proxy.port': 1080, 'proxy.enabled': True, 'proxy.type': 'socks5', 'proxy.host': '127.0.0.1', 'action': 'update', 'table': 'config'}) resp = requests.get('http://checkip.dyndns.org/') proxy_text = resp.text.strip() assert check_output(proxy_text) assert proxy_text != proxyless_text interface.call('proxy', 'remove') data = listener.pop().values()[0] debugtools.compare_dict(data, {'proxy.port': None, 'proxy.enabled': None, 'proxy.type': None, 'proxy.host': None, 'action': 'update', 'table': 'config'}) resp = requests.get('http://checkip.dyndns.org/') proxyless_text2 = resp.text.strip() assert check_output(proxyless_text2) assert proxy_text != proxyless_text2 assert proxyless_text == proxyless_text2
def assert_download_complete(self): assert debugtools.compare_dict(self.file.serialize(), {'substate': [None], 'last_error': None, 'hash_type': None, 'chunks': 0, 'hash_value': None, 'size': 10485760, 'state': 'download_complete', 'name': '10mb.bin', 'enabled': True, 'working': False})