<s> from click . testing import CliRunner <EOL> import git <EOL> import pytest <EOL> from os . path import abspath , dirname <EOL> from turnstile . manager_subcommands . remove import cmd <EOL> TEST_FOLDER = dirname ( abspath ( __file__ ) ) <EOL> class FakeNonExistingPath ( object ) : <EOL> def __init__ ( self , * args ) : <EOL> pass <EOL> def exists ( self ) : <EOL> return False <EOL> def __div__ ( self , other ) : <EOL> return self <EOL> def __truediv__ ( self , other ) : <EOL> return self <EOL> class FakeRepo ( object ) : <EOL> def __init__ ( self , dir = None ) : <EOL> self . working_dir = TEST_FOLDER <EOL> self . git_dir = '<STR_LIT>' <EOL> @ pytest . fixture <EOL> def fake_git ( monkeypatch ) : <EOL> monkeypatch . setattr ( git , '<STR_LIT>' , FakeRepo ) <EOL> return FakeRepo <EOL> @ pytest . fixture ( ) <EOL> def fake_no_git ( monkeypatch ) : <EOL> def raiser ( * args ) : <EOL> raise git . InvalidGitRepositoryError <EOL> monkeypatch . setattr ( git , '<STR_LIT>' , raiser ) <EOL> @ pytest . fixture <EOL> def fake_path ( mocker ) : <EOL> mock = mocker . patch ( '<STR_LIT>' ) <EOL> return mock <EOL> @ pytest . fixture <EOL> def fake_path_existence ( monkeypatch ) : <EOL> mock2 = monkeypatch . setattr ( '<STR_LIT>' , FakeNonExistingPath ) <EOL> return mock2 <EOL> def test_outside_git ( fake_no_git ) : <EOL> runner = CliRunner ( ) <EOL> result = runner . invoke ( cmd ) <EOL> assert "<STR_LIT>" in result . output <EOL> assert result . exit_code == <NUM_LIT:1> <EOL> def test_remove_hook ( fake_git , fake_path ) : <EOL> runner = CliRunner ( ) <EOL> result = runner . invoke ( cmd , input = '<STR_LIT>' ) <EOL> assert "<STR_LIT>" in result . output <EOL> assert "<STR_LIT>" in result . output <EOL> assert result . exit_code == <NUM_LIT:0> <EOL> def test_dont_remove ( fake_git , fake_path ) : <EOL> runner = CliRunner ( ) <EOL> result = runner . invoke ( cmd , input = '<STR_LIT>' ) <EOL> assert "<STR_LIT>" in result . output <EOL> assert "<STR_LIT>" in result . output <EOL> assert result . exit_code == <NUM_LIT:0> <EOL> def test_doesnt_exist ( fake_git , fake_path_existence ) : <EOL> fake_path . exists = False <EOL> runner = CliRunner ( ) <EOL> result = runner . invoke ( cmd , [ '<STR_LIT>' ] , input = '<STR_LIT>' ) <EOL> assert "<STR_LIT>" in result . output <EOL> assert "<STR_LIT>" in result . output <EOL> assert result . exit_code == <NUM_LIT:0> </s>
