Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
#17: improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
derrix060 committed Sep 28, 2018
1 parent 84205dd commit 1c0f70b
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions tests/test_pref_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def test_list_drives(self, mock):
pass

@requests_mock.mock()
def test_add_drive(self, mock):
def test_add_drive(self, mock, drive_id='new_drive_id'):
self._call_authenticate_account(mock=mock, code='foobar_code', args=('--code', 'foobar_code'))

def fake_accounts():
Expand All @@ -127,7 +127,7 @@ def fake_accounts():
try:
od_pref.set_drive(
args=(
'--drive-id', 'new_drive_id',
'--drive-id', drive_id,
'--email', '[email protected]',
'--local-root', tmp_local_repo.name,
'--ignore-file', tmp_local_repo.name + '/ignore_file.txt',
Expand All @@ -142,7 +142,18 @@ def fake_accounts():
@requests_mock.mock()
def test_del_drive(self, mock):
drive_id = 'xb_drive_id'
self.test_add_drive()
self.test_add_drive(drive_id=drive_id)
try:
od_pref.delete_drive(args=('--drive-id', drive_id, '--yes'))
self.assertFalse(os.path.exists(od_repo.get_drive_db_path(od_pref.context.config_dir, drive_id)))
except SystemExit as e:
if e.code == 0:
pass

@requests_mock.mock()
def test_del_unknown_drive(self, mock):
drive_id = 'unknown_drive'
self.assertFalse(os.path.isfile(od_repo.get_drive_db_path(od_pref.context.config_dir, drive_id)))
try:
od_pref.delete_drive(args=('--drive-id', drive_id, '--yes'))
self.assertFalse(os.path.exists(od_repo.get_drive_db_path(od_pref.context.config_dir, drive_id)))
Expand Down

0 comments on commit 1c0f70b

Please sign in to comment.