Exemplo n.º 1
0
 def test_from_path(self, mocker):
     match = object()
     get_new_command = object()
     load_source = mocker.patch('thefuck.types.load_source',
                                return_value=Mock(
                                    match=match,
                                    get_new_command=get_new_command,
                                    enabled_by_default=True,
                                    priority=900,
                                    requires_output=True))
     assert Rule.from_path(Path('/rules/bash.py')) \
            == Rule('bash', match, get_new_command, priority=900)
     load_source.assert_called_once_with('bash', '/rules/bash.py')
Exemplo n.º 2
0
 def test_from_path(self, mocker):
     match = object()
     get_new_command = object()
     load_source = mocker.patch(
         'thefuck.types.load_source',
         return_value=Mock(match=match,
                           get_new_command=get_new_command,
                           enabled_by_default=True,
                           priority=900,
                           requires_output=True))
     assert Rule.from_path(Path('/rules/bash.py')) \
            == Rule('bash', match, get_new_command, priority=900)
     load_source.assert_called_once_with('bash', '/rules/bash.py')
Exemplo n.º 3
0
 def test_from_path(self, mocker):
     match = object()
     get_new_command = object()
     load_source = mocker.patch(
         'thedick.types.load_source',
         return_value=Mock(match=match,
                           get_new_command=get_new_command,
                           enabled_by_default=True,
                           priority=900,
                           requires_output=True))
     rule_path = os.path.join(os.sep, 'rules', 'bash.py')
     assert (Rule.from_path(Path(rule_path))
             == Rule('bash', match, get_new_command, priority=900))
     load_source.assert_called_once_with('bash', rule_path)
Exemplo n.º 4
0
 def test_from_path(self, mocker):
     match = object()
     get_new_command = object()
     load_source = mocker.patch(
         "thefuck.types.load_source",
         return_value=Mock(
             match=match,
             get_new_command=get_new_command,
             enabled_by_default=True,
             priority=900,
             requires_output=True,
         ),
     )
     rule_path = os.path.join(os.sep, "rules", "bash.py")
     assert Rule.from_path(Path(rule_path)) == Rule("bash",
                                                    match,
                                                    get_new_command,
                                                    priority=900)
     load_source.assert_called_once_with("bash", rule_path)
Exemplo n.º 5
0
 def test_from_path_excluded_rule(self, mocker, settings):
     load_source = mocker.patch('thedarn.types.load_source')
     settings.update(exclude_rules=['git'])
     rule_path = os.path.join(os.sep, 'rules', 'git.py')
     assert Rule.from_path(Path(rule_path)) is None
     assert not load_source.called
Exemplo n.º 6
0
 def test_from_path_rule_exception(self, mocker):
     load_source = mocker.patch(
         'thedarn.types.load_source',
         side_effect=ImportError("No module named foo..."))
     assert Rule.from_path(Path('git.py')) is None
     load_source.assert_called_once_with('git', 'git.py')