Skip to content

Commit

Permalink
Merge branch 'too_verbose' of 'https://github.com/jgbarah/sortinghat'
Browse files Browse the repository at this point in the history
Merges #118
Closes #118
  • Loading branch information
sduenas committed Jan 31, 2018
2 parents 06d3d42 + e7cb01e commit b34787e
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 10 deletions.
8 changes: 5 additions & 3 deletions sortinghat/cmd/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,8 @@ def __load_unique_identities(self, uidentities, matcher, match_new,
stored_uuid = self._merge_on_matching(stored_uuid, matcher,
verbose)

self.log("+ %s (old %s) loaded" % (stored_uuid, uidentity.uuid))
self.log("+ %s (old %s) loaded" % (stored_uuid, uidentity.uuid),
verbose)
self.log("=====", verbose)
n += 1

Expand Down Expand Up @@ -361,7 +362,8 @@ def __load_unique_identity(self, uidentity, verbose):
self.log("-- %s already exists." % uuid, verbose)
return uuid
except NotFoundError as e:
self.log("-- %s not found. Generating a new UUID." % uuid, verbose)
self.log("-- %s not found. Generating a new UUID." % uuid,
debug=verbose)

# We don't have a unique identity, so we have to create
# a new one.
Expand All @@ -379,7 +381,7 @@ def __load_unique_identity(self, uidentity, verbose):
self.new_uids.add(stored_uuid)
except AlreadyExistsError as e:
stored_uuid = e.uuid
self.warning("-- " + str(e))
self.warning("-- " + str(e), debug=verbose)
except ValueError as e:
raise LoadError(cause=str(e))

Expand Down
6 changes: 4 additions & 2 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,8 @@ def test_add_enrollment(self):
enrollments = session.query(Enrollment).\
join(UniqueIdentity, Organization).\
filter(UniqueIdentity.uuid == 'John Smith',
Organization.name == 'Example').order_by(Enrollment.start).all()
Organization.name == 'Example').\
order_by(Enrollment.start).all()
self.assertEqual(len(enrollments), 3)

enrollment = enrollments[0]
Expand Down Expand Up @@ -1662,7 +1663,8 @@ def test_merge_enrollments(self):
enrollments = session.query(Enrollment).\
join(UniqueIdentity, Organization).\
filter(UniqueIdentity.uuid == 'John Smith',
Organization.name == 'Bitergia').all()
Organization.name == 'Bitergia').\
order_by(Enrollment.start).all()
self.assertEqual(len(enrollments), 2)

rol0 = enrollments[0]
Expand Down
88 changes: 83 additions & 5 deletions tests/test_cmd_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,35 @@
Entry added to the blacklist
2/2 blacklist entries loaded
Loading unique identities...
=====
+ Processing 0000000000000000000000000000000000000000
-- 0000000000000000000000000000000000000000 not found. Generating a new UUID.
=====
=====
+ Processing 03e12d00e37fd45593c49a5a5a1652deca4cf302
-- 03e12d00e37fd45593c49a5a5a1652deca4cf302 not found. Generating a new UUID.
-- using a9b403e150dd4af8953a52a4bb841051e4b705d9 for 03e12d00e37fd45593c49a5a5a1652deca4cf302 unique identity.
-- loading identities
-- identities loaded
-- profile a9b403e150dd4af8953a52a4bb841051e4b705d9 updated
-- loading enrollments
-- enrollments loaded
+ a9b403e150dd4af8953a52a4bb841051e4b705d9 (old 03e12d00e37fd45593c49a5a5a1652deca4cf302) loaded
=====
=====
+ Processing 52e0aa0a14826627e633fd15332988686b730ab3
-- 52e0aa0a14826627e633fd15332988686b730ab3 not found. Generating a new UUID.
-- using 17ab00ed3825ec2f50483e33c88df223264182ba for 52e0aa0a14826627e633fd15332988686b730ab3 unique identity.
-- loading identities
-- identities loaded
-- profile 17ab00ed3825ec2f50483e33c88df223264182ba updated
-- loading enrollments
-- enrollments loaded
+ 17ab00ed3825ec2f50483e33c88df223264182ba (old 52e0aa0a14826627e633fd15332988686b730ab3) loaded
=====
2/3 unique identities loaded"""

# Identities outputs
Expand All @@ -73,16 +100,65 @@
Entry added to the blacklist
2/2 blacklist entries loaded
Loading unique identities...
=====
+ Processing 0000000000000000000000000000000000000000
-- 0000000000000000000000000000000000000000 not found. Generating a new UUID.
=====
=====
+ Processing 03e12d00e37fd45593c49a5a5a1652deca4cf302
-- 03e12d00e37fd45593c49a5a5a1652deca4cf302 not found. Generating a new UUID.
-- using a9b403e150dd4af8953a52a4bb841051e4b705d9 for 03e12d00e37fd45593c49a5a5a1652deca4cf302 unique identity.
-- loading identities
-- identities loaded
-- profile a9b403e150dd4af8953a52a4bb841051e4b705d9 updated
-- loading enrollments
-- enrollments loaded
+ a9b403e150dd4af8953a52a4bb841051e4b705d9 (old 03e12d00e37fd45593c49a5a5a1652deca4cf302) loaded
=====
=====
+ Processing 52e0aa0a14826627e633fd15332988686b730ab3
-- 52e0aa0a14826627e633fd15332988686b730ab3 not found. Generating a new UUID.
-- using 17ab00ed3825ec2f50483e33c88df223264182ba for 52e0aa0a14826627e633fd15332988686b730ab3 unique identity.
-- loading identities
-- identities loaded
-- profile 17ab00ed3825ec2f50483e33c88df223264182ba updated
-- loading enrollments
-- enrollments loaded
+ 17ab00ed3825ec2f50483e33c88df223264182ba (old 52e0aa0a14826627e633fd15332988686b730ab3) loaded
=====
2/3 unique identities loaded"""

LOAD_IDENTITIES_OUTPUT_ERROR = """Error: not enough info to load 0000000000000000000000000000000000000000 unique identity. Skipping."""
LOAD_IDENTITIES_OUTPUT_ERROR = """Error: not enough info to load 0000000000000000000000000000000000000000 unique identity. Skipping.
Warning: Bitergia already exists in the registry. Organization not updated.
Warning: Example already exists in the registry. Organization not updated."""

LOAD_IDENTITIES_NO_STRICT_OUTPUT = """Loading blacklist...
0/0 blacklist entries loaded
Loading unique identities...
=====
+ Processing e8284285566fdc1f41c8a22bb84a295fc3c4cbb3
-- e8284285566fdc1f41c8a22bb84a295fc3c4cbb3 not found. Generating a new UUID.
-- using e8284285566fdc1f41c8a22bb84a295fc3c4cbb3 for e8284285566fdc1f41c8a22bb84a295fc3c4cbb3 unique identity.
-- loading identities
-- identities loaded
-- profile e8284285566fdc1f41c8a22bb84a295fc3c4cbb3 updated
-- loading enrollments
-- enrollments loaded
New match found
+ e8284285566fdc1f41c8a22bb84a295fc3c4cbb3
* - jsmith@example - scm
+ 8253035bc847e70ddd13f7a721faf6f3dd159d7a
* - jsmith@example - unknown
Unique identity e8284285566fdc1f41c8a22bb84a295fc3c4cbb3 merged on 8253035bc847e70ddd13f7a721faf6f3dd159d7a
+ 8253035bc847e70ddd13f7a721faf6f3dd159d7a (old e8284285566fdc1f41c8a22bb84a295fc3c4cbb3) loaded
=====
1/1 unique identities loaded"""

# Organization outputs
Expand Down Expand Up @@ -136,7 +212,7 @@ class TestLoadCommand(TestLoadCaseBase):
def test_load(self):
"""Test to load identities and organizations from a file"""

code = self.cmd.run('data/sortinghat_valid.json')
code = self.cmd.run('data/sortinghat_valid.json', '--verbose')
self.assertEqual(code, CMD_SUCCESS)

uids = api.unique_identities(self.db)
Expand All @@ -151,7 +227,7 @@ def test_load(self):
def test_load_identities(self):
"""Test to load identities from a file"""

code = self.cmd.run('--identities', 'data/sortinghat_valid.json')
code = self.cmd.run('--identities', 'data/sortinghat_valid.json', '--verbose')
self.assertEqual(code, CMD_SUCCESS)

uids = api.unique_identities(self.db)
Expand All @@ -172,7 +248,8 @@ def test_load_identities_with_default_matching(self):
"""Test to load identities from a file using default matching"""

code = self.cmd.run('--identities', '--matching', 'default',
'data/sortinghat_valid.json')
'data/sortinghat_valid.json',
'--verbose')
self.assertEqual(code, CMD_SUCCESS)

output = sys.stdout.getvalue().strip()
Expand All @@ -190,7 +267,8 @@ def test_load_identities_no_strict_matching(self):

code = self.cmd.run('--identities', '--matching', 'default',
'--no-strict-matching',
'data/sortinghat_no_strict_valid.json')
'data/sortinghat_no_strict_valid.json',
'--verbose')
self.assertEqual(code, CMD_SUCCESS)

output = sys.stdout.getvalue().strip()
Expand Down

0 comments on commit b34787e

Please sign in to comment.