Esempio n. 1
0
 def test_snap(self, mock_parse):
     argparse.ArgumentParser.parse_args = MagicMock()
     argparse.ArgumentParser.parse_args.return_value = argparse.Namespace()
     js = SnapAdmin()
     conf_file = os.path.join(os.path.dirname(__file__), 'configs',
                              'main.yml')
     config_file = open(conf_file, 'r')
     js.main_file = yaml.load(config_file)
     js.generate_rpc_reply(None, "snap_mock", "10.216.193.114",
                           js.main_file)
     self.assertTrue(mock_parse.called)
Esempio n. 2
0
 def test_generate_rpc_reply_correct_data(self, mock_parse, mock_path):
     # Testcase to check if proper config_data is passed to generate_rpc_reply
     # it should not give an error in that function
     argparse.ArgumentParser.parse_args = MagicMock()
     argparse.ArgumentParser.parse_args.return_value = argparse.Namespace()
     js = SnapAdmin()
     conf_file = os.path.join(os.path.dirname(__file__),
                              'configs', 'main.yml')
     config_file = open(conf_file, 'r')
     js.main_file = yaml.load(config_file, Loader=yaml.FullLoader)
     mock_path.return_value = os.path.join(os.path.dirname(__file__), 'configs')
     js.test_cases = None
     js.generate_rpc_reply(
         None,
         "snap_mock",
         "1.1.1.1",
         js.main_file)
     self.assertTrue(mock_parse.called)
Esempio n. 3
0
 def test_generate_rpc_reply_testcase_extracted_data(self, mock_parse, mock_extract, mock_path):
     # Testcase to check if proper config_data is passed to generate_rpc_reply
     # testcases is already extracted so it should not be called.
     # it should not give an error in that function
     argparse.ArgumentParser.parse_args = MagicMock()
     argparse.ArgumentParser.parse_args.return_value = argparse.Namespace()
     js = SnapAdmin()
     conf_file = os.path.join(os.path.dirname(__file__),
                              'configs', 'main.yml')
     config_file = open(conf_file, 'r')
     js.main_file = yaml.load(config_file, Loader=yaml.FullLoader)
     mock_path.return_value = os.path.join(os.path.dirname(__file__), 'configs')
     js.test_cases = [{'tests_include': ['check_chassis_fpc'], 'check_chassis_fpc':
         [{'command': 'show chassis fpc'}, {'item': {'xpath': '//fpc', 'id': 'slot',
                                                     'tests': [{'delta': 'memory-heap-utilization, 50%'}]}}]}]
     js.generate_rpc_reply(
         None,
         "snap_mock",
         "1.1.1.1",
         js.main_file)
     self.assertFalse(mock_extract.called)
     self.assertTrue(mock_parse.called)