def test_fromfile(self): "Testing the fromfile() factory." ref_pnt = GEOSGeometry('POINT(5 23)') wkt_f = BytesIO() wkt_f.write(force_bytes(ref_pnt.wkt)) wkb_f = BytesIO() wkb_f.write(bytes(ref_pnt.wkb)) # Other tests use `fromfile()` on string filenames so those # aren't tested here. for fh in (wkt_f, wkb_f): fh.seek(0) pnt = fromfile(fh) self.assertEqual(ref_pnt, pnt)
def test_fromfile(self): "Testing the fromfile() factory." ref_pnt = GEOSGeometry("POINT(5 23)") wkt_f = BytesIO() wkt_f.write(force_bytes(ref_pnt.wkt)) wkb_f = BytesIO() wkb_f.write(bytes(ref_pnt.wkb)) # Other tests use `fromfile()` on string filenames so those # aren't tested here. for fh in (wkt_f, wkb_f): fh.seek(0) pnt = fromfile(fh) self.assertEqual(ref_pnt, pnt)
class RouteFactory(DjangoModelFactory): class Meta: model = Route activity_type = SubFactory(ActivityTypeFactory) name = Faker("text", max_nb_chars=100) source_id = Sequence(lambda n: 1000 + n) data_source = "homebytwo" description = Faker("bs") athlete = SubFactory(AthleteFactory) garmin_id = None total_elevation_gain = Faker("random_int", min=0, max=5000) total_elevation_loss = Faker("random_int", min=0, max=5000) total_distance = Faker("random_int", min=1, max=5000) geom = fromfile(get_data_file_path("route.ewkb").as_posix()) start_place = SubFactory(PlaceFactory, geom=Point(geom.coords[0], srid=geom.srid)) end_place = SubFactory(PlaceFactory, geom=Point(geom.coords[-1], srid=geom.srid)) data = read_json(load_data("route_data.json"), orient="records")
def get_geos_geometry(self): _file = self.get_file_path() return fromfile(open(_file))