Skip to content

Commit

Permalink
Merge pull request #34 from kmckinnis/master
Browse files Browse the repository at this point in the history
Made changes to allow the API to work with cual-id, UUID format
  • Loading branch information
johnchase committed Aug 23, 2016
2 parents 1bb93ae + e0f3859 commit 864da29
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cualid/mint.py
Expand Up @@ -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
7 changes: 7 additions & 0 deletions cualid/tests/test_mint.py
Expand Up @@ -3,6 +3,7 @@

from cualid import create_ids
from cualid.mint import at_least_distance
import uuid


class TestCreateIDS(unittest.TestCase):
Expand All @@ -16,6 +17,12 @@ def test_create_ids_fail(self):
self.assertTrue(len(result) > 0)
self.assertTrue(len(result) < 1000)

def test_create_ids_API(self):
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):

Expand Down
2 changes: 1 addition & 1 deletion scripts/cual-id
Expand Up @@ -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
Expand Down

0 comments on commit 864da29

Please sign in to comment.