예제 #1
0
    def test_global_shell_configuration_zshell(self):
        """ The global shell should dictate what files are injected (zsh, no bash, no gui)"""
        # test zshell, no bash, no gui
        global_shell_configuration_zshell = """[shell]
bash = false
zsh = true
gui = false

[global]
env_source_rc = False
        """
        environment = create_mock_environment(
            target_config=test_target,
            global_config=global_shell_configuration_zshell,
            mock_injections=False)
        environment.warmup()
        environment.injections.commit = Mock()
        environment.formula_dict['sprinter.formulabase'] = Mock(return_value=create_mock_formulabase())
        environment.install()
        assert [x for x in environment.injections.inject_dict.keys() if x.endswith('.zshrc')]
        env_injected = False
        for profile in ['.zprofile', '.zlogin']:
            env_injected = env_injected or filter(lambda x: x.endswith(profile), environment.injections.inject_dict.keys())
        assert env_injected
        assert not [x for x in environment.injections.inject_dict.keys() if x.endswith('.bashrc')]
        for profile in ['.bash_profile', '.bash_login']:
            assert not [x for x in environment.injections.inject_dict.keys() if x.endswith(profile)]
예제 #2
0
 def setup(self):
     self.temp_dir = tempfile.mkdtemp()
     self.environment = create_mock_environment(source_config=source_config,
                                                target_config=target_config,
                                                mock_directory=False,
                                                mock_system=False,
                                                root=self.temp_dir)
     self.directory = self.environment.directory
예제 #3
0
 def test_running_missing_formula(self):
     """ When a formula is missing, a sprinter exception should be thrown at the end """
     self.environment = create_mock_environment(
         target_config=missing_formula_config)
     try:
         self.environment.install()
         raise Exception("Exception not raised!")
     except SprinterException:
         pass
예제 #4
0
 def test_grab_inputs_existing_source(self):
     """ Grabbing inputs should source from source first, if it exists """
     self.environment = create_mock_environment(
         source_config=source_config,
         target_config=target_config
     )
     self.environment.target.get_config = Mock()
     self.environment.grab_inputs()
     self.environment.target.get_config.assert_has_calls([
         call("password", default=None, secret=True, force_prompt=False),
         call("main_branch", default="comp_main", secret=True, force_prompt=False)
     ])
     assert self.environment.target.get_config.call_count == 2, "More calls were called!"
예제 #5
0
 def test_feature_run_order_install(self):
     """ A feature install should have it's methods run in the proper order """
     environment = create_mock_environment(
         target_config=test_target
     )
     mock_formulabase = Mock(spec=FormulaBase)
     mock_formulabase.resolve.return_value = None
     mock_formulabase.validate.return_value = None
     mock_formulabase.prompt.return_value = None
     mock_formulabase.sync.return_value = None
     environment.formula_dict['sprinter.formulabase'] = Mock(return_value=mock_formulabase)
     environment.install()
     tools.eq_(mock_formulabase.method_calls, [call.should_run(),
                                               call.validate(),
                                               call.resolve(),
                                               call.prompt(),
                                               call.sync()])
예제 #6
0
    def test_env_to_rc_injection(self):
        """ If env_source_rc is set to true, the env environments should source the rc """
        # test bash, gui, no zshell
        global_shell_configuration_bash = """[shell]
bash = true
zsh = true
gui = false

[global]
env_source_rc = True
        """
        environment = create_mock_environment(
            target_config=test_target,
            global_config=global_shell_configuration_bash,
            mock_injections=False,
            mock_global_injections=False)
        environment.warmup()
        environment.injections.commit = Mock()
        environment.global_injections.commit = Mock()
        environment.formula_dict['sprinter.formulabase'] = Mock(return_value=create_mock_formulabase())
        environment.install()

        # bash
        env_injected = False
        full_rc_path = os.path.expanduser(os.path.join("~", ".bashrc"))
        for profile in ['.bash_profile', '.bash_login', '.profile']:
            full_profile_path = os.path.expanduser(os.path.join("~", profile))
            specific_env_injected = full_profile_path in environment.global_injections.inject_dict
            if specific_env_injected:
                env_injected = True
                assert (source_template % (full_rc_path, full_rc_path) in
                        environment.global_injections.inject_dict[full_profile_path])
        assert env_injected

        # zshell
        env_injected = False
        full_rc_path = os.path.expanduser(os.path.join("~", ".zshrc"))
        for profile in ['.zprofile', '.zlogin']:
            full_profile_path = os.path.expanduser(os.path.join("~", profile))
            specific_env_injected = full_profile_path in environment.global_injections.inject_dict
            if specific_env_injected:
                env_injected = True
                assert (source_template % (full_rc_path, full_rc_path) in
                        environment.global_injections.inject_dict[full_profile_path])
        assert env_injected
예제 #7
0
 def test_feature_run_order_activate(self):
     """ A feature should have it's methods run in the proper order """
     environment = create_mock_environment(
         source_config=test_source,
         installed=True
     )
     mock_formulabase = Mock(spec=FormulaBase)
     mock_formulabase.resolve.return_value = None
     mock_formulabase.validate.return_value = None
     mock_formulabase.prompt.return_value = None
     mock_formulabase.activate.return_value = None
     environment.formula_dict['sprinter.formulabase'] = Mock(return_value=mock_formulabase)
     environment.activate()
     tools.eq_(mock_formulabase.method_calls, [call.should_run(),
                                               call.validate(),
                                               call.resolve(),
                                               call.prompt(),
                                               call.activate()])