forked from chaoss/grimoirelab-perceval
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[cmd:add] Support specific error codes on Add command
This commit also adds a new exception that wraps ValueError. Closes chaoss#19
- Loading branch information
1 parent
ac6a282
commit 96c3936
Showing
5 changed files
with
50 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ | |
from sortinghat.command import CMD_SUCCESS, CMD_FAILURE | ||
from sortinghat.cmd.add import Add | ||
from sortinghat.db.database import Database | ||
from sortinghat.exceptions import CODE_ALREADY_EXISTS_ERROR, CODE_MATCHER_NOT_SUPPORTED_ERROR, CODE_NOT_FOUND_ERROR, CODE_VALUE_ERROR | ||
|
||
from tests.config import DB_USER, DB_PASSWORD, DB_NAME, DB_HOST, DB_PORT | ||
|
||
|
@@ -180,7 +181,7 @@ def test_non_existing_uuid(self): | |
"""Check if it fails adding identities to unique identities that do not exist""" | ||
|
||
code = self.cmd.add('scm', email='[email protected]', uuid='FFFFFFFFFFFFFFF') | ||
self.assertEqual(code, CMD_FAILURE) | ||
self.assertEqual(code, CODE_NOT_FOUND_ERROR) | ||
|
||
output = sys.stderr.getvalue().strip() | ||
self.assertEqual(output, ADD_UUID_NOT_FOUND_ERROR) | ||
|
@@ -189,41 +190,41 @@ def test_existing_identity(self): | |
"""Check if it fails adding an identity that already exists""" | ||
|
||
code = self.cmd.add('scm', '[email protected]', 'John Smith', 'jsmith') | ||
self.assertEqual(code, CMD_FAILURE) | ||
self.assertEqual(code, CODE_ALREADY_EXISTS_ERROR) | ||
output = sys.stderr.getvalue().strip() | ||
self.assertEqual(output, ADD_EXISTING_ERROR) | ||
|
||
def test_none_or_empty_source(self): | ||
"""Check whether new identities cannot be added when giving a None or empty source""" | ||
|
||
code = self.cmd.add(None) | ||
self.assertEqual(code, CMD_FAILURE) | ||
self.assertEqual(code, CODE_VALUE_ERROR) | ||
output = sys.stderr.getvalue().strip().split('\n')[0] | ||
self.assertEqual(output, ADD_SOURCE_NONE_ERROR) | ||
|
||
code = self.cmd.add('') | ||
self.assertEqual(code, CMD_FAILURE) | ||
self.assertEqual(code, CODE_VALUE_ERROR) | ||
output = sys.stderr.getvalue().strip().split('\n')[1] | ||
self.assertEqual(output, ADD_SOURCE_EMPTY_ERROR) | ||
|
||
def test_none_or_empty_data(self): | ||
"""Check whether new identities cannot be added when identity data is None or empty""" | ||
|
||
code = self.cmd.add('scm', None, '', None) | ||
self.assertEqual(code, CMD_FAILURE) | ||
self.assertEqual(code, CODE_VALUE_ERROR) | ||
output = sys.stderr.getvalue().strip().split('\n')[0] | ||
self.assertEqual(output, ADD_IDENTITY_NONE_OR_EMPTY_ERROR) | ||
|
||
code = self.cmd.add('scm', '', '', '') | ||
self.assertEqual(code, CMD_FAILURE) | ||
self.assertEqual(code, CODE_VALUE_ERROR) | ||
output = sys.stderr.getvalue().strip().split('\n')[1] | ||
self.assertEqual(output, ADD_IDENTITY_NONE_OR_EMPTY_ERROR) | ||
|
||
def test_invalid_matching_method(self): | ||
"""Check if it fails when an invalid matching method is given""" | ||
|
||
code = self.cmd.add('scm', '[email protected]', matching='mock') | ||
self.assertEqual(code, CMD_FAILURE) | ||
self.assertEqual(code, CODE_MATCHER_NOT_SUPPORTED_ERROR) | ||
output = sys.stderr.getvalue().strip() | ||
self.assertEqual(output, ADD_MATCHING_ERROR) | ||
|
||
|