This repository has been archived by the owner on Jun 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Leifur Halldor Asgeirsson
committed
Nov 2, 2016
1 parent
586dfca
commit 9c9f2e2
Showing
5 changed files
with
39 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,3 +87,7 @@ ENV/ | |
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
|
||
# PyCharm | ||
.idea/ |
Empty file.
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import functools | ||
import operator | ||
|
||
|
||
def get_id_hash(id_dict): | ||
hashes = map(hash, id_dict.items()) | ||
id_hash = functools.reduce(operator.xor, hashes, 0) | ||
return id_hash |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
goblin | ||
pytest | ||
pytest-asyncio | ||
pytest-cov |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from goblin_dse import utils | ||
|
||
|
||
def test_get_id_hash(): | ||
distinct_ids = ( | ||
{"~label": "label1", "community_id": 6335574440, "member_id": 1}, | ||
{"~label": "label1", "community_id": 6335574440, "member_id": 2}, | ||
{"~label": "label1", "community_id": 8412991644, "member_id": 1}, | ||
{"~label": "label2", "community_id": 6335574440, "member_id": 1}, | ||
{"~label": "vertex_with_custom_id", | ||
"custom_partition_key_name": "custom_partition_key_value"}, | ||
) | ||
|
||
same_ids = ( | ||
{"~label": "label1", "community_id": 6335574440, "member_id": 1}, | ||
{"~label": "label1", "community_id": 6335574440, "member_id": 1}, | ||
) | ||
|
||
distinct_id_hashes_set = {utils.get_id_hash(val) for val in distinct_ids} | ||
same_ids_hashes_set = {utils.get_id_hash(val) for val in same_ids} | ||
|
||
assert len(distinct_id_hashes_set) == len(distinct_ids) | ||
assert len(same_ids_hashes_set) == 1 |