def test_get_netinfo_from_report(self): path = self._get_report_file() report = radiomobile.parse_report(path) info = netinfo.get_netinfo_from_report(report) self.assert_(info["units"]) self.assert_(info["networks"]) self.assertEqual(sorted(info["units"].keys()), ['Ccatcca', 'Huiracochan', 'Josjojauarina 1', 'Josjojauarina 2', 'Kcauri', 'Urcos', 'Urpay']) urcos = info["units"]["Urcos"] self.assertEqual(urcos["elevation"], 274) self.assertEqual(urcos["location"], [2533, -19694]) self.assertEqual(sorted(info["networks"].keys()), ['Huiracochan', 'Josjo1', 'Josjo1-Josjo2', 'Josjo2']) josjo1 = info["networks"]["Josjo1"] self.assertEqual(josjo1["mode"], {'standard': 'wifi', 'wifi_mode': 'wifia-6mbs'}) self.assertEqual(josjo1["node"], {'name': 'Josjojauarina 1', 'system': 'wifi1'}) self.assertEqual(josjo1["terminals"][0], {'name': 'Urpay', 'system': 'wifi1'}) self.assertEqual(josjo1["terminals"][1], {'name': 'Huiracochan', 'system': 'wifi1'}) josjo2 = info["networks"]["Josjo2"] self.assertEqual(josjo2["mode"], {'standard': 'wimax', 'wimax_scheduler': 'rtps'}) self.assertEqual(josjo2["node"], {'name': 'Josjojauarina 2', 'system': 'wimax1', 'wimax_mode': 'all'}) self.assertEqual(josjo2["terminals"][0], {'name': 'Ccatcca', 'system': 'wimax2', 'wimax_mode': 'QAM64_34'}) self.assertEqual(josjo2["terminals"][1], {'name': 'Kcauri', 'system': 'wimax2', 'wimax_mode': 'QAM64_34'})
def create_network_from_report_file(filename): """Create a network Struct from a RadioMobile text-report filename.""" report = radiomobile.parse_report(filename) netinfo = wwplan.netinfo.get_netinfo_from_report(report) logging.debug("Netinfo YML contents:") for line in yaml.dump(netinfo).splitlines(): logging.debug("Netinfo: %s" % line.rstrip()) return create_network(netinfo)
def test_get_netinfo_from_report(self): path = self._get_report_file() report = radiomobile.parse_report(path) info = netinfo.get_netinfo_from_report(report) self.assert_(info["units"]) self.assert_(info["networks"]) self.assertEqual(sorted(info["units"].keys()), [ 'Ccatcca', 'Huiracochan', 'Josjojauarina 1', 'Josjojauarina 2', 'Kcauri', 'Urcos', 'Urpay' ]) urcos = info["units"]["Urcos"] self.assertEqual(urcos["elevation"], 274) self.assertEqual(urcos["location"], [2533, -19694]) self.assertEqual(sorted(info["networks"].keys()), ['Huiracochan', 'Josjo1', 'Josjo1-Josjo2', 'Josjo2']) josjo1 = info["networks"]["Josjo1"] self.assertEqual(josjo1["mode"], { 'standard': 'wifi', 'wifi_mode': 'wifia-6mbs' }) self.assertEqual(josjo1["node"], { 'name': 'Josjojauarina 1', 'system': 'wifi1' }) self.assertEqual(josjo1["terminals"][0], { 'name': 'Urpay', 'system': 'wifi1' }) self.assertEqual(josjo1["terminals"][1], { 'name': 'Huiracochan', 'system': 'wifi1' }) josjo2 = info["networks"]["Josjo2"] self.assertEqual(josjo2["mode"], { 'standard': 'wimax', 'wimax_scheduler': 'rtps' }) self.assertEqual(josjo2["node"], { 'name': 'Josjojauarina 2', 'system': 'wimax1', 'wimax_mode': 'all' }) self.assertEqual(josjo2["terminals"][0], { 'name': 'Ccatcca', 'system': 'wimax2', 'wimax_mode': 'QAM64_34' }) self.assertEqual(josjo2["terminals"][1], { 'name': 'Kcauri', 'system': 'wimax2', 'wimax_mode': 'QAM64_34' })
def main(args, stream=sys.stdout): import optparse usage = """Usage: %prog [OPTIONS] RADIOMOBILE_REPORT Parse a Radio Mobile report and write the netinfo YML to stdout.""" parser = optparse.OptionParser(usage) options, args0 = parser.parse_args(args) if len(args0) != 1: parser.print_help() return 2 report_filename, = args0 report = radiomobile.parse_report(report_filename) netinfo = get_netinfo_from_report(report) stream.write(yaml.dump(netinfo))
def setUp(self): filename = "josjo.report.txt" path = os.path.join(os.path.dirname(__file__), filename) self.report = radiomobile.parse_report(path)