Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop returning an error for logged in login attempts #53

Merged
merged 1 commit into from
Aug 7, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion shub/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
@click.pass_context
def cli(context):
if auth.get_key_netrc():
context.fail('Already logged in. To logout use: shub logout')
log("You're already logged in. To change credentials, use 'shub logout' first.")
return 0

cfg_key = _find_cfg_key()
key = _prompt_for_key(suggestion=cfg_key)
Expand Down
14 changes: 14 additions & 0 deletions tests/test_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,17 @@ def test_login_can_handle_invalid_scrapy_cfg(self):

# then
self.assertEqual(0, result.exit_code, result.exception)

def test_login_attempt_after_login_doesnt_lead_to_an_error(self):
with self.runner.isolated_filesystem() as fs:
login.auth.NETRC_FILE = os.path.join(fs, '.netrc')

# given
self.runner.invoke(login.cli, input=self.VALID_KEY)

# when
result = self.runner.invoke(login.cli, input=self.VALID_KEY)

# then
self.assertEqual(0, result.exit_code)
self.assertTrue('already logged in' in result.output)