Exemplo n.º 1
0
# Unless required by applicable law or agreed to in writing, software          #
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT    #
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the     #
# LICENSE file distributed with this work for specific language governing      #
# permissions and limitations under the License.                               #
################################################################################
# /updates/vlan_test.py                                                        #
# Tests for vlan.py, which assigns vlan tags to slices                         #
################################################################################

import examples.amaz as az
import vlan
import unittest
import util

topo, slices = az.get_slices()

def qualified_edge(topology, (s1, s2)):
    """Convert (s1, s2) edge into ((s1, p1), (s2, p2))."""
    p1 = topology.node[s1]['ports'][s2]
    p2 = topology.node[s2]['ports'][s1]
    return ((s1, p1), (s2, p2))

class TestVlanAssignment(unittest.TestCase):
    def test_basic(self):
        slices = range(0,10)
        assigned = vlan.sequential(slices)
        # Verify via pigeonhole principle - if there are as many slices as
        # vlans, no vlan is used with two slices
        self.assertEqual(len(slices), len(set(assigned.keys())))
Exemplo n.º 2
0
 def test_examples(self):
     # Maintains examples
     self.assertEquals(3, len(mil.get_slices()))
     self.assertEquals(3, len(amaz.get_slices()[1]))
     self.assertEquals(1, len(simple.get_slices()))
     self.assertEquals(3, len(day.get_slices()))