{"action":"created","comment":{"url":"https://api.github.com/repos/bm5w/network_tools/pulls/comments/24786225","id":24786225,"diff_hunk":"@@ -1,31 +1,103 @@\n # -*- coding: utf-8 -*-\n-import subprocess\n+from echo_client import client\n \n \n-def test_basic(string=u\"This is a test.\"):\n-    \"\"\"Test function to test echo server and client with inputted string.\"\"\"\n-    process = subprocess.Popen(['./echo_client.py', string],\n-                               stdout=subprocess.PIPE)\n-    assert string == process.stdout.readline().rstrip()\n+# def test_basic(string=u\"This is a test.\"):\n+#     \"\"\"Test function to test echo server and client with inputted string.\"\"\"\n+#     process = subprocess.Popen(['./echo_client.py', string],\n+#                                stdout=subprocess.PIPE)\n+#     assert string == process.stdout.readline().rstrip()\n \n \n-def test_exact32():\n-    \"\"\"Test echo server and client with string length 32, the buffer size.\"\"\"\n-    test_basic(u\"12345678901234567890123456789012\")\n+# def test_exact32():\n+#     \"\"\"Test echo server and client with string length 32, the buffer size.\"\"\"\n+#     test_basic(u\"12345678901234567890123456789012\")\n \n \n-def test_unicode():\n-    \"\"\"Test that server and client handle encoding and decoding of unicode.\"\"\"\n-    inp = u'Testing «ταБЬℓσ»: 1<2 & 4+1>3, now 20 off!'\n-    inp = inp.encode('utf-8')\n-    process = subprocess.Popen(['./echo_client.py', inp],\n-                               stdout=subprocess.PIPE)\n-    assert inp == process.stdout.readline().rstrip()\n+# def test_unicode():\n+#     \"\"\"Test that server and client handle encoding and decoding of unicode.\"\"\"\n+#     inp = u'Testing «ταБЬℓσ»: 1<2 & 4+1>3, now 20 off!'\n+#     inp = inp.encode('utf-8')\n+#     process = subprocess.Popen(['./echo_client.py', inp],\n+#                                stdout=subprocess.PIPE)\n+#     assert inp == process.stdout.readline().rstrip()\n \n \n-def test_long():\n-    \"\"\"Test server and client can handle long messages.\"\"\"\n-    test_basic(u\"Running the server script in one terminal should allow you to \\\n-        run the client script in a separate terminal. The client script should\\\n-         take an argument which is the message to send.  Upon completing, the \\\n-         response from the server should be printed to stdout.\")\n+# def test_long():\n+#     \"\"\"Test server and client can handle long messages.\"\"\"\n+#     test_basic(u\"Running the server script in one terminal should allow you to \\\n+#         run the client script in a separate terminal. The client script should\\\n+#          take an argument which is the message to send.  Upon completing, the \\\n+#          response from the server should be printed to stdout.\")\n+\n+\n+def test_response_ok():\n+    \"\"\"Test that function returns appropriate byte string.\"\"\"\n+    from echo_server import response_ok\n+    assert response_ok() == \\\n+        'HTTP/1.1 200 OK\\r\\nContent-Type: text/plain\\r\\nContent-length: 18\\r\\n\\r\\neverything is okay'\n+\n+\n+def test_response_error():\n+    \"\"\"Test that function returns appropriate byte string.\"\"\"\n+    from echo_server import response_error\n+    assert response_error(404, 'Not Found') == 'HTTP/1.1 404 Not Found\\r\\nContent-Type: text/plain\\r\\nContent-length: 18\\r\\n\\r\\nNot Found'\n+\n+\n+def test_simple_parse_request():\n+    \"\"\"Test that function returns appropriate URI.\"\"\"\n+    from echo_server import parse_request\n+    assert parse_request('GET /path/to/index.html HTTP/1.1\\r\\nHost: www.host1.com:80\\r\\n\\r\\n') == \\\n+        '/path/to/index.html'\n+\n+\n+def test_put_parse_request():\n+    \"\"\"Test that function returns error when PUT method requested.\"\"\"\n+    from echo_server import parse_request\n+    assert parse_request('PUT /path/to/index.html HTTP/1.1\\r\\nHost: www.host1.com:80\\r\\n') == \\\n+        'HTTP/1.1 405 Method Not Allowed\\r\\nContent-Type: text/plain\\r\\nContent-length: 18\\r\\n\\r\\nMethod Not Allowed'\n+\n+\n+def test_HTTP10_parse_request():\n+    \"\"\"Test that function returns error on HTTP/1.0 request.\"\"\"\n+    from echo_server import parse_request\n+    assert parse_request('GET /path/to/index.html HTTP/1.0\\r\\nHost: www.host1.com:80\\r\\n') == \\\n+        'HTTP/1.1 505 HTTP Version Not Supported\\r\\nContent-Type: text/plain\\r\\nContent-length: 18\\r\\n\\r\\nHTTP Version Not Supported'\n+\n+\n+def test_HTTP20_parse_request():\n+    \"\"\"Test that function returns error on HTTP/2.0 request.\"\"\"\n+    from echo_server import parse_request\n+    assert parse_request('GET /path/to/index.html HTTP/2.0\\r\\nHost: www.host1.com:80\\r\\n') == \\\n+        'HTTP/1.1 505 HTTP Version Not Supported\\r\\nContent-Type: text/plain\\r\\nContent-length: 18\\r\\n\\r\\nHTTP Version Not Supported'\n+\n+\n+def test_server():\n+    \"\"\"In response to incoming request, server responds with 200 ok message.\"\"\"\n+    from echo_server import response_ok\n+    assert client('GET /path/to/index.html HTTP/1.1\\r\\nHost: www.host1.com:80\\r\\n\\r\\n') == response_ok()\n+\n+\n+def test_server_505():\n+    \"\"\"In response to HTTP20 request, server responds with error.\"\"\"\n+    assert client('GET /path/to/index.html HTTP/2.0\\r\\nnHost: www.host1.com:80\\r\\n\\r\\n') == \\\n+        'HTTP/1.1 505 HTTP Version Not Supported\\r\\nContent-Type: text/plain\\r\\nContent-length: 18\\r\\n\\r\\nHTTP Version Not Supported'\n+\n+\n+def test_server_405():\n+    \"\"\"In response to HTTP20 request, server responds with error.\"\"\"\n+    assert client('PUT /path/to/index.html HTTP/1.1\\r\\nHost: www.host1.com:80\\r\\n\\r\\n') == \\\n+        'HTTP/1.1 405 Method Not Allowed\\r\\nContent-Type: text/plain\\r\\nContent-length: 18\\r\\n\\r\\nMethod Not Allowed'\n+\n+\n+def test_server_505_2():\n+    \"\"\"In response to HTTP20 SET request, server responds with error.\"\"\"\n+    assert client('SET /path/to/index.html HTTP/2.0\\r\\nHost: www.host1.com:80\\r\\n\\r\\n') == \\\n+        'HTTP/1.1 505 HTTP Version Not Supported\\r\\nContent-Type: text/plain\\r\\nContent-length: 18\\r\\n\\r\\nHTTP Version Not Supported'","path":"test_echo.py","position":118,"original_position":118,"commit_id":"6022a06d1ec68f2ed0c8cdc8cd52dbaa195f3a98","original_commit_id":"6022a06d1ec68f2ed0c8cdc8cd52dbaa195f3a98","user":{"login":"cewing","id":417109,"avatar_url":"https://avatars.githubusercontent.com/u/417109?v=3","gravatar_id":"","url":"https://api.github.com/users/cewing","html_url":"https://github.com/cewing","followers_url":"https://api.github.com/users/cewing/followers","following_url":"https://api.github.com/users/cewing/following{/other_user}","gists_url":"https://api.github.com/users/cewing/gists{/gist_id}","starred_url":"https://api.github.com/users/cewing/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cewing/subscriptions","organizations_url":"https://api.github.com/users/cewing/orgs","repos_url":"https://api.github.com/users/cewing/repos","events_url":"https://api.github.com/users/cewing/events{/privacy}","received_events_url":"https://api.github.com/users/cewing/received_events","type":"User","site_admin":false},"body":"A reasonable selection of tests, both functional and unit.  Lines of code are ridiculously over-long.  How can you cut down the length while still testing the same things (or better things, even).","created_at":"2015-02-17T01:07:32Z","updated_at":"2015-02-17T01:07:32Z","html_url":"https://github.com/bm5w/network_tools/pull/2#discussion_r24786225","pull_request_url":"https://api.github.com/repos/bm5w/network_tools/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/bm5w/network_tools/pulls/comments/24786225"},"html":{"href":"https://github.com/bm5w/network_tools/pull/2#discussion_r24786225"},"pull_request":{"href":"https://api.github.com/repos/bm5w/network_tools/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/bm5w/network_tools/pulls/2","id":29069436,"html_url":"https://github.com/bm5w/network_tools/pull/2","diff_url":"https://github.com/bm5w/network_tools/pull/2.diff","patch_url":"https://github.com/bm5w/network_tools/pull/2.patch","issue_url":"https://api.github.com/repos/bm5w/network_tools/issues/2","number":2,"state":"closed","locked":false,"title":"Http1","user":{"login":"bm5w","id":8129937,"avatar_url":"https://avatars.githubusercontent.com/u/8129937?v=3","gravatar_id":"","url":"https://api.github.com/users/bm5w","html_url":"https://github.com/bm5w","followers_url":"https://api.github.com/users/bm5w/followers","following_url":"https://api.github.com/users/bm5w/following{/other_user}","gists_url":"https://api.github.com/users/bm5w/gists{/gist_id}","starred_url":"https://api.github.com/users/bm5w/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bm5w/subscriptions","organizations_url":"https://api.github.com/users/bm5w/orgs","repos_url":"https://api.github.com/users/bm5w/repos","events_url":"https://api.github.com/users/bm5w/events{/privacy}","received_events_url":"https://api.github.com/users/bm5w/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-02-11T05:40:06Z","updated_at":"2015-02-17T01:07:32Z","closed_at":"2015-02-13T01:46:52Z","merged_at":"2015-02-13T01:46:52Z","merge_commit_sha":"d9154744d49e3d5213099dbc9522076676b09610","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/bm5w/network_tools/pulls/2/commits","review_comments_url":"https://api.github.com/repos/bm5w/network_tools/pulls/2/comments","review_comment_url":"https://api.github.com/repos/bm5w/network_tools/pulls/comments/{number}","comments_url":"https://api.github.com/repos/bm5w/network_tools/issues/2/comments","statuses_url":"https://api.github.com/repos/bm5w/network_tools/statuses/6022a06d1ec68f2ed0c8cdc8cd52dbaa195f3a98","head":{"label":"bm5w:http1","ref":"http1","sha":"6022a06d1ec68f2ed0c8cdc8cd52dbaa195f3a98","user":{"login":"bm5w","id":8129937,"avatar_url":"https://avatars.githubusercontent.com/u/8129937?v=3","gravatar_id":"","url":"https://api.github.com/users/bm5w","html_url":"https://github.com/bm5w","followers_url":"https://api.github.com/users/bm5w/followers","following_url":"https://api.github.com/users/bm5w/following{/other_user}","gists_url":"https://api.github.com/users/bm5w/gists{/gist_id}","starred_url":"https://api.github.com/users/bm5w/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bm5w/subscriptions","organizations_url":"https://api.github.com/users/bm5w/orgs","repos_url":"https://api.github.com/users/bm5w/repos","events_url":"https://api.github.com/users/bm5w/events{/privacy}","received_events_url":"https://api.github.com/users/bm5w/received_events","type":"User","site_admin":false},"repo":{"id":30571025,"name":"network_tools","full_name":"bm5w/network_tools","owner":{"login":"bm5w","id":8129937,"avatar_url":"https://avatars.githubusercontent.com/u/8129937?v=3","gravatar_id":"","url":"https://api.github.com/users/bm5w","html_url":"https://github.com/bm5w","followers_url":"https://api.github.com/users/bm5w/followers","following_url":"https://api.github.com/users/bm5w/following{/other_user}","gists_url":"https://api.github.com/users/bm5w/gists{/gist_id}","starred_url":"https://api.github.com/users/bm5w/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bm5w/subscriptions","organizations_url":"https://api.github.com/users/bm5w/orgs","repos_url":"https://api.github.com/users/bm5w/repos","events_url":"https://api.github.com/users/bm5w/events{/privacy}","received_events_url":"https://api.github.com/users/bm5w/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bm5w/network_tools","description":"","fork":false,"url":"https://api.github.com/repos/bm5w/network_tools","forks_url":"https://api.github.com/repos/bm5w/network_tools/forks","keys_url":"https://api.github.com/repos/bm5w/network_tools/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bm5w/network_tools/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bm5w/network_tools/teams","hooks_url":"https://api.github.com/repos/bm5w/network_tools/hooks","issue_events_url":"https://api.github.com/repos/bm5w/network_tools/issues/events{/number}","events_url":"https://api.github.com/repos/bm5w/network_tools/events","assignees_url":"https://api.github.com/repos/bm5w/network_tools/assignees{/user}","branches_url":"https://api.github.com/repos/bm5w/network_tools/branches{/branch}","tags_url":"https://api.github.com/repos/bm5w/network_tools/tags","blobs_url":"https://api.github.com/repos/bm5w/network_tools/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bm5w/network_tools/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bm5w/network_tools/git/refs{/sha}","trees_url":"https://api.github.com/repos/bm5w/network_tools/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bm5w/network_tools/statuses/{sha}","languages_url":"https://api.github.com/repos/bm5w/network_tools/languages","stargazers_url":"https://api.github.com/repos/bm5w/network_tools/stargazers","contributors_url":"https://api.github.com/repos/bm5w/network_tools/contributors","subscribers_url":"https://api.github.com/repos/bm5w/network_tools/subscribers","subscription_url":"https://api.github.com/repos/bm5w/network_tools/subscription","commits_url":"https://api.github.com/repos/bm5w/network_tools/commits{/sha}","git_commits_url":"https://api.github.com/repos/bm5w/network_tools/git/commits{/sha}","comments_url":"https://api.github.com/repos/bm5w/network_tools/comments{/number}","issue_comment_url":"https://api.github.com/repos/bm5w/network_tools/issues/comments/{number}","contents_url":"https://api.github.com/repos/bm5w/network_tools/contents/{+path}","compare_url":"https://api.github.com/repos/bm5w/network_tools/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bm5w/network_tools/merges","archive_url":"https://api.github.com/repos/bm5w/network_tools/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bm5w/network_tools/downloads","issues_url":"https://api.github.com/repos/bm5w/network_tools/issues{/number}","pulls_url":"https://api.github.com/repos/bm5w/network_tools/pulls{/number}","milestones_url":"https://api.github.com/repos/bm5w/network_tools/milestones{/number}","notifications_url":"https://api.github.com/repos/bm5w/network_tools/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bm5w/network_tools/labels{/name}","releases_url":"https://api.github.com/repos/bm5w/network_tools/releases{/id}","created_at":"2015-02-10T02:37:29Z","updated_at":"2015-02-13T01:46:52Z","pushed_at":"2015-02-14T00:25:48Z","git_url":"git://github.com/bm5w/network_tools.git","ssh_url":"git@github.com:bm5w/network_tools.git","clone_url":"https://github.com/bm5w/network_tools.git","svn_url":"https://github.com/bm5w/network_tools","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"bm5w:master","ref":"master","sha":"2e776aa6c64fac55c8824dd703f91e7f14d63a35","user":{"login":"bm5w","id":8129937,"avatar_url":"https://avatars.githubusercontent.com/u/8129937?v=3","gravatar_id":"","url":"https://api.github.com/users/bm5w","html_url":"https://github.com/bm5w","followers_url":"https://api.github.com/users/bm5w/followers","following_url":"https://api.github.com/users/bm5w/following{/other_user}","gists_url":"https://api.github.com/users/bm5w/gists{/gist_id}","starred_url":"https://api.github.com/users/bm5w/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bm5w/subscriptions","organizations_url":"https://api.github.com/users/bm5w/orgs","repos_url":"https://api.github.com/users/bm5w/repos","events_url":"https://api.github.com/users/bm5w/events{/privacy}","received_events_url":"https://api.github.com/users/bm5w/received_events","type":"User","site_admin":false},"repo":{"id":30571025,"name":"network_tools","full_name":"bm5w/network_tools","owner":{"login":"bm5w","id":8129937,"avatar_url":"https://avatars.githubusercontent.com/u/8129937?v=3","gravatar_id":"","url":"https://api.github.com/users/bm5w","html_url":"https://github.com/bm5w","followers_url":"https://api.github.com/users/bm5w/followers","following_url":"https://api.github.com/users/bm5w/following{/other_user}","gists_url":"https://api.github.com/users/bm5w/gists{/gist_id}","starred_url":"https://api.github.com/users/bm5w/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bm5w/subscriptions","organizations_url":"https://api.github.com/users/bm5w/orgs","repos_url":"https://api.github.com/users/bm5w/repos","events_url":"https://api.github.com/users/bm5w/events{/privacy}","received_events_url":"https://api.github.com/users/bm5w/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bm5w/network_tools","description":"","fork":false,"url":"https://api.github.com/repos/bm5w/network_tools","forks_url":"https://api.github.com/repos/bm5w/network_tools/forks","keys_url":"https://api.github.com/repos/bm5w/network_tools/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bm5w/network_tools/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bm5w/network_tools/teams","hooks_url":"https://api.github.com/repos/bm5w/network_tools/hooks","issue_events_url":"https://api.github.com/repos/bm5w/network_tools/issues/events{/number}","events_url":"https://api.github.com/repos/bm5w/network_tools/events","assignees_url":"https://api.github.com/repos/bm5w/network_tools/assignees{/user}","branches_url":"https://api.github.com/repos/bm5w/network_tools/branches{/branch}","tags_url":"https://api.github.com/repos/bm5w/network_tools/tags","blobs_url":"https://api.github.com/repos/bm5w/network_tools/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bm5w/network_tools/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bm5w/network_tools/git/refs{/sha}","trees_url":"https://api.github.com/repos/bm5w/network_tools/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bm5w/network_tools/statuses/{sha}","languages_url":"https://api.github.com/repos/bm5w/network_tools/languages","stargazers_url":"https://api.github.com/repos/bm5w/network_tools/stargazers","contributors_url":"https://api.github.com/repos/bm5w/network_tools/contributors","subscribers_url":"https://api.github.com/repos/bm5w/network_tools/subscribers","subscription_url":"https://api.github.com/repos/bm5w/network_tools/subscription","commits_url":"https://api.github.com/repos/bm5w/network_tools/commits{/sha}","git_commits_url":"https://api.github.com/repos/bm5w/network_tools/git/commits{/sha}","comments_url":"https://api.github.com/repos/bm5w/network_tools/comments{/number}","issue_comment_url":"https://api.github.com/repos/bm5w/network_tools/issues/comments/{number}","contents_url":"https://api.github.com/repos/bm5w/network_tools/contents/{+path}","compare_url":"https://api.github.com/repos/bm5w/network_tools/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bm5w/network_tools/merges","archive_url":"https://api.github.com/repos/bm5w/network_tools/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bm5w/network_tools/downloads","issues_url":"https://api.github.com/repos/bm5w/network_tools/issues{/number}","pulls_url":"https://api.github.com/repos/bm5w/network_tools/pulls{/number}","milestones_url":"https://api.github.com/repos/bm5w/network_tools/milestones{/number}","notifications_url":"https://api.github.com/repos/bm5w/network_tools/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bm5w/network_tools/labels{/name}","releases_url":"https://api.github.com/repos/bm5w/network_tools/releases{/id}","created_at":"2015-02-10T02:37:29Z","updated_at":"2015-02-13T01:46:52Z","pushed_at":"2015-02-14T00:25:48Z","git_url":"git://github.com/bm5w/network_tools.git","ssh_url":"git@github.com:bm5w/network_tools.git","clone_url":"https://github.com/bm5w/network_tools.git","svn_url":"https://github.com/bm5w/network_tools","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bm5w/network_tools/pulls/2"},"html":{"href":"https://github.com/bm5w/network_tools/pull/2"},"issue":{"href":"https://api.github.com/repos/bm5w/network_tools/issues/2"},"comments":{"href":"https://api.github.com/repos/bm5w/network_tools/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/bm5w/network_tools/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/bm5w/network_tools/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/bm5w/network_tools/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/bm5w/network_tools/statuses/6022a06d1ec68f2ed0c8cdc8cd52dbaa195f3a98"}}}}