def test_zonemap(): zones_at_k_value = {1: ["Zone1", "Zone2"], 3: ["Zone3"]} zone_map = ZoneMap(zones_at_k_value) assert zone_map.has_relationship("Zone1", 1) assert zone_map.has_relationship("Zone2", 1) assert not zone_map.has_relationship("Zone1", 3) assert zone_map.has_relationship("Zone3", 3)
def test_validate_non_existing_zone(): zones_at_k_value = {1: ["Zone1", "Zone2"], 3: ["Zone3"]} zone_map = ZoneMap(zones_at_k_value) point = TrajectoryPoint(0, 1, 2, 3, "non existing") point.set_ijk((0, 0, 1)) point.validate_zone(zone_map) assert not point.valid_zone
def test_invalid_load(initdir): errors = [ "k values cannot be 0, must start at 1", "k must be integer, was zone1", "Number of zonenames must be 1 or more", "ZoneMap file non_existing not found", ] fnames = [ "invalid_starts_at_0.txt", "invalid_format_string_first.txt", "invalid_format_missing_zone.txt", "non_existing", ] for fname, error in zip(fnames, errors): with pytest.raises(argparse.ArgumentTypeError) as msgcontext: ZoneMap.load_and_parse_zonemap_file(fname) assert error in msgcontext.value.args[0]
def test_validate_zone(k_value, expected_validation): zones_at_k_value = {1: ["Zone1", "Zone2"], 3: ["Zone3"]} zone_map = ZoneMap(zones_at_k_value) point = TrajectoryPoint(0, 1, 2, 3, "Zone1") point.set_ijk([0, 0, k_value]) assert not point.valid_zone point.validate_zone(zone_map) assert point.valid_zone == expected_validation
def test_load_data(initdir): for fname in [ "valid_zonemap.txt", "valid_zonemap_with_comments.txt", "valid_weird_zonemap.txt", ]: zone_map = ZoneMap.load_and_parse_zonemap_file(fname) assert zone_map.has_relationship("zone1", 0) assert zone_map.has_relationship("zone3", 0) assert zone_map.has_relationship("zone2", 2) assert zone_map.has_relationship("zone2", 1) assert not zone_map.has_relationship("zone1", 1) assert not zone_map.has_relationship("zone1", 2)