当前位置: 首页>>代码示例>>Python>>正文


Python Node.first方法代码示例

本文整理汇总了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)
开发者ID:PabloCastellano,项目名称:nodeshot,代码行数:34,代码来源:tests.py

示例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)
开发者ID:un33k,项目名称:nodeshot,代码行数:60,代码来源:tests.py

示例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)
开发者ID:devalexfrig,项目名称:nodeshot,代码行数:55,代码来源:tests.py

示例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())
开发者ID:un33k,项目名称:nodeshot,代码行数:40,代码来源:tests.py

示例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)
开发者ID:PabloCastellano,项目名称:nodeshot,代码行数:63,代码来源:tests.py


注:本文中的nodeshot.core.nodes.models.Node.first方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。