def test_gleb2_pch__unequal(self): gleb_2_pch = get_test_resource('Gleb2.pch2') expected_modules_correct = [Module(self.data, Location.VOICE_AREA, 4, 1), Module(self.data, Location.VOICE_AREA, 96, 2)] expected_modules = [Module(self.data, Location.VOICE_AREA, 4, 1), Module(self.data, Location.VOICE_AREA, 100, 2)] expected_cables = [ Cable(Location.VOICE_AREA, CableType.IN_TO_IN, CableColor.WHITE, 1, 0, 141, 1)] parsed = parse_pch2(self.data, gleb_2_pch, convert_in2in=False) self.assertTrue(parsed.modules == expected_modules_correct) self.assertFalse(parsed.modules == expected_modules) self.assertFalse(parsed.cables == expected_cables)
def test_reimport_track(db): updated = Track.query.one().updated filename = get_test_resource('json/97684385.json') with open(filename) as f: data = json.load(f) track = Track.from_rk_json(data) assert Track.query.count() == 1 assert track.updated > updated
def test_gleb2_pch(self): gleb_2_pch = get_test_resource('Gleb2.pch2') expected_modules = [Module(self.data, Location.VOICE_AREA, 4, 1), Module(self.data, Location.VOICE_AREA, 96, 2)] expected_cables = [Cable(Location.VOICE_AREA, CableType.IN_TO_IN, CableColor.WHITE, 1, 1, 1, 0)] expected_mod_params = [ModuleParameters(Location.VOICE_AREA, 1, 3, [0, 1, 0]), ModuleParameters(Location.VOICE_AREA, 2, 5, [127, 127, 0, 2, 0])] parsed = parse_pch2(self.data, gleb_2_pch, convert_in2in=False) self.assertSequenceEqual(parsed.modules, expected_modules) self.assertSequenceEqual(parsed.cables, expected_cables) self.assertSequenceEqual(parsed.mod_params, expected_mod_params)
def test_extra_func_length_spheroid(db): track = db.session.query(Track).get(1) filename = get_test_resource('json/97684385.json') with open(filename) as f: data = json.load(f) # FIXME: can we get the SPHEROID from the metadata? length = db.session.scalar(track.points.length_spheroid( 'SPHEROID["WGS 84",6378137,298.257223563]')) assert np.abs(data['total_distance'] - length) < 10 # within 10m
def setUp(self): self.data = ProjectData() self.poly_mix2 = parse_pch2(self.data, get_test_resource('test_poly_mix2.pch2')) self.udo_mix2_k = """opcode Mix21A_v0, 0, iiiiiiiii ; TODO: lin/log scale, chain input iLev1, iSw1, iLev2, iSw2, iScale, izIn1, izIn2, izInChain, izOut xin k1 zkr izIn1 k2 zkr izIn2 k3 zkr izInChain kout = k1 + k2*iLev1*iSW1 + k3*iLev2*iSW2 zkw kout, izOut endop """ self.udo_mix2_a = """opcode Mix21A_v1, 0, iiiiiiiii
def setUp(self): self.data = ProjectData() self.poly_mix2 = parse_pch2(self.data, get_test_resource('test_poly_mix2.pch2')) self.udo_mix2_k = """;@ args iiiii, kkk, k opcode Mix21A_v0, 0, iiiiiiiii ; MULTIMODE support a/k? ; TODO: lin/log scale, chain input iLev1, iSw1, iLev2, iSw2, iScale, izIn1, izIn2, izInChain, izOut xin k1 zkr izIn1 k2 zkr izIn2 k3 zkr izInChain aout = a1 + a2*kLev1*iSW1 + a3*kLev2*iSW2 zkw aout, izOut endop """ self.udo_mix2_a = """;@ args iiiii, aaa, a
def test_import_track(db): filename = get_test_resource('json/97684385.json') with open(filename) as f: data = json.load(f) # we need to insert this user_id into the database db.session.add(User(user_id=data['userID'])) db.session.commit() track = Track.from_rk_json(data) assert Track.query.count() == 1 npoints = db.session.scalar(track.points.num_points()) assert len(data['path']) == npoints # FIXME: how to determine the UTM zone automatically? length = db.session.scalar(track.points.transform(32755).length()) assert np.abs(data['total_distance'] - length) < 10 # within 10m
def test_in2in__all_cables_from_the_first_module(self): pch2 = get_test_resource('test_in2in.pch2') patch = parse_pch2(self.data, pch2) patch.cables = [transform_in2in_cables(patch, c) for c in patch.cables] for c in patch.cables: self.assertEqual(c.module_from, 1)
def setUp(self): self.data = ProjectData() self.poly_mix2_fn = get_test_resource('test_poly_mix2.pch2') self.modes_LfoC = get_test_resource('test_modes_LfoC.pch2') self.LevAmp = get_test_resource('test_LevAmp.pch2')
def setUp(self): self.data = ProjectData() self.r2b_b2r_fn = get_test_resource('test_convert_r2b_b2r.pch2')
def setUp(self): self.data = ProjectData() self.poly_mix2 = parse_pch2(self.data, get_test_resource('test_poly_mix2.pch2'))
def setUp(self): self.data = ProjectData() self.poly_mix2_fn = get_test_resource('test_poly_mix2.pch2')
def test_modes__LfoC(self): pch2 = get_test_resource('test_modes_LfoC.pch2') patch = parse_pch2(self.data, pch2) p_modes = [m.modes for m in patch.modules] self.assertSequenceEqual(p_modes, [[0], [1], [2], [3], [4], [5], [6], [7]])
def test_convert_pch2__not_raises(self): try: convert_pch2(get_test_resource('test_in2in.pch2')) except SystemExit: pass # allow program to exit while we haven't created all modules
def test_print_pch2__not_raises(self): for f in glob(get_test_resource('*.pch2')): print(f) print_pch2(f)