當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。