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


Python VentureRole.networks方法代码示例

本文整理汇总了Python中ralph.business.models.VentureRole.networks方法的典型用法代码示例。如果您正苦于以下问题:Python VentureRole.networks方法的具体用法?Python VentureRole.networks怎么用?Python VentureRole.networks使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ralph.business.models.VentureRole的用法示例。


在下文中一共展示了VentureRole.networks方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_check_ip

# 需要导入模块: from ralph.business.models import VentureRole [as 别名]
# 或者: from ralph.business.models.VentureRole import networks [as 别名]
    def test_check_ip(self):
        terminator = NetworkTerminator(name='Test Terminator')
        terminator.save()

        data_center = DataCenter(name='Test date_center')
        data_center.save()

        network = Network(address='192.168.1.0/24',name='Test network',
                          data_center=data_center)
        network.save()
        network.terminators = [terminator]
        network.save()

        subnetwork = Network(address='192.168.2.0/24',name='Test subnetwork',
                          data_center=data_center)
        subnetwork.save()
        subnetwork.terminators = [terminator]
        subnetwork.save()

        main_venture = Venture(name='Main Venture')
        main_venture.save()
        main_venture.networks = [network, subnetwork]
        main_venture.save()

        second_network = Network(address='172.16.0.0/28',name='Test secound_network',
                          data_center=data_center)
        second_network.save()
        second_network.terminators = [terminator]
        second_network.save()

        child_venture = Venture(name='Child Venture', parent=main_venture)
        child_venture.save()
        child_venture.networks = [second_network]
        child_venture.save()

        third_network = Network(address='66.6.6.0/29',name='Test third_network',
                          data_center=data_center)
        third_network.save()
        third_network.terminators = [terminator]
        third_network.save()

        third_subnetwork = Network(address='66.6.7.0/29',name='Test third_subnetwork',
                          data_center=data_center)
        third_subnetwork.save()
        third_subnetwork.terminators = [terminator]
        third_subnetwork.save()

        venture_role_main = VentureRole(name='Main Venture role',
                                        venture=child_venture)
        venture_role_main.save()
        venture_role_main.networks = [third_network, third_subnetwork]
        venture_role_main.save()

        fourth_network = Network(address='111.11.11.0/27',name='Test fourth_network',
                          data_center=data_center)
        fourth_network.save()
        fourth_network.terminators = [terminator]
        fourth_network.save()

        venture_role_child = VentureRole(name='Child Venture role',
                                         venture=child_venture,
                                         parent=venture_role_main)
        venture_role_child.save()
        venture_role_child.networks = [fourth_network]
        venture_role_child.save()

        self.assertEqual(venture_role_child.check_ip("192.168.1.15"), True)
        self.assertEqual(venture_role_child.check_ip("192.168.2.15"), True)
        self.assertEqual(venture_role_child.check_ip("192.168.3.15"), False)

        self.assertEqual(venture_role_child.check_ip("172.16.0.10"), True)
        self.assertEqual(venture_role_child.check_ip("172.16.0.22"), False)

        self.assertEqual(venture_role_child.check_ip("66.6.6.5"), True)
        self.assertEqual(venture_role_child.check_ip("66.6.7.5"), True)
        self.assertEqual(venture_role_child.check_ip("66.6.8.10"), False)

        self.assertEqual(venture_role_child.check_ip("111.11.11.1"), True)
        self.assertEqual(venture_role_child.check_ip("111.11.11.44"), False)
开发者ID:iwwwwwwi,项目名称:ralph,代码行数:81,代码来源:tests.py


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