本文整理汇总了Python中nodeshot.core.nodes.models.Node.first方法的典型用法代码示例。如果您正苦于以下问题:Python Node.first方法的具体用法?Python Node.first怎么用?Python Node.first使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nodeshot.core.nodes.models.Node
的用法示例。
在下文中一共展示了Node.first方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_preexisting_name
# 需要导入模块: from nodeshot.core.nodes.models import Node [as 别名]
# 或者: from nodeshot.core.nodes.models.Node import first [as 别名]
def test_preexisting_name(self):
""" test preexisting names """
layer = Layer.objects.external()[0]
layer.new_nodes_allowed = False
layer.save()
layer = Layer.objects.get(pk=layer.pk)
node = Node.first()
self.assertNotEqual(layer.id, node.layer.id)
node.name = 'simplejson'
node.save()
url = '%s/geojson1.json' % TEST_FILES_PATH
external = LayerExternal(layer=layer)
external.synchronizer_path = 'nodeshot.interop.sync.synchronizers.GeoJson'
external._reload_schema()
external.config = {"url": url}
external.full_clean()
external.save()
output = capture_output(
management.call_command,
['sync', 'vienna'],
kwargs={'verbosity': 0}
)
# ensure following text is in output
self.assertIn('2 nodes added', output)
self.assertIn('0 nodes changed', output)
self.assertIn('2 total external', output)
self.assertIn('2 total local', output)
示例2: test_key_mappings
# 需要导入模块: from nodeshot.core.nodes.models import Node [as 别名]
# 或者: from nodeshot.core.nodes.models.Node import first [as 别名]
def test_key_mappings(self):
""" importing a file with different keys """
layer = Layer.objects.external()[0]
layer.minimum_distance = 0
layer.area = None
layer.new_nodes_allowed = False
layer.save()
layer = Layer.objects.get(pk=layer.pk)
node = Node.first()
self.assertNotEqual(layer.id, node.layer.id)
node.name = 'simplejson'
node.save()
url = '%snodeshot/testing/geojson3.json' % settings.STATIC_URL
external = LayerExternal(layer=layer)
external.interoperability = 'nodeshot.interoperability.synchronizers.GeoJson'
external.config = json.dumps({
"url": url,
"map": {
"name": "nome",
"description": "descrizione",
"address": "indirizzo",
"elevation": "altitudine"
}
})
external.full_clean()
external.save()
# start capturing print statements
output = StringIO()
sys.stdout = output
# execute command
management.call_command('synchronize', 'vienna', verbosity=0)
# stop capturing print statements
sys.stdout = sys.__stdout__
# ensure following text is in output
self.assertIn('2 nodes added', output.getvalue())
self.assertIn('0 nodes changed', output.getvalue())
self.assertIn('2 total external', output.getvalue())
self.assertIn('2 total local', output.getvalue())
node = Node.objects.get(slug='verycool')
self.assertEqual(node.name, 'veryCool')
self.assertEqual(node.address, 'veryCool indirizzo')
self.assertEqual(node.description, 'veryCool descrizione')
self.assertEqual(node.elev, 10.0)
node = Node.objects.get(slug='secondo')
self.assertEqual(node.name, 'secondo')
self.assertEqual(node.address, 'secondo indirizzo')
self.assertEqual(node.description, 'secondo descrizione')
self.assertEqual(node.elev, 20.0)
示例3: test_key_mappings
# 需要导入模块: from nodeshot.core.nodes.models import Node [as 别名]
# 或者: from nodeshot.core.nodes.models.Node import first [as 别名]
def test_key_mappings(self):
""" importing a file with different keys """
layer = Layer.objects.external()[0]
layer.minimum_distance = 0
layer.area = None
layer.new_nodes_allowed = False
layer.save()
layer = Layer.objects.get(pk=layer.pk)
node = Node.first()
self.assertNotEqual(layer.id, node.layer.id)
node.name = 'simplejson'
node.save()
url = '%s/geojson3.json' % TEST_FILES_PATH
external = LayerExternal(layer=layer)
external.interoperability = 'nodeshot.interoperability.synchronizers.GeoJson'
external.config = json.dumps({
"url": url,
"map": {
"name": "nome",
"description": "descrizione",
"address": "indirizzo",
"elevation": "altitudine"
}
})
external.full_clean()
external.save()
output = capture_output(
management.call_command,
['synchronize', 'vienna'],
kwargs={ 'verbosity': 0 }
)
# ensure following text is in output
self.assertIn('2 nodes added', output)
self.assertIn('0 nodes changed', output)
self.assertIn('2 total external', output)
self.assertIn('2 total local', output)
node = Node.objects.get(slug='verycool')
self.assertEqual(node.name, 'veryCool')
self.assertEqual(node.address, 'veryCool indirizzo')
self.assertEqual(node.description, 'veryCool descrizione')
self.assertEqual(node.elev, 10.0)
node = Node.objects.get(slug='secondo')
self.assertEqual(node.name, 'secondo')
self.assertEqual(node.address, 'secondo indirizzo')
self.assertEqual(node.description, 'secondo descrizione')
self.assertEqual(node.elev, 20.0)
示例4: test_preexisting_name
# 需要导入模块: from nodeshot.core.nodes.models import Node [as 别名]
# 或者: from nodeshot.core.nodes.models.Node import first [as 别名]
def test_preexisting_name(self):
""" test preexisting names """
layer = Layer.objects.external()[0]
layer.minimum_distance = 0
layer.area = None
layer.new_nodes_allowed = False
layer.save()
layer = Layer.objects.get(pk=layer.pk)
node = Node.first()
self.assertNotEqual(layer.id, node.layer.id)
node.name = 'simplejson'
node.save()
url = '%snodeshot/testing/geojson1.json' % settings.STATIC_URL
external = LayerExternal(layer=layer)
external.interoperability = 'nodeshot.interoperability.synchronizers.GeoJson'
external.config = '{ "url": "%s", "map": {} }' % url
external.full_clean()
external.save()
# start capturing print statements
output = StringIO()
sys.stdout = output
# execute command
management.call_command('synchronize', 'vienna', verbosity=0)
# stop capturing print statements
sys.stdout = sys.__stdout__
# ensure following text is in output
self.assertIn('2 nodes added', output.getvalue())
self.assertIn('0 nodes changed', output.getvalue())
self.assertIn('2 total external', output.getvalue())
self.assertIn('2 total local', output.getvalue())
示例5: test_key_mappings
# 需要导入模块: from nodeshot.core.nodes.models import Node [as 别名]
# 或者: from nodeshot.core.nodes.models.Node import first [as 别名]
def test_key_mappings(self):
""" importing a file with different keys """
layer = Layer.objects.external()[0]
layer.new_nodes_allowed = False
layer.save()
layer = Layer.objects.get(pk=layer.pk)
node = Node.first()
self.assertNotEqual(layer.id, node.layer.id)
node.name = 'simplejson'
node.save()
url = '%s/geojson3.json' % TEST_FILES_PATH
external = LayerExternal(layer=layer)
external.synchronizer_path = 'nodeshot.interop.sync.synchronizers.GeoJson'
external._reload_schema()
external.url = url
external.field_name = "nome"
external.field_description = "descrizione"
external.field_address = "indirizzo"
external.field_elev = "altitudine"
external.full_clean()
external.save()
output = capture_output(
management.call_command,
['sync', 'vienna'],
kwargs={'verbosity': 0}
)
# ensure following text is in output
self.assertIn('2 nodes added', output)
self.assertIn('0 nodes changed', output)
self.assertIn('2 total external', output)
self.assertIn('2 total local', output)
node = Node.objects.get(slug='verycool')
self.assertEqual(node.name, 'veryCool')
self.assertEqual(node.address, 'veryCool indirizzo')
self.assertEqual(node.description, 'veryCool descrizione')
self.assertEqual(node.elev, 10.0)
node = Node.objects.get(slug='secondo')
self.assertEqual(node.name, 'secondo')
self.assertEqual(node.address, 'secondo indirizzo')
self.assertEqual(node.description, 'secondo descrizione')
self.assertEqual(node.elev, 20.0)
output = capture_output(
management.call_command,
['sync', 'vienna'],
kwargs={'verbosity': 0}
)
# no changes
self.assertIn('0 nodes added', output)
self.assertIn('0 nodes changed', output)
self.assertIn('0 nodes deleted', output)
self.assertIn('2 nodes unmodified', output)
self.assertIn('2 total external', output)
self.assertIn('2 total local', output)