def test_no_expansion(self): desc = { 'src': 'grp1', 'dst': 'grp2', 'delay': 0, 'rate': 0, 'symetric': True } descs = _expand_description(desc) self.assertEqual(1, len(descs)) self.assertDictEqual(desc, descs[0])
def test_dst_expansion(self): desc = { 'src': 'grp4', 'dst': 'grp[1-3]', 'delay': 0, 'rate': 0, 'symetric': True } # checking cardinality : the cartesian product descs = _expand_description(desc) self.assertEqual(3, len(descs)) # checking that expansion has been generated dsts = map(lambda d: d.pop('dst'), descs) self.assertEqual(set(dsts), {'grp1', 'grp2', 'grp3'}) # checking that the remaining is untouched desc.pop('dst') for d in descs: self.assertDictEqual(desc, d)