Beispiel #1
0
 def test_get_config_file_from_arguments(self):
     js = SnapAdmin()
     self.set_hardcoded_value_for_device(js)
     js.args.testfiles = ["main.yml"]
     js.get_config_file()
     local_dict = {'hosts': [{'device': '1.1.1.1', 'username': '******', 'passwd': '123'}], 'tests': ['main.yml']}
     self.assertEqual(js.main_file, local_dict)
Beispiel #2
0
 def test_get_config_file_from_file_exact_path(self):
     # config file is extracted when exact path is passed
     js = SnapAdmin()
     js.args.file = os.path.join(os.path.dirname(__file__),
                                 'configs', 'main.yml')
     js.get_config_file()
     config_file = open(js.args.file, 'r')
     config_file = yaml.load(config_file, Loader=yaml.FullLoader)
     self.assertEqual(js.main_file, config_file)
Beispiel #3
0
 def test_get_config_file_from_file_with_default_path(self, mock_path):
     # config file to be appended with default path when file not present in the path.
     mock_path.return_value = os.path.join(os.path.dirname(__file__), 'configs')
     js = SnapAdmin()
     js.args.file = "main.yml"
     js.get_config_file()
     conf_file = os.path.join(os.path.dirname(__file__),
                              'configs', 'main.yml')
     config_file = open(conf_file, 'r')
     config_file = yaml.load(config_file, Loader=yaml.FullLoader)
     self.assertEqual(js.main_file, config_file)
Beispiel #4
0
 def test_get_config_file_no_file(self, mock_exit):
     js = SnapAdmin()
     js.main_file = "hosts"
     js.args.file = "file_not_found.yml"
     js.get_config_file()
     mock_exit.assert_called_with(1)