Esempio n. 1
0
    def test_import(self):
        data = "10.0.1.0/24:lan:uninett:here-there:employee:Employee LAN:20"
        parser = bulkparse.PrefixBulkParser(data)
        importer = bulkimport.PrefixImporter(parser)
        _line_num, objects = six.next(importer)

        if isinstance(objects, Exception):
            raise objects
        self.assertEqual(len(objects), 2)
        self.assertTrue(isinstance(objects[0], manage.Vlan))
        self.assertTrue(isinstance(objects[1], manage.Prefix))
Esempio n. 2
0
 def test_valid_prefix_should_not_raise_error(self):
     data = b"10.0.0.0/8:scope"
     b = bulkparse.PrefixBulkParser(data)
     assert (six.next(b))
Esempio n. 3
0
 def test_invalid_prefix_should_raise_error(self):
     data = b"10.0.0.x/3f:scope"
     b = bulkparse.PrefixBulkParser(data)
     with pytest.raises(bulkparse.InvalidFieldValue):
         six.next(b)
Esempio n. 4
0
 def test_invalid_prefix_should_raise_error(self):
     data = b"10.0.0.x/3f:scope"
     b = bulkparse.PrefixBulkParser(data)
     self.assertRaises(bulkparse.InvalidFieldValue, lambda: six.next(b))