Пример #1
0
 def test_should_be_able_to_do_simple_op_instead_of_calling_hooks(
         self, reset_folder_structure, mocker):
     """Our test server instance should be able to do simple op instead of calling hooks."""
     self.instance._prepare_server_core()
     mocker.patch.object(self.instance, "registered_fix", return_value=[])
     with spy(self.instance._copy_mod) as copy_mod_function:
         self.instance._apply_hooks_and_do_op("init", "copy", "CBA_A3")
     copy_mod_function.assert_called()
     with spy(self.instance._symlink_mod) as symlink_mod_function:
         self.instance._apply_hooks_and_do_op("init", "link", "ace")
     symlink_mod_function.assert_called()
Пример #2
0
 def test_should_be_able_to_update_compiled_files(self,
                                                  reset_folder_structure):
     """Our test server instance should be able to update compiled files."""
     self.instance._prepare_server_core()
     self.instance._compile_bat_file()
     self.instance._compile_config_file()
     with spy(self.instance._clear_compiled_files) as clear_files_fun, \
             spy(self.instance._compile_bat_file) as compile_bat_fun, \
             spy(self.instance._compile_config_file) as compile_config_fun:
         self.instance._update_compiled_files()
     clear_files_fun.assert_called()
     compile_bat_fun.assert_called()
     compile_config_fun.assert_called()
Пример #3
0
 def test_should_be_able_to_update(self, reset_folder_structure):
     """Our test server instance should be able to update."""
     self.instance._prepare_server_core()
     self.instance._compile_bat_file()
     self.instance._compile_config_file()
     i = self.instance
     with spy(i._check_mods) as check_mods_fun, \
             spy(i._update_all_mods) as update_mods_fun, \
             spy(i._update_keys) as update_keys_fun, \
             spy(i._update_compiled_files) as update_files_fun:
         i.update()
     check_mods_fun.assert_called()
     update_mods_fun.assert_called()
     update_keys_fun.assert_called()
     update_files_fun.assert_called()
Пример #4
0
 def test_should_call_hooks_at_init_mods_time(self, reset_folder_structure):
     """Our test server instance should call hooks at init mods time."""
     self.instance._prepare_server_core()
     with spy(self.instance._apply_hooks_and_do_op) as apply_hooks_function:
         self.instance._start_op_on_mods("init", ["ace", "CBA_A3"])
     apply_hooks_function.assert_has_calls(
         [call("init", "link", "ace"),
          call("init", "copy", "CBA_A3")])
Пример #5
0
 def test_should_be_able_to_update_keys(self, reset_folder_structure):
     """Our test server instance should be able to update keys."""
     self.instance._prepare_server_core()
     self.instance.S.user_mods_list = ["ace", "AdvProp", "ODKAI"]
     self.instance._start_op_on_mods("init", self.instance.S.user_mods_list)
     self.instance._link_keys()
     self.instance.S.user_mods_list = ["ODKAI"]
     self.instance._update_all_mods()
     with spy(self.instance._clear_keys) as clear_keys_fun, spy(
             self.instance._link_keys) as link_keys_fun:
         self.instance._update_keys()
     clear_keys_fun.assert_called()
     link_keys_fun.assert_called()
     keys = listdir(
         join(self.instance.get_server_instance_path(),
              self.instance.keys_folder_name))
     assert len(keys) == len(self.instance.arma_keys) + 1
Пример #6
0
 def setup(self, request, class_reset_folder_structure, c_sc_stub):
     """TestServerInstanceInit setup"""
     server_name = "TestServer1"
     request.cls.test_path = test_folder_structure_path()
     sb = ServerBatSettings(
         server_title="ODK Training Server",
         server_port="2202",
         server_config_file_name="serverTraining.cfg",
         server_cfg_file_name="Arma3Training.cfg",
         server_max_mem="8192",
         server_flags="-filePatching -autoinit -enableHT")
     sc = c_sc_stub
     request.cls.settings = ServerInstanceSettings(
         server_instance_name=server_name,
         bat_settings=sb,
         config_settings=sc,
         arma_folder=self.test_path,
         server_instance_root=self.test_path,
         mods_to_be_copied=["CBA_A3"],
         user_mods_list=["ace", "CBA_A3", "ODKAI"],
         server_mods_list=["AdvProp", "ODKMIN"],
     )
     request.cls.instance = ServerInstance(self.settings)
     request.cls.instance_folder = self.instance.get_server_instance_path()
     # set up all needed spies
     with spy(self.instance._new_server_folder) as request.cls.new_server_fun, \
             spy(self.instance._check_mods) as request.cls.check_mods_fun, \
             spy(self.instance._prepare_server_core) as request.cls.prepare_server_fun, \
             spy(self.instance._start_op_on_mods) as request.cls.init_mods_fun, \
             spy(self.instance._link_keys) as request.cls.init_keys_fun, \
             spy(self.instance._compile_bat_file) as request.cls.compiled_bat_fun, \
             spy(self.instance._compile_config_file) as request.cls.compiled_config_fun:
         self.instance.init()
Пример #7
0
 def test_should_check_for_it_and_stop_before_changing_anything(
         self, reset_folder_structure):
     """An instance with a non existing mod should check for it and stop before changing anything."""
     from odk_servermanager.instance import ModNotFound
     with pytest.raises(ModNotFound), spy(
             self.instance._check_mods_folders) as check_fun:
         self.instance.init()
     check_fun.assert_called()
     assert not isdir(self.instance.get_server_instance_path())