本文整理汇总了Python中spatial.tests.factories.SpatialUnitFactory.build方法的典型用法代码示例。如果您正苦于以下问题:Python SpatialUnitFactory.build方法的具体用法?Python SpatialUnitFactory.build怎么用?Python SpatialUnitFactory.build使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类spatial.tests.factories.SpatialUnitFactory
的用法示例。
在下文中一共展示了SpatialUnitFactory.build方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_repr
# 需要导入模块: from spatial.tests.factories import SpatialUnitFactory [as 别名]
# 或者: from spatial.tests.factories.SpatialUnitFactory import build [as 别名]
def test_repr(self):
project = ProjectFactory.build(slug='prj')
su1 = SpatialUnitFactory.build(type='PA', id='abc123', project=project)
su2 = SpatialUnitFactory.build(type='PA', id='def456', project=project)
relationship = SpatialRelationshipFactory.build(
id='abc123',
project=project,
su1=su1,
su2=su2,
type='C')
assert repr(relationship) == ('<SpatialRelationship id=abc123'
' project=prj su1=abc123 su2=def456'
' type=C>')
示例2: test_serialize
# 需要导入模块: from spatial.tests.factories import SpatialUnitFactory [as 别名]
# 或者: from spatial.tests.factories.SpatialUnitFactory import build [as 别名]
def test_serialize(self):
location = SpatialUnitFactory.build(id='abc123')
serializer = serializers.SpatialUnitGeoJsonSerializer(location)
assert 'type' in serializer.data['properties']
assert 'url' in serializer.data['properties']
assert 'geometry' in serializer.data
示例3: test_get_url
# 需要导入模块: from spatial.tests.factories import SpatialUnitFactory [as 别名]
# 或者: from spatial.tests.factories.SpatialUnitFactory import build [as 别名]
def test_get_url(self):
location = SpatialUnitFactory.build(id='abc123')
serializer = serializers.SpatialUnitGeoJsonSerializer(location)
expected_url = ('/organizations/{o}/projects/{p}/records/'
'locations/{l}/'.format(
o=location.project.organization.slug,
p=location.project.slug,
l=location.id
))
assert serializer.get_url(location) == expected_url
示例4: test_repr
# 需要导入模块: from spatial.tests.factories import SpatialUnitFactory [as 别名]
# 或者: from spatial.tests.factories.SpatialUnitFactory import build [as 别名]
def test_repr(self):
project = ProjectFactory.build(slug='prj')
party = PartyFactory.build(id='abc123', project=project)
su = SpatialUnitFactory.build(id='def456', project=project)
relationship = TenureRelationshipFactory.build(
id='abc123',
project=project,
party=party,
spatial_unit=su,
tenure_type=TenureRelationshipType(id='CR'))
assert repr(relationship) == ('<TenureRelationship id=abc123'
' party=abc123 spatial_unit=def456'
' project=prj tenure_type=CR>')
示例5: test_get_type
# 需要导入模块: from spatial.tests.factories import SpatialUnitFactory [as 别名]
# 或者: from spatial.tests.factories.SpatialUnitFactory import build [as 别名]
def test_get_type(self):
location = SpatialUnitFactory.build(type='CB')
serializer = serializers.SpatialUnitGeoJsonSerializer(location)
assert serializer.get_type(location) == 'Community boundary'