{"action":"created","comment":{"url":"https://api.github.com/repos/python-hyper/hpack/pulls/comments/33701251","id":33701251,"diff_hunk":"@@ -0,0 +1,147 @@\n+from hpack.table import HeaderTable\n+import pytest\n+import sys\n+_ver = sys.version_info\n+is_py2 = _ver[0] == 2\n+is_py3 = _ver[0] == 3\n+\n+class TestHeaderTable(object):\n+    def test_getitem_dynamic_table(self):\n+        tbl = HeaderTable()\n+        off = len(HeaderTable.STATIC_TABLE)\n+        val = (b'TestName', b'TestValue')\n+        tbl.add(val[0], val[1])\n+        res = tbl[off + 1]\n+        assert res == val\n+\n+    def test_getitem_static_table(self):\n+        tbl = HeaderTable()\n+        exp = HeaderTable.STATIC_TABLE[0]\n+        res = tbl[1]\n+        assert res == exp\n+        off = len(HeaderTable.STATIC_TABLE)\n+        exp = HeaderTable.STATIC_TABLE[off - 1]\n+        res = tbl[off]\n+        assert res == exp\n+\n+    def test_getitem_zero_index(self):\n+        tbl = HeaderTable()\n+        res = tbl[0]\n+        assert res == None # TODO HPACKException will be raised instead\n+\n+    def test_getitem_out_of_range(self):\n+        tbl = HeaderTable()\n+        off = len(HeaderTable.STATIC_TABLE)\n+        tbl.add(b'TestName', b'TestValue')\n+        res = tbl[off+2]\n+        assert res == None # TODO HPACKException will be reaised instead\n+\n+    def test_setitem(self):\n+        tbl = HeaderTable()\n+        with pytest.raises(TypeError) as einfo:\n+            tbl[1] = (b'TestName', b'TestValue')\n+        assert 'HeaderTable' in str(einfo.value)\n+\n+    def test_repr(self):\n+        tbl = HeaderTable()\n+        tbl.add(b'TestName1', b'TestValue1')\n+        tbl.add(b'TestName2', b'TestValue2')\n+        tbl.add(b'TestName2', b'TestValue2')\n+        # Meh, I hate that I have to do this to test\n+        # repr\n+        if(is_py3):\n+            exp = (\"HeaderTable(4096, False, [\"    +\n+                   \"(b'TestName2', b'TestValue2'), \" +\n+                   \"(b'TestName2', b'TestValue2'), \" +\n+                   \"(b'TestName1', b'TestValue1')\"   +\n+                   \"])\")\n+        else:\n+            exp = (\"HeaderTable(4096, False, [\"    +\n+                   \"('TestName2', 'TestValue2'), \" +\n+                   \"('TestName2', 'TestValue2'), \" +\n+                   \"('TestName1', 'TestValue1')\"   +\n+                   \"])\")\n+        res = str(tbl)","path":"test/test_table.py","position":64,"original_position":64,"commit_id":"af8153b62e19a91cfff55e6e7ee210b7795e09a5","original_commit_id":"af8153b62e19a91cfff55e6e7ee210b7795e09a5","user":{"login":"Lukasa","id":1382556,"avatar_url":"https://avatars.githubusercontent.com/u/1382556?v=3","gravatar_id":"","url":"https://api.github.com/users/Lukasa","html_url":"https://github.com/Lukasa","followers_url":"https://api.github.com/users/Lukasa/followers","following_url":"https://api.github.com/users/Lukasa/following{/other_user}","gists_url":"https://api.github.com/users/Lukasa/gists{/gist_id}","starred_url":"https://api.github.com/users/Lukasa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Lukasa/subscriptions","organizations_url":"https://api.github.com/users/Lukasa/orgs","repos_url":"https://api.github.com/users/Lukasa/repos","events_url":"https://api.github.com/users/Lukasa/events{/privacy}","received_events_url":"https://api.github.com/users/Lukasa/received_events","type":"User","site_admin":false},"body":"*Strictly* this is testing the cast to string, not the repr. ;) Might be better to call `repr()` than `str()`.","created_at":"2015-07-01T17:18:57Z","updated_at":"2015-07-01T17:18:57Z","html_url":"https://github.com/python-hyper/hpack/pull/5#discussion_r33701251","pull_request_url":"https://api.github.com/repos/python-hyper/hpack/pulls/5","_links":{"self":{"href":"https://api.github.com/repos/python-hyper/hpack/pulls/comments/33701251"},"html":{"href":"https://github.com/python-hyper/hpack/pull/5#discussion_r33701251"},"pull_request":{"href":"https://api.github.com/repos/python-hyper/hpack/pulls/5"}}},"pull_request":{"url":"https://api.github.com/repos/python-hyper/hpack/pulls/5","id":38921681,"html_url":"https://github.com/python-hyper/hpack/pull/5","diff_url":"https://github.com/python-hyper/hpack/pull/5.diff","patch_url":"https://github.com/python-hyper/hpack/pull/5.patch","issue_url":"https://api.github.com/repos/python-hyper/hpack/issues/5","number":5,"state":"open","locked":false,"title":"Refactor Header Table","user":{"login":"jimcarreer","id":433092,"avatar_url":"https://avatars.githubusercontent.com/u/433092?v=3","gravatar_id":"","url":"https://api.github.com/users/jimcarreer","html_url":"https://github.com/jimcarreer","followers_url":"https://api.github.com/users/jimcarreer/followers","following_url":"https://api.github.com/users/jimcarreer/following{/other_user}","gists_url":"https://api.github.com/users/jimcarreer/gists{/gist_id}","starred_url":"https://api.github.com/users/jimcarreer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jimcarreer/subscriptions","organizations_url":"https://api.github.com/users/jimcarreer/orgs","repos_url":"https://api.github.com/users/jimcarreer/repos","events_url":"https://api.github.com/users/jimcarreer/events{/privacy}","received_events_url":"https://api.github.com/users/jimcarreer/received_events","type":"User","site_admin":false},"body":"Header table functionality now encapsulated in its own class.","created_at":"2015-06-30T20:40:16Z","updated_at":"2015-07-01T17:18:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"86e943d5abf29def27544c0d9c2e24b941e04fe6","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/python-hyper/hpack/pulls/5/commits","review_comments_url":"https://api.github.com/repos/python-hyper/hpack/pulls/5/comments","review_comment_url":"https://api.github.com/repos/python-hyper/hpack/pulls/comments{/number}","comments_url":"https://api.github.com/repos/python-hyper/hpack/issues/5/comments","statuses_url":"https://api.github.com/repos/python-hyper/hpack/statuses/af8153b62e19a91cfff55e6e7ee210b7795e09a5","head":{"label":"jimcarreer:master","ref":"master","sha":"af8153b62e19a91cfff55e6e7ee210b7795e09a5","user":{"login":"jimcarreer","id":433092,"avatar_url":"https://avatars.githubusercontent.com/u/433092?v=3","gravatar_id":"","url":"https://api.github.com/users/jimcarreer","html_url":"https://github.com/jimcarreer","followers_url":"https://api.github.com/users/jimcarreer/followers","following_url":"https://api.github.com/users/jimcarreer/following{/other_user}","gists_url":"https://api.github.com/users/jimcarreer/gists{/gist_id}","starred_url":"https://api.github.com/users/jimcarreer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jimcarreer/subscriptions","organizations_url":"https://api.github.com/users/jimcarreer/orgs","repos_url":"https://api.github.com/users/jimcarreer/repos","events_url":"https://api.github.com/users/jimcarreer/events{/privacy}","received_events_url":"https://api.github.com/users/jimcarreer/received_events","type":"User","site_admin":false},"repo":{"id":37951389,"name":"hpack","full_name":"jimcarreer/hpack","owner":{"login":"jimcarreer","id":433092,"avatar_url":"https://avatars.githubusercontent.com/u/433092?v=3","gravatar_id":"","url":"https://api.github.com/users/jimcarreer","html_url":"https://github.com/jimcarreer","followers_url":"https://api.github.com/users/jimcarreer/followers","following_url":"https://api.github.com/users/jimcarreer/following{/other_user}","gists_url":"https://api.github.com/users/jimcarreer/gists{/gist_id}","starred_url":"https://api.github.com/users/jimcarreer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jimcarreer/subscriptions","organizations_url":"https://api.github.com/users/jimcarreer/orgs","repos_url":"https://api.github.com/users/jimcarreer/repos","events_url":"https://api.github.com/users/jimcarreer/events{/privacy}","received_events_url":"https://api.github.com/users/jimcarreer/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jimcarreer/hpack","description":"HTTP/2 Header Encoding for Python","fork":true,"url":"https://api.github.com/repos/jimcarreer/hpack","forks_url":"https://api.github.com/repos/jimcarreer/hpack/forks","keys_url":"https://api.github.com/repos/jimcarreer/hpack/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jimcarreer/hpack/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jimcarreer/hpack/teams","hooks_url":"https://api.github.com/repos/jimcarreer/hpack/hooks","issue_events_url":"https://api.github.com/repos/jimcarreer/hpack/issues/events{/number}","events_url":"https://api.github.com/repos/jimcarreer/hpack/events","assignees_url":"https://api.github.com/repos/jimcarreer/hpack/assignees{/user}","branches_url":"https://api.github.com/repos/jimcarreer/hpack/branches{/branch}","tags_url":"https://api.github.com/repos/jimcarreer/hpack/tags","blobs_url":"https://api.github.com/repos/jimcarreer/hpack/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jimcarreer/hpack/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jimcarreer/hpack/git/refs{/sha}","trees_url":"https://api.github.com/repos/jimcarreer/hpack/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jimcarreer/hpack/statuses/{sha}","languages_url":"https://api.github.com/repos/jimcarreer/hpack/languages","stargazers_url":"https://api.github.com/repos/jimcarreer/hpack/stargazers","contributors_url":"https://api.github.com/repos/jimcarreer/hpack/contributors","subscribers_url":"https://api.github.com/repos/jimcarreer/hpack/subscribers","subscription_url":"https://api.github.com/repos/jimcarreer/hpack/subscription","commits_url":"https://api.github.com/repos/jimcarreer/hpack/commits{/sha}","git_commits_url":"https://api.github.com/repos/jimcarreer/hpack/git/commits{/sha}","comments_url":"https://api.github.com/repos/jimcarreer/hpack/comments{/number}","issue_comment_url":"https://api.github.com/repos/jimcarreer/hpack/issues/comments{/number}","contents_url":"https://api.github.com/repos/jimcarreer/hpack/contents/{+path}","compare_url":"https://api.github.com/repos/jimcarreer/hpack/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jimcarreer/hpack/merges","archive_url":"https://api.github.com/repos/jimcarreer/hpack/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jimcarreer/hpack/downloads","issues_url":"https://api.github.com/repos/jimcarreer/hpack/issues{/number}","pulls_url":"https://api.github.com/repos/jimcarreer/hpack/pulls{/number}","milestones_url":"https://api.github.com/repos/jimcarreer/hpack/milestones{/number}","notifications_url":"https://api.github.com/repos/jimcarreer/hpack/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jimcarreer/hpack/labels{/name}","releases_url":"https://api.github.com/repos/jimcarreer/hpack/releases{/id}","created_at":"2015-06-23T23:51:41Z","updated_at":"2015-06-23T23:51:43Z","pushed_at":"2015-07-01T11:58:08Z","git_url":"git://github.com/jimcarreer/hpack.git","ssh_url":"git@github.com:jimcarreer/hpack.git","clone_url":"https://github.com/jimcarreer/hpack.git","svn_url":"https://github.com/jimcarreer/hpack","homepage":null,"size":2150,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"python-hyper:master","ref":"master","sha":"06143ae33805580c5e8d39ad2bcd2bc61a9e813b","user":{"login":"python-hyper","id":13035907,"avatar_url":"https://avatars.githubusercontent.com/u/13035907?v=3","gravatar_id":"","url":"https://api.github.com/users/python-hyper","html_url":"https://github.com/python-hyper","followers_url":"https://api.github.com/users/python-hyper/followers","following_url":"https://api.github.com/users/python-hyper/following{/other_user}","gists_url":"https://api.github.com/users/python-hyper/gists{/gist_id}","starred_url":"https://api.github.com/users/python-hyper/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/python-hyper/subscriptions","organizations_url":"https://api.github.com/users/python-hyper/orgs","repos_url":"https://api.github.com/users/python-hyper/repos","events_url":"https://api.github.com/users/python-hyper/events{/privacy}","received_events_url":"https://api.github.com/users/python-hyper/received_events","type":"Organization","site_admin":false},"repo":{"id":33873218,"name":"hpack","full_name":"python-hyper/hpack","owner":{"login":"python-hyper","id":13035907,"avatar_url":"https://avatars.githubusercontent.com/u/13035907?v=3","gravatar_id":"","url":"https://api.github.com/users/python-hyper","html_url":"https://github.com/python-hyper","followers_url":"https://api.github.com/users/python-hyper/followers","following_url":"https://api.github.com/users/python-hyper/following{/other_user}","gists_url":"https://api.github.com/users/python-hyper/gists{/gist_id}","starred_url":"https://api.github.com/users/python-hyper/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/python-hyper/subscriptions","organizations_url":"https://api.github.com/users/python-hyper/orgs","repos_url":"https://api.github.com/users/python-hyper/repos","events_url":"https://api.github.com/users/python-hyper/events{/privacy}","received_events_url":"https://api.github.com/users/python-hyper/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/python-hyper/hpack","description":"HTTP/2 Header Encoding for Python","fork":false,"url":"https://api.github.com/repos/python-hyper/hpack","forks_url":"https://api.github.com/repos/python-hyper/hpack/forks","keys_url":"https://api.github.com/repos/python-hyper/hpack/keys{/key_id}","collaborators_url":"https://api.github.com/repos/python-hyper/hpack/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/python-hyper/hpack/teams","hooks_url":"https://api.github.com/repos/python-hyper/hpack/hooks","issue_events_url":"https://api.github.com/repos/python-hyper/hpack/issues/events{/number}","events_url":"https://api.github.com/repos/python-hyper/hpack/events","assignees_url":"https://api.github.com/repos/python-hyper/hpack/assignees{/user}","branches_url":"https://api.github.com/repos/python-hyper/hpack/branches{/branch}","tags_url":"https://api.github.com/repos/python-hyper/hpack/tags","blobs_url":"https://api.github.com/repos/python-hyper/hpack/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/python-hyper/hpack/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/python-hyper/hpack/git/refs{/sha}","trees_url":"https://api.github.com/repos/python-hyper/hpack/git/trees{/sha}","statuses_url":"https://api.github.com/repos/python-hyper/hpack/statuses/{sha}","languages_url":"https://api.github.com/repos/python-hyper/hpack/languages","stargazers_url":"https://api.github.com/repos/python-hyper/hpack/stargazers","contributors_url":"https://api.github.com/repos/python-hyper/hpack/contributors","subscribers_url":"https://api.github.com/repos/python-hyper/hpack/subscribers","subscription_url":"https://api.github.com/repos/python-hyper/hpack/subscription","commits_url":"https://api.github.com/repos/python-hyper/hpack/commits{/sha}","git_commits_url":"https://api.github.com/repos/python-hyper/hpack/git/commits{/sha}","comments_url":"https://api.github.com/repos/python-hyper/hpack/comments{/number}","issue_comment_url":"https://api.github.com/repos/python-hyper/hpack/issues/comments{/number}","contents_url":"https://api.github.com/repos/python-hyper/hpack/contents/{+path}","compare_url":"https://api.github.com/repos/python-hyper/hpack/compare/{base}...{head}","merges_url":"https://api.github.com/repos/python-hyper/hpack/merges","archive_url":"https://api.github.com/repos/python-hyper/hpack/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/python-hyper/hpack/downloads","issues_url":"https://api.github.com/repos/python-hyper/hpack/issues{/number}","pulls_url":"https://api.github.com/repos/python-hyper/hpack/pulls{/number}","milestones_url":"https://api.github.com/repos/python-hyper/hpack/milestones{/number}","notifications_url":"https://api.github.com/repos/python-hyper/hpack/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/python-hyper/hpack/labels{/name}","releases_url":"https://api.github.com/repos/python-hyper/hpack/releases{/id}","created_at":"2015-04-13T14:26:18Z","updated_at":"2015-06-28T15:02:44Z","pushed_at":"2015-07-01T11:58:08Z","git_url":"git://github.com/python-hyper/hpack.git","ssh_url":"git@github.com:python-hyper/hpack.git","clone_url":"https://github.com/python-hyper/hpack.git","svn_url":"https://github.com/python-hyper/hpack","homepage":null,"size":2161,"stargazers_count":3,"watchers_count":3,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":3,"forks":2,"open_issues":3,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/python-hyper/hpack/pulls/5"},"html":{"href":"https://github.com/python-hyper/hpack/pull/5"},"issue":{"href":"https://api.github.com/repos/python-hyper/hpack/issues/5"},"comments":{"href":"https://api.github.com/repos/python-hyper/hpack/issues/5/comments"},"review_comments":{"href":"https://api.github.com/repos/python-hyper/hpack/pulls/5/comments"},"review_comment":{"href":"https://api.github.com/repos/python-hyper/hpack/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/python-hyper/hpack/pulls/5/commits"},"statuses":{"href":"https://api.github.com/repos/python-hyper/hpack/statuses/af8153b62e19a91cfff55e6e7ee210b7795e09a5"}}}}