Esempio n. 1
0
    def test_do_validation_disabled_success(self):
        ztpserver.config.runtime.set_value(\
            'disable_topology_validation', True, 'default')

        controller = ztpserver.controller.NodesController()
        (resp, state) = controller.do_validation(dict(),
                                                 resource=random_string())

        self.assertEqual(state, 'get_startup_config')
        self.assertIsInstance(resp, dict)
Esempio n. 2
0
    def test_do_validation_disabled_success(self):
        ztpserver.config.runtime.set_value(\
            'disable_topology_validation', True, 'default')

        controller = ztpserver.controller.NodesController()
        (resp, state) = controller.do_validation(dict(),
                                                 resource=random_string())

        self.assertEqual(state, 'get_startup_config')
        self.assertIsInstance(resp, dict)
Esempio n. 3
0
    def test_do_validation_success(self, m_load_pattern):

        cfg = {'return_value.match_node.return_value': True}
        m_load_pattern.configure_mock(**cfg)

        controller = ztpserver.controller.NodesController()
        (resp, state) = controller.do_validation(dict(),
                                                 resource=random_string(),
                                                 node=Mock())

        self.assertEqual(state, 'get_startup_config')
        self.assertIsInstance(resp, dict)
Esempio n. 4
0
    def test_do_validation_success(self, m_load_pattern):

        cfg = {'return_value.match_node.return_value': True}
        m_load_pattern.configure_mock(**cfg)

        controller = ztpserver.controller.NodesController()
        (resp, state) = controller.do_validation(dict(),
                                                 resource=random_string(),
                                                 node=Mock())

        self.assertEqual(state, 'get_startup_config')
        self.assertIsInstance(resp, dict)
    def test_do_validation_success(self):
        node = create_node()

        filestore = Mock()
        ztpserver.controller.create_file_store = filestore

        ztpserver.neighbordb.load_pattern = Mock()
        cfg = {'return_value.match_node.return_value': True}
        ztpserver.neighbordb.load_pattern.configure_mock(**cfg)

        controller = ztpserver.controller.NodesController()
        (resp, state) = controller.do_validation(dict(),
                                                 resource=node.systemmac,
                                                 node=Mock())

        filepath = '%s/%s' % (node.systemmac, ztpserver.controller.PATTERN_FN)
        filestore.return_value.get_file.assert_called_with(filepath)
        self.assertEqual(state, 'get_startup_config')
        self.assertIsInstance(resp, dict)
        self.assertEqual(resp, dict())