From 9ac5673ac80b2ca32ed70b180bd95c0263a967f8 Mon Sep 17 00:00:00 2001 From: Kevin McKinnis Date: Fri, 19 Aug 2016 12:17:56 -0700 Subject: [PATCH 1/5] Made changes to allow the API to work with cual-id, UUID format --- cualid/mint.py | 2 +- cualid/tests/test_mint.py | 4 ++++ scripts/cual-id | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cualid/mint.py b/cualid/mint.py index b00e2eb..2188fc3 100644 --- a/cualid/mint.py +++ b/cualid/mint.py @@ -36,6 +36,6 @@ def create_ids(n, id_length, if at_least_distance(hrid, hrids, d=min_distance): uuids.append(uuid_) hrids.append(hrid) - yield (uuid_, hrid) + yield (hrid, uuid_) else: failures += 1 diff --git a/cualid/tests/test_mint.py b/cualid/tests/test_mint.py index ee7d281..87dbf78 100644 --- a/cualid/tests/test_mint.py +++ b/cualid/tests/test_mint.py @@ -15,6 +15,10 @@ def test_create_ids_fail(self): result = list(create_ids(1000, 3)) self.assertTrue(len(result) > 0) self.assertTrue(len(result) < 1000) + def test_create_ids_API(self): + result = list(create_ids(100,7)) + self.assertTrue(len(str(result[0][0])) < 10) + self.assertTrue(len(str(result[0][1])) > 10) class TestAtLeastDistance(unittest.TestCase): diff --git a/scripts/cual-id b/scripts/cual-id index abaaf09..dc42531 100644 --- a/scripts/cual-id +++ b/scripts/cual-id @@ -41,7 +41,7 @@ def sample_id_generator(number_of_ids, length, fail_threshold, existing_ids): collected = 0 if existing_ids: existing_ids = parse_ids(existing_ids, 0) - for uuid_, hrid in create_ids(number_of_ids, length, + for hrid, uuid_ in create_ids(number_of_ids, length, failure_threshold=fail_threshold, existing_ids=existing_ids): collected += 1 From 984c1cbd25316991e1f55f5f35e2d4778390c9ed Mon Sep 17 00:00:00 2001 From: Kevin McKinnis Date: Fri, 19 Aug 2016 12:27:41 -0700 Subject: [PATCH 2/5] Pep8 fix --- cualid/tests/test_mint.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cualid/tests/test_mint.py b/cualid/tests/test_mint.py index 87dbf78..b3d22a4 100644 --- a/cualid/tests/test_mint.py +++ b/cualid/tests/test_mint.py @@ -15,8 +15,9 @@ def test_create_ids_fail(self): result = list(create_ids(1000, 3)) self.assertTrue(len(result) > 0) self.assertTrue(len(result) < 1000) + def test_create_ids_API(self): - result = list(create_ids(100,7)) + result = list(create_ids(100, 7)) self.assertTrue(len(str(result[0][0])) < 10) self.assertTrue(len(str(result[0][1])) > 10) From abb5d498c7f75b73e44dd15c2b85e9b549990e88 Mon Sep 17 00:00:00 2001 From: Kevin McKinnis Date: Mon, 22 Aug 2016 14:56:23 -0700 Subject: [PATCH 3/5] Finished up some tests --- cualid/tests/test_mint.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cualid/tests/test_mint.py b/cualid/tests/test_mint.py index b3d22a4..c9d3cb1 100644 --- a/cualid/tests/test_mint.py +++ b/cualid/tests/test_mint.py @@ -18,8 +18,9 @@ def test_create_ids_fail(self): def test_create_ids_API(self): result = list(create_ids(100, 7)) - self.assertTrue(len(str(result[0][0])) < 10) - self.assertTrue(len(str(result[0][1])) > 10) + self.assertTrue(len(str(result[0][0])) == 7) + #It is length 36 because of the four - dividers + self.assertTrue(len(str(result[0][1])) == 36) class TestAtLeastDistance(unittest.TestCase): From dc3901a94af9e040cb97e68cf93456c30982e799 Mon Sep 17 00:00:00 2001 From: Kevin McKinnis Date: Mon, 22 Aug 2016 15:01:01 -0700 Subject: [PATCH 4/5] Now at pep8 standards --- cualid/tests/test_mint.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cualid/tests/test_mint.py b/cualid/tests/test_mint.py index c9d3cb1..66e3651 100644 --- a/cualid/tests/test_mint.py +++ b/cualid/tests/test_mint.py @@ -19,7 +19,7 @@ def test_create_ids_fail(self): def test_create_ids_API(self): result = list(create_ids(100, 7)) self.assertTrue(len(str(result[0][0])) == 7) - #It is length 36 because of the four - dividers + """It is length 36 because of the four - dividers""" self.assertTrue(len(str(result[0][1])) == 36) From e0f3859de30b0e609627f72de388e62b4e521ff0 Mon Sep 17 00:00:00 2001 From: Kevin McKinnis Date: Tue, 23 Aug 2016 10:01:28 -0700 Subject: [PATCH 5/5] --- cualid/tests/test_mint.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cualid/tests/test_mint.py b/cualid/tests/test_mint.py index 66e3651..74e0b08 100644 --- a/cualid/tests/test_mint.py +++ b/cualid/tests/test_mint.py @@ -3,6 +3,7 @@ from cualid import create_ids from cualid.mint import at_least_distance +import uuid class TestCreateIDS(unittest.TestCase): @@ -17,10 +18,10 @@ def test_create_ids_fail(self): self.assertTrue(len(result) < 1000) def test_create_ids_API(self): - result = list(create_ids(100, 7)) - self.assertTrue(len(str(result[0][0])) == 7) - """It is length 36 because of the four - dividers""" - self.assertTrue(len(str(result[0][1])) == 36) + id_length = 7 + result = list(create_ids(100, id_length)) + self.assertTrue(len(result[0][0]) == id_length) + self.assertTrue(type(result[0][1]) == uuid.UUID) class TestAtLeastDistance(unittest.TestCase):