{"action":"created","comment":{"url":"https://api.github.com/repos/seequent/properties/pulls/comments/181168120","pull_request_review_id":111727394,"id":181168120,"diff_hunk":"@@ -0,0 +1,151 @@\n+# coding=utf-8\n+from __future__ import absolute_import\n+from __future__ import division\n+from __future__ import print_function\n+from __future__ import unicode_literals\n+\n+from collections import OrderedDict\n+import unittest\n+\n+import properties\n+from properties.extras import HasUID, Pointer\n+\n+class TestUID(unittest.TestCase):\n+\n+    def test_hasuid(self):\n+\n+        has_uid = HasUID()\n+\n+        assert has_uid.uid in HasUID._INSTANCES\n+        assert has_uid is HasUID._INSTANCES[has_uid.uid]\n+\n+        has_uid.uid = 'a'\n+        assert 'a' in HasUID._INSTANCES\n+\n+        has_uid.uid = 'a'\n+\n+        with self.assertRaises(properties.ValidationError):\n+            HasUID(uid='a')\n+\n+        class RecursiveUID(HasUID):\n+\n+            instance = properties.Instance('Any instance', HasUID)\n+\n+        recursive_uid = RecursiveUID(uid='b')\n+        recursive_uid.instance = recursive_uid\n+\n+        serial_dict = recursive_uid.serialize()\n+        assert '__uid__' in serial_dict\n+        assert serial_dict['__uid__'] == 'b'\n+        assert 'b' in serial_dict\n+        assert serial_dict['b'] == {'uid': 'b', 'instance': 'b', '__class__': 'RecursiveUID'}\n+\n+        with self.assertRaises(ValueError):\n+            RecursiveUID.deserialize('hello')\n+\n+        with self.assertRaises(ValueError):\n+            RecursiveUID.deserialize(serial_dict)\n+\n+        RecursiveUID._INSTANCES.clear()\n+        recursive_uid = RecursiveUID.deserialize(serial_dict)\n+        assert recursive_uid.instance is recursive_uid\n+        assert recursive_uid.validate()\n+\n+        RecursiveUID._INSTANCES.clear()\n+        serial_dict['b']['instance'] = 'c'\n+        with self.assertRaises(ValueError):\n+            RecursiveUID.deserialize(serial_dict)\n+\n+        nested_uid = RecursiveUID(\n+            uid='x',\n+            instance=RecursiveUID(\n+                uid='y',\n+                instance=HasUID(\n+                    uid='z',\n+                ),\n+            ),\n+        )\n+\n+        serial_dict = nested_uid.serialize()\n+        assert all([uid in serial_dict for uid in ['x', 'y', 'z', '__uid__']])\n+\n+        RecursiveUID._INSTANCES.clear()\n+        less_nested_uid = RecursiveUID.deserialize(serial_dict, uid='y')\n+        assert less_nested_uid.uid == 'y'\n+        assert less_nested_uid.instance.uid == 'z'\n+\n+        serial_ordered_dict = nested_uid.serialize(registry=OrderedDict())\n+        assert list(serial_ordered_dict.keys()) == ['__uid__', 'x', 'y', 'z']\n+\n+\n+    def test_pointer(self):\n+\n+        with self.assertRaises(TypeError):\n+            Pointer('', object)\n+\n+        class AnotherUID(HasUID):\n+            pass\n+\n+        class HasPointer(HasUID):\n+\n+            other = Pointer('', AnotherUID)\n+\n+        has_pointer = HasPointer()\n+        has_uid = HasUID()\n+        another_uid = AnotherUID()\n+\n+        has_pointer.other = 'silly_pointer'\n+        assert has_pointer.other == 'silly_pointer'\n+\n+        has_pointer.other = another_uid\n+        assert has_pointer.other is another_uid\n+\n+        has_pointer.other = properties.undefined\n+        has_pointer.other = another_uid.uid\n+        assert has_pointer.other is another_uid\n+\n+        has_pointer.other = properties.undefined\n+        with self.assertRaises(properties.ValidationError):\n+            has_pointer.other = has_uid\n+\n+        with self.assertRaises(properties.ValidationError):\n+            has_pointer.other = has_uid.uid\n+\n+    def test_enforce_uid(self):\n+\n+        with self.assertRaises(TypeError):\n+            Pointer('', HasUID, enforce_uid=5)","path":"tests/test_uid.py","position":117,"original_position":117,"commit_id":"cd3cf9f243b3dad651f56c6ddeeedcd8dca804e3","original_commit_id":"cd3cf9f243b3dad651f56c6ddeeedcd8dca804e3","user":{"login":"bsmithyman","id":4269565,"avatar_url":"https://avatars3.githubusercontent.com/u/4269565?v=4","gravatar_id":"","url":"https://api.github.com/users/bsmithyman","html_url":"https://github.com/bsmithyman","followers_url":"https://api.github.com/users/bsmithyman/followers","following_url":"https://api.github.com/users/bsmithyman/following{/other_user}","gists_url":"https://api.github.com/users/bsmithyman/gists{/gist_id}","starred_url":"https://api.github.com/users/bsmithyman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bsmithyman/subscriptions","organizations_url":"https://api.github.com/users/bsmithyman/orgs","repos_url":"https://api.github.com/users/bsmithyman/repos","events_url":"https://api.github.com/users/bsmithyman/events{/privacy}","received_events_url":"https://api.github.com/users/bsmithyman/received_events","type":"User","site_admin":false},"body":"Again, I guess I don't really get the point here.","created_at":"2018-04-12T17:51:26Z","updated_at":"2018-04-12T17:53:53Z","html_url":"https://github.com/seequent/properties/pull/234#discussion_r181168120","pull_request_url":"https://api.github.com/repos/seequent/properties/pulls/234","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/seequent/properties/pulls/comments/181168120"},"html":{"href":"https://github.com/seequent/properties/pull/234#discussion_r181168120"},"pull_request":{"href":"https://api.github.com/repos/seequent/properties/pulls/234"}}},"pull_request":{"url":"https://api.github.com/repos/seequent/properties/pulls/234","id":181258186,"html_url":"https://github.com/seequent/properties/pull/234","diff_url":"https://github.com/seequent/properties/pull/234.diff","patch_url":"https://github.com/seequent/properties/pull/234.patch","issue_url":"https://api.github.com/repos/seequent/properties/issues/234","number":234,"state":"open","locked":false,"title":"Add HasUID class for HasProperties models with UID","user":{"login":"fwkoch","id":9453731,"avatar_url":"https://avatars0.githubusercontent.com/u/9453731?v=4","gravatar_id":"","url":"https://api.github.com/users/fwkoch","html_url":"https://github.com/fwkoch","followers_url":"https://api.github.com/users/fwkoch/followers","following_url":"https://api.github.com/users/fwkoch/following{/other_user}","gists_url":"https://api.github.com/users/fwkoch/gists{/gist_id}","starred_url":"https://api.github.com/users/fwkoch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fwkoch/subscriptions","organizations_url":"https://api.github.com/users/fwkoch/orgs","repos_url":"https://api.github.com/users/fwkoch/repos","events_url":"https://api.github.com/users/fwkoch/events{/privacy}","received_events_url":"https://api.github.com/users/fwkoch/received_events","type":"User","site_admin":false},"body":"- `HasUID` instances are serialized/deserialized into/from a flat dict of UID/HasUID key/value pairs\r\n- `HasUID` instances contained in memory may be accessed by their UID from `HasUID._INSTANCES`\r\n- The `Pointer` property extends `Instance` property functionality for `HasUID` classes, allowing them to be referenced by uid","created_at":"2018-04-12T16:23:06Z","updated_at":"2018-04-12T17:53:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b406ab5465a73a9756e13838b32061f5ea736d88","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/seequent/properties/pulls/234/commits","review_comments_url":"https://api.github.com/repos/seequent/properties/pulls/234/comments","review_comment_url":"https://api.github.com/repos/seequent/properties/pulls/comments{/number}","comments_url":"https://api.github.com/repos/seequent/properties/issues/234/comments","statuses_url":"https://api.github.com/repos/seequent/properties/statuses/cd3cf9f243b3dad651f56c6ddeeedcd8dca804e3","head":{"label":"seequent:feat/uid_extra","ref":"feat/uid_extra","sha":"cd3cf9f243b3dad651f56c6ddeeedcd8dca804e3","user":{"login":"seequent","id":32965729,"avatar_url":"https://avatars1.githubusercontent.com/u/32965729?v=4","gravatar_id":"","url":"https://api.github.com/users/seequent","html_url":"https://github.com/seequent","followers_url":"https://api.github.com/users/seequent/followers","following_url":"https://api.github.com/users/seequent/following{/other_user}","gists_url":"https://api.github.com/users/seequent/gists{/gist_id}","starred_url":"https://api.github.com/users/seequent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seequent/subscriptions","organizations_url":"https://api.github.com/users/seequent/orgs","repos_url":"https://api.github.com/users/seequent/repos","events_url":"https://api.github.com/users/seequent/events{/privacy}","received_events_url":"https://api.github.com/users/seequent/received_events","type":"Organization","site_admin":false},"repo":{"id":59582679,"name":"properties","full_name":"seequent/properties","owner":{"login":"seequent","id":32965729,"avatar_url":"https://avatars1.githubusercontent.com/u/32965729?v=4","gravatar_id":"","url":"https://api.github.com/users/seequent","html_url":"https://github.com/seequent","followers_url":"https://api.github.com/users/seequent/followers","following_url":"https://api.github.com/users/seequent/following{/other_user}","gists_url":"https://api.github.com/users/seequent/gists{/gist_id}","starred_url":"https://api.github.com/users/seequent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seequent/subscriptions","organizations_url":"https://api.github.com/users/seequent/orgs","repos_url":"https://api.github.com/users/seequent/repos","events_url":"https://api.github.com/users/seequent/events{/privacy}","received_events_url":"https://api.github.com/users/seequent/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/seequent/properties","description":"An organizational aid and wrapper for validation and tab completion of class properties/traits.","fork":false,"url":"https://api.github.com/repos/seequent/properties","forks_url":"https://api.github.com/repos/seequent/properties/forks","keys_url":"https://api.github.com/repos/seequent/properties/keys{/key_id}","collaborators_url":"https://api.github.com/repos/seequent/properties/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/seequent/properties/teams","hooks_url":"https://api.github.com/repos/seequent/properties/hooks","issue_events_url":"https://api.github.com/repos/seequent/properties/issues/events{/number}","events_url":"https://api.github.com/repos/seequent/properties/events","assignees_url":"https://api.github.com/repos/seequent/properties/assignees{/user}","branches_url":"https://api.github.com/repos/seequent/properties/branches{/branch}","tags_url":"https://api.github.com/repos/seequent/properties/tags","blobs_url":"https://api.github.com/repos/seequent/properties/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/seequent/properties/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/seequent/properties/git/refs{/sha}","trees_url":"https://api.github.com/repos/seequent/properties/git/trees{/sha}","statuses_url":"https://api.github.com/repos/seequent/properties/statuses/{sha}","languages_url":"https://api.github.com/repos/seequent/properties/languages","stargazers_url":"https://api.github.com/repos/seequent/properties/stargazers","contributors_url":"https://api.github.com/repos/seequent/properties/contributors","subscribers_url":"https://api.github.com/repos/seequent/properties/subscribers","subscription_url":"https://api.github.com/repos/seequent/properties/subscription","commits_url":"https://api.github.com/repos/seequent/properties/commits{/sha}","git_commits_url":"https://api.github.com/repos/seequent/properties/git/commits{/sha}","comments_url":"https://api.github.com/repos/seequent/properties/comments{/number}","issue_comment_url":"https://api.github.com/repos/seequent/properties/issues/comments{/number}","contents_url":"https://api.github.com/repos/seequent/properties/contents/{+path}","compare_url":"https://api.github.com/repos/seequent/properties/compare/{base}...{head}","merges_url":"https://api.github.com/repos/seequent/properties/merges","archive_url":"https://api.github.com/repos/seequent/properties/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/seequent/properties/downloads","issues_url":"https://api.github.com/repos/seequent/properties/issues{/number}","pulls_url":"https://api.github.com/repos/seequent/properties/pulls{/number}","milestones_url":"https://api.github.com/repos/seequent/properties/milestones{/number}","notifications_url":"https://api.github.com/repos/seequent/properties/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/seequent/properties/labels{/name}","releases_url":"https://api.github.com/repos/seequent/properties/releases{/id}","deployments_url":"https://api.github.com/repos/seequent/properties/deployments","created_at":"2016-05-24T14:57:02Z","updated_at":"2018-04-02T19:48:50Z","pushed_at":"2018-04-12T16:23:07Z","git_url":"git://github.com/seequent/properties.git","ssh_url":"git@github.com:seequent/properties.git","clone_url":"https://github.com/seequent/properties.git","svn_url":"https://github.com/seequent/properties","homepage":"http://propertiespy.rtfd.org","size":1059,"stargazers_count":6,"watchers_count":6,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"archived":false,"open_issues_count":24,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":3,"open_issues":24,"watchers":6,"default_branch":"master"}},"base":{"label":"seequent:dev","ref":"dev","sha":"cad580c643856d2898f867d24433686d631ee1f2","user":{"login":"seequent","id":32965729,"avatar_url":"https://avatars1.githubusercontent.com/u/32965729?v=4","gravatar_id":"","url":"https://api.github.com/users/seequent","html_url":"https://github.com/seequent","followers_url":"https://api.github.com/users/seequent/followers","following_url":"https://api.github.com/users/seequent/following{/other_user}","gists_url":"https://api.github.com/users/seequent/gists{/gist_id}","starred_url":"https://api.github.com/users/seequent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seequent/subscriptions","organizations_url":"https://api.github.com/users/seequent/orgs","repos_url":"https://api.github.com/users/seequent/repos","events_url":"https://api.github.com/users/seequent/events{/privacy}","received_events_url":"https://api.github.com/users/seequent/received_events","type":"Organization","site_admin":false},"repo":{"id":59582679,"name":"properties","full_name":"seequent/properties","owner":{"login":"seequent","id":32965729,"avatar_url":"https://avatars1.githubusercontent.com/u/32965729?v=4","gravatar_id":"","url":"https://api.github.com/users/seequent","html_url":"https://github.com/seequent","followers_url":"https://api.github.com/users/seequent/followers","following_url":"https://api.github.com/users/seequent/following{/other_user}","gists_url":"https://api.github.com/users/seequent/gists{/gist_id}","starred_url":"https://api.github.com/users/seequent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seequent/subscriptions","organizations_url":"https://api.github.com/users/seequent/orgs","repos_url":"https://api.github.com/users/seequent/repos","events_url":"https://api.github.com/users/seequent/events{/privacy}","received_events_url":"https://api.github.com/users/seequent/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/seequent/properties","description":"An organizational aid and wrapper for validation and tab completion of class properties/traits.","fork":false,"url":"https://api.github.com/repos/seequent/properties","forks_url":"https://api.github.com/repos/seequent/properties/forks","keys_url":"https://api.github.com/repos/seequent/properties/keys{/key_id}","collaborators_url":"https://api.github.com/repos/seequent/properties/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/seequent/properties/teams","hooks_url":"https://api.github.com/repos/seequent/properties/hooks","issue_events_url":"https://api.github.com/repos/seequent/properties/issues/events{/number}","events_url":"https://api.github.com/repos/seequent/properties/events","assignees_url":"https://api.github.com/repos/seequent/properties/assignees{/user}","branches_url":"https://api.github.com/repos/seequent/properties/branches{/branch}","tags_url":"https://api.github.com/repos/seequent/properties/tags","blobs_url":"https://api.github.com/repos/seequent/properties/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/seequent/properties/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/seequent/properties/git/refs{/sha}","trees_url":"https://api.github.com/repos/seequent/properties/git/trees{/sha}","statuses_url":"https://api.github.com/repos/seequent/properties/statuses/{sha}","languages_url":"https://api.github.com/repos/seequent/properties/languages","stargazers_url":"https://api.github.com/repos/seequent/properties/stargazers","contributors_url":"https://api.github.com/repos/seequent/properties/contributors","subscribers_url":"https://api.github.com/repos/seequent/properties/subscribers","subscription_url":"https://api.github.com/repos/seequent/properties/subscription","commits_url":"https://api.github.com/repos/seequent/properties/commits{/sha}","git_commits_url":"https://api.github.com/repos/seequent/properties/git/commits{/sha}","comments_url":"https://api.github.com/repos/seequent/properties/comments{/number}","issue_comment_url":"https://api.github.com/repos/seequent/properties/issues/comments{/number}","contents_url":"https://api.github.com/repos/seequent/properties/contents/{+path}","compare_url":"https://api.github.com/repos/seequent/properties/compare/{base}...{head}","merges_url":"https://api.github.com/repos/seequent/properties/merges","archive_url":"https://api.github.com/repos/seequent/properties/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/seequent/properties/downloads","issues_url":"https://api.github.com/repos/seequent/properties/issues{/number}","pulls_url":"https://api.github.com/repos/seequent/properties/pulls{/number}","milestones_url":"https://api.github.com/repos/seequent/properties/milestones{/number}","notifications_url":"https://api.github.com/repos/seequent/properties/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/seequent/properties/labels{/name}","releases_url":"https://api.github.com/repos/seequent/properties/releases{/id}","deployments_url":"https://api.github.com/repos/seequent/properties/deployments","created_at":"2016-05-24T14:57:02Z","updated_at":"2018-04-02T19:48:50Z","pushed_at":"2018-04-12T16:23:07Z","git_url":"git://github.com/seequent/properties.git","ssh_url":"git@github.com:seequent/properties.git","clone_url":"https://github.com/seequent/properties.git","svn_url":"https://github.com/seequent/properties","homepage":"http://propertiespy.rtfd.org","size":1059,"stargazers_count":6,"watchers_count":6,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"archived":false,"open_issues_count":24,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":3,"open_issues":24,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/seequent/properties/pulls/234"},"html":{"href":"https://github.com/seequent/properties/pull/234"},"issue":{"href":"https://api.github.com/repos/seequent/properties/issues/234"},"comments":{"href":"https://api.github.com/repos/seequent/properties/issues/234/comments"},"review_comments":{"href":"https://api.github.com/repos/seequent/properties/pulls/234/comments"},"review_comment":{"href":"https://api.github.com/repos/seequent/properties/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/seequent/properties/pulls/234/commits"},"statuses":{"href":"https://api.github.com/repos/seequent/properties/statuses/cd3cf9f243b3dad651f56c6ddeeedcd8dca804e3"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"bsmithyman"}}