def test_boundary(self): """ Test behavior around 0.4.14.999 boundary """ self.assertEquals(utils_version.to_canonical('0.004014998'), '0.4.14-rc998') self.assertEquals(utils_version.to_canonical('0.004014999'), '0.4.14') self.assertEquals(utils_version.to_canonical('0.004015000'), '0.4.15.0') self.assertEquals(utils_version.to_canonical('0.004015999'), '0.4.15.999') self.assertEquals(utils_version.to_numeric('0.4.14-rc998'), '0.004014998') self.assertEquals(utils_version.to_numeric('0.4.14'), '0.004014999') self.assertEquals(utils_version.to_numeric('0.4.15.0'), '0.004015000') self.assertEquals(utils_version.to_numeric('0.4.15.999'), '0.004015999')
def test_double_conversion(self): """ Convert from canonical to numeric and then again to canonical (and viceversa) to make sure that we get what is expected. """ # canonical -> numeric -> canonical self.assertEquals( utils_version.to_canonical( utils_version.to_numeric("133.35.71.19")), "133.35.71.19") # Same as above but check for -rc999 (legacy check) self.assertEquals( utils_version.to_canonical( utils_version.to_numeric("0.3.71-rc999")), "0.3.71") # numeric -> canonical -> numeric self.assertEquals( utils_version.to_numeric( utils_version.to_canonical("133.035071019")), "133.035071019")
def test_double_conversion(self): """ Convert from canonical to numeric and then again to canonical (and viceversa) to make sure that we get what is expected. """ # canonical -> numeric -> canonical self.assertEquals(utils_version.to_canonical( utils_version.to_numeric("133.35.71.19")), "133.35.71.19") # Same as above but check for -rc999 (legacy check) self.assertEquals(utils_version.to_canonical( utils_version.to_numeric("0.3.71-rc999")), "0.3.71") # numeric -> canonical -> numeric self.assertEquals(utils_version.to_numeric( utils_version.to_canonical("133.035071019")), "133.035071019")
def peer_test_complete(self, stream, download_speed, rtt, target_bytes): self.success = True stream = self.http_stream # Update the downstream channel estimate estimate.DOWNLOAD = target_bytes self.my_side = { # The server will override our timestamp "timestamp": utils.timestamp(), "uuid": self.conf.get("uuid"), "internal_address": stream.myname[0], "real_address": self.conf.get("_real_address", ""), "remote_address": stream.peername[0], "privacy_informed": self.conf.get("privacy.informed", 0), "privacy_can_collect": self.conf.get("privacy.can_collect", 0), "privacy_can_publish": self.conf.get("privacy.can_publish", 0), # Upload speed measured at the server "connect_time": rtt, "download_speed": download_speed, # OS and version info "neubot_version": utils_version.to_numeric("0.4.12-rc2"), "platform": sys.platform, } logging.info("BitTorrent: collecting in progress...") STATE.update("collect") s = json.dumps(self.my_side) stringio = StringIO.StringIO(s) request = Message() request.compose( method="POST", pathquery="/collect/bittorrent", body=stringio, mimetype="application/json", host=self.host_header) request["authorization"] = self.conf.get("_authorization", "") stream.send_request(request)
def connection_ready(self, stream): m1 = SpeedtestCollect() m1.client = self.conf.get("uuid", "") m1.timestamp = utils.timestamp() m1.internalAddress = stream.myname[0] m1.realAddress = self.conf.get("speedtest.client.public_address", "") m1.remoteAddress = stream.peername[0] m1.latency = self.conf.get("speedtest.client.latency", 0.0) m1.downloadSpeed = self.conf.get("speedtest.client.download", 0.0) m1.uploadSpeed = self.conf.get("speedtest.client.upload", 0.0) m1.privacy_informed = self.conf.get("privacy.informed", 0) m1.privacy_can_collect = self.conf.get("privacy.can_collect", 0) m1.privacy_can_share = self.conf.get("privacy.can_publish", 0) # XXX m1.neubot_version = utils_version.to_numeric("0.4.12-rc2") m1.platform = sys.platform m1.connectTime = sum(self.rtts) / len(self.rtts) s = marshal.marshal_object(m1, "text/xml") stringio = StringIO.StringIO(s) # # Pass a dictionary because the function does not accept # anymore an object # if privacy.collect_allowed(m1.__dict__): insertxxx(DATABASE.connection(), m1) request = Message() request.compose(method="POST", pathquery="/speedtest/collect", body=stringio, mimetype="application/xml", host=self.host_header) request["authorization"] = self.conf.get( "speedtest.client.authorization", "") stream.send_request(request)