Fussy is about to be deprecated as Factory Boy documentation says.
Now that FactoryBoy includes the factory.Faker class, most of these built-in fuzzers are deprecated in favor of their Faker equivalents.
As @Steven B said, you must create your own provider. I did some changes to his code in order to make the provider as generic as possible.
class DjangoGeoPointProvider(BaseProvider): def geo_point(self, **kwargs): kwargs['coords_only'] = True faker = factory.Faker('local_latlng', **kwargs) coords = faker.generate() return Point(x=float(coords[1]), y=float(coords[0]), srid=4326)
Note: coords_only
must be always true because we just need lat
and long
values, without any extra metadata.
Finally, it is like using the local_latlng
provider or any of the built-in providers. Here is a full example:
class TargetFactory(factory.django.DjangoModelFactory): factory.Faker.add_provider(DjangoGeoPointProvider) class Meta: model = Target radius = factory.Faker('random_int', min=4500, max=90000) location = factory.Faker('geo_point', country_code='US')
Note: 'US' is the default country code, it could be omitted in this example, but you could use any of the other specified countries code in Faker doc.