def test_add_bad_pool_size(self, m_IPPool):
        """
        Test ip_pool_add exits when pool with bad prefix is passed in.
        """
        m_IPPool.side_effect = InvalidBlockSizeError
        with patch('sys.exit', autospec=True) as m_sys_exit:
            # Call method under test
            pool.ip_pool_add(["10.10.10.10/32"], 4, False, False)

            # Call method under test for each test case
            self.assertTrue(m_sys_exit.called)
Esempio n. 2
0
    def test_add_overlapping_existing_pool(self, m_client):
        """
        Test ip_pool_add exits when a pool is added that falls within an
        existing pool.
        """
        m_client.get_ip_pools.return_value = [IPPool("10.10.10.0/24")]
        with patch("sys.exit", autospec=True) as m_sys_exit:
            # Call method under test
            pool.ip_pool_add(cidrs=["10.10.10.0/25"], version=4, ipip=False, masquerade=False)

            self.assertTrue(m_sys_exit.called)
Esempio n. 3
0
    def test_add_overlapping_new_pools(self, m_client):
        """
        Test ip_pool_add exits when two new pools overlap with
        each other.
        """
        m_client.get_ip_pools.return_value = []
        with patch("sys.exit", autospec=True) as m_sys_exit:
            # Call method under test
            pool.ip_pool_add(cidrs=["10.10.10.0/25", "10.10.10.0/26"], version=4, ipip=False, masquerade=False)

            self.assertTrue(m_sys_exit.called)
Esempio n. 4
0
    def test_add_bad_pool_size(self, m_IPPool):
        """
        Test ip_pool_add exits when pool with bad prefix is passed in.
        """
        m_IPPool.side_effect = CidrTooSmallError
        with patch('sys.exit', autospec=True) as m_sys_exit:
            # Call method under test
            pool.ip_pool_add(["10.10.10.10/32"], 4, False, False)

            # Call method under test for each test case
            self.assertTrue(m_sys_exit.called)
Esempio n. 5
0
    def test_add_overlapping_new_pools(self, m_client):
        """
        Test ip_pool_add exits when two new pools overlap with
        each other.
        """
        m_client.get_ip_pools.return_value = []
        with patch('sys.exit', autospec=True) as m_sys_exit:
            # Call method under test
            pool.ip_pool_add(cidrs=["10.10.10.0/25", "10.10.10.0/26"],
                             version=4, ipip=False, masquerade=False)

            self.assertTrue(m_sys_exit.called)
Esempio n. 6
0
    def test_add_overlapping_existing_pool_2(self, m_client):
        """
        Test ip_pool_add exits when a pool is added that fully encompasses an
        existing pool.
        """
        m_client.get_ip_pools.return_value = [IPPool("10.10.10.0/26")]
        with patch('sys.exit', autospec=True) as m_sys_exit:
            # Call method under test
            pool.ip_pool_add(cidrs=["10.10.10.0/24"], version=4,
                             ipip=False, masquerade=False)

            self.assertTrue(m_sys_exit.called)