{"action":"created","comment":{"url":"https://api.github.com/repos/dkotegov/seismograph/pulls/comments/89698304","pull_request_review_id":10237262,"id":89698304,"diff_hunk":"@@ -0,0 +1,180 @@\n+import sys\n+import unittest\n+\n+import mock\n+\n+from seismograph.exceptions import TimeoutException\n+from seismograph.utils import common\n+\n+START_TIME_STUB = 1000\n+END_TIME_STUB = 5000\n+RETURN_VALUE_STUB = 5\n+CUSTOM_EXCEPTION_STUB = ZeroDivisionError\n+TIMEOUT_STUB = 0.00001\n+DELAY_STUB = 1\n+CHAIN_LENGTH_STUB = 5\n+PATH_STUB = 'PATH_STUB'\n+LIST_OF_DICTS_STUB = [{'k1': 1, 'k2': 2}]\n+CORRECT_PATTERN_STUB = {'k1': 1, 'k2': 2}\n+INCORRECT_PATTERN_STUB = {'k1': 1, 'k2': 5}\n+\n+DICT1_STUB = {\n+    'list': [{'k1': {'k2': 5, 'k3': 7}}, {'k1': 1}],\n+    'dict': {'k1': {'k1': 5}, 'k2': {'k3': '1'}},\n+    'val': 5,\n+    'not_in_dict2': 1\n+}\n+DICT2_STUB = {\n+    'list': [{'k1': 5}, {'k3': '1'}],\n+    'dict': {'k1': {'k3': 5}},\n+    'val': 4\n+}\n+REDUCE_DICT_RESULT = {\n+    'list': [{}, {'k1': {'k2': 5, 'k3': 7}}],\n+    'dict': {'k1': {}},\n+    'val': 5\n+}\n+\n+LIST1_STUB = [\n+    [{'k1': {'k2': 5, 'k3': 7}}, {'k1': 1}],\n+    {'k1': {'k1': 5}, 'k2': {'k3': '1'}},\n+    5,\n+]\n+LIST2_STUB = [\n+    [{'k1': 5}, {'k3': '1'}],\n+    {'k1': {'k3': 5}},\n+    4\n+]\n+REDUCE_LIST_RESULT = [\n+    5,\n+    {'k1': {}},\n+    ([{}, {'k1': {'k3': 7, 'k2': 5}}], [{'k1': 5}, {'k3': '1'}]),\n+]\n+\n+\n+class CommonCase(unittest.TestCase):\n+    @mock.patch('seismograph.utils.common.time')\n+    def test_measure(self, mock_time):\n+        mock_time.time.return_value = START_TIME_STUB\n+        measure_func = common.measure_time()\n+        mock_time.time.return_value = END_TIME_STUB\n+        right_value = END_TIME_STUB - START_TIME_STUB\n+        self.assertEqual(measure_func(), right_value)\n+\n+    def test_call_to_chain(self):\n+        mock_func = mock.Mock()\n+        chain = CHAIN_LENGTH_STUB * [mock_func]\n+        common.call_to_chain(chain, None)\n+        self.assertEqual(mock_func.call_count, len(chain))\n+\n+    def test_call_to_chain_with_internal_func(self):\n+        mock_obj = mock.Mock()\n+        mock_obj.mock_func = mock.Mock()\n+        chain = CHAIN_LENGTH_STUB * [mock_obj]\n+        common.call_to_chain(chain, 'mock_func')\n+        self.assertEqual(mock_obj.mock_func.call_count, len(chain))\n+\n+    def test_get_dict_from_list(self):\n+        self.assertDictEqual(common.get_dict_from_list(LIST_OF_DICTS_STUB, **CORRECT_PATTERN_STUB),\n+                             CORRECT_PATTERN_STUB)\n+\n+    def test_get_dict_from_list_without_pattern(self):\n+        self.assertEqual(common.get_dict_from_list(LIST_OF_DICTS_STUB), LIST_OF_DICTS_STUB)\n+\n+    def test_get_fict_from_list_with_incorrect_pattern(self):\n+        self.assertRaises(LookupError, common.get_dict_from_list, LIST_OF_DICTS_STUB, **INCORRECT_PATTERN_STUB)\n+\n+\n+class DictReduceCase(unittest.TestCase):\n+    def setUp(self):\n+        self.dict1 = dict(DICT1_STUB)\n+\n+    def test_reduce_dict(self):\n+        self.assertDictEqual(common.reduce_dict(self.dict1, DICT2_STUB), REDUCE_DICT_RESULT)\n+\n+    def test_with_different_lists_length(self):\n+        self.assertRaises(AssertionError, common.reduce_dict, self.dict1, {'list': []})\n+\n+\n+class ListReduceCase(unittest.TestCase):\n+    def setUp(self):\n+        self.list2 = list(LIST2_STUB)\n+\n+    def test_first_return_value(self):\n+        result, _ = common.reduce_list(LIST1_STUB, self.list2)\n+        self.assertListEqual(result, REDUCE_LIST_RESULT)\n+\n+    def test_second_return_value(self):\n+        def deepsort(lst):\n+            result = list(lst)\n+            map(lambda l: deepsort(l) if isinstance(l, list) else l, result)\n+            result.sort()\n+            return result\n+\n+        expected_result = deepsort(self.list2)\n+        _, result = common.reduce_list(LIST1_STUB, self.list2)\n+        self.assertListEqual(result, expected_result)\n+\n+    def test_with_different_length(self):\n+        self.assertRaises(AssertionError, common.reduce_list, LIST1_STUB, [])\n+\n+\n+class PythonPathsCase(unittest.TestCase):\n+    def test_pythonpaths(self):\n+        common.pythonpaths(PATH_STUB)(lambda: 0)\n+        self.assertIn(PATH_STUB, sys.path)\n+\n+    def tearDown(self):\n+        sys.path.remove(PATH_STUB)\n+\n+\n+class WaitingForCase(unittest.TestCase):\n+    def setUp(self):\n+        self.mock_func = mock.Mock()\n+\n+    def test_without_timeout(self):\n+        self.mock_func.return_value = RETURN_VALUE_STUB\n+        self.assertEqual(common.waiting_for(self.mock_func), RETURN_VALUE_STUB)\n+\n+    def test_timeout_exception(self):\n+        self.mock_func.return_value = None\n+        self.assertRaises(TimeoutException, common.waiting_for, self.mock_func)\n+\n+    def test_custom_exception(self):\n+        self.mock_func.return_value = None\n+        self.assertRaises(\n+            CUSTOM_EXCEPTION_STUB,\n+            common.waiting_for,\n+            self.mock_func,\n+            exc_cls=CUSTOM_EXCEPTION_STUB\n+        )\n+\n+    def test_with_timout(self):\n+        self.mock_func.return_value = RETURN_VALUE_STUB\n+        self.assertEqual(common.waiting_for(self.mock_func, TIMEOUT_STUB), RETURN_VALUE_STUB)\n+\n+    def test_timeout_exception_with_timeout(self):\n+        self.mock_func.return_value = None\n+        self.assertRaises(TimeoutException, common.waiting_for, self.mock_func, TIMEOUT_STUB)\n+\n+    def test_custom_exception_with_timeout(self):\n+        self.mock_func.return_value = None\n+        self.assertRaises(\n+            CUSTOM_EXCEPTION_STUB,\n+            common.waiting_for,\n+            self.mock_func,\n+            TIMEOUT_STUB,\n+            CUSTOM_EXCEPTION_STUB\n+        )\n+\n+    @mock.patch('seismograph.utils.common.time.sleep')\n+    def test_delay_works(self, mock_sleep):\n+        self.mock_func.return_value = None\n+        try:\n+            common.waiting_for(self.mock_func, TIMEOUT_STUB, delay=DELAY_STUB)\n+        except:","path":"tests/utils_test/test_common.py","position":175,"original_position":175,"commit_id":"3988901f80d51837d03c2c532ad90240d685e540","original_commit_id":"3988901f80d51837d03c2c532ad90240d685e540","user":{"login":"dkotegov","id":11413412,"avatar_url":"https://avatars.githubusercontent.com/u/11413412?v=3","gravatar_id":"","url":"https://api.github.com/users/dkotegov","html_url":"https://github.com/dkotegov","followers_url":"https://api.github.com/users/dkotegov/followers","following_url":"https://api.github.com/users/dkotegov/following{/other_user}","gists_url":"https://api.github.com/users/dkotegov/gists{/gist_id}","starred_url":"https://api.github.com/users/dkotegov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dkotegov/subscriptions","organizations_url":"https://api.github.com/users/dkotegov/orgs","repos_url":"https://api.github.com/users/dkotegov/repos","events_url":"https://api.github.com/users/dkotegov/events{/privacy}","received_events_url":"https://api.github.com/users/dkotegov/received_events","type":"User","site_admin":false},"body":"Плохо перехватывать всё","created_at":"2016-11-27T20:12:21Z","updated_at":"2016-11-27T20:29:40Z","html_url":"https://github.com/dkotegov/seismograph/pull/5#discussion_r89698304","pull_request_url":"https://api.github.com/repos/dkotegov/seismograph/pulls/5","_links":{"self":{"href":"https://api.github.com/repos/dkotegov/seismograph/pulls/comments/89698304"},"html":{"href":"https://github.com/dkotegov/seismograph/pull/5#discussion_r89698304"},"pull_request":{"href":"https://api.github.com/repos/dkotegov/seismograph/pulls/5"}}},"pull_request":{"url":"https://api.github.com/repos/dkotegov/seismograph/pulls/5","id":95402124,"html_url":"https://github.com/dkotegov/seismograph/pull/5","diff_url":"https://github.com/dkotegov/seismograph/pull/5.diff","patch_url":"https://github.com/dkotegov/seismograph/pull/5.patch","issue_url":"https://api.github.com/repos/dkotegov/seismograph/issues/5","number":5,"state":"open","locked":false,"title":"Команда undefined. ","user":{"login":"Vertaler","id":15687604,"avatar_url":"https://avatars.githubusercontent.com/u/15687604?v=3","gravatar_id":"","url":"https://api.github.com/users/Vertaler","html_url":"https://github.com/Vertaler","followers_url":"https://api.github.com/users/Vertaler/followers","following_url":"https://api.github.com/users/Vertaler/following{/other_user}","gists_url":"https://api.github.com/users/Vertaler/gists{/gist_id}","starred_url":"https://api.github.com/users/Vertaler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Vertaler/subscriptions","organizations_url":"https://api.github.com/users/Vertaler/orgs","repos_url":"https://api.github.com/users/Vertaler/repos","events_url":"https://api.github.com/users/Vertaler/events{/privacy}","received_events_url":"https://api.github.com/users/Vertaler/received_events","type":"User","site_admin":false},"body":"Тесты на utils/*","created_at":"2016-11-27T13:02:22Z","updated_at":"2016-11-27T20:29:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"93915f127256ae77e516cbed4a48d252448047f7","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/dkotegov/seismograph/pulls/5/commits","review_comments_url":"https://api.github.com/repos/dkotegov/seismograph/pulls/5/comments","review_comment_url":"https://api.github.com/repos/dkotegov/seismograph/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dkotegov/seismograph/issues/5/comments","statuses_url":"https://api.github.com/repos/dkotegov/seismograph/statuses/3988901f80d51837d03c2c532ad90240d685e540","head":{"label":"Vertaler:master","ref":"master","sha":"3988901f80d51837d03c2c532ad90240d685e540","user":{"login":"Vertaler","id":15687604,"avatar_url":"https://avatars.githubusercontent.com/u/15687604?v=3","gravatar_id":"","url":"https://api.github.com/users/Vertaler","html_url":"https://github.com/Vertaler","followers_url":"https://api.github.com/users/Vertaler/followers","following_url":"https://api.github.com/users/Vertaler/following{/other_user}","gists_url":"https://api.github.com/users/Vertaler/gists{/gist_id}","starred_url":"https://api.github.com/users/Vertaler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Vertaler/subscriptions","organizations_url":"https://api.github.com/users/Vertaler/orgs","repos_url":"https://api.github.com/users/Vertaler/repos","events_url":"https://api.github.com/users/Vertaler/events{/privacy}","received_events_url":"https://api.github.com/users/Vertaler/received_events","type":"User","site_admin":false},"repo":{"id":74061084,"name":"seismograph","full_name":"Vertaler/seismograph","owner":{"login":"Vertaler","id":15687604,"avatar_url":"https://avatars.githubusercontent.com/u/15687604?v=3","gravatar_id":"","url":"https://api.github.com/users/Vertaler","html_url":"https://github.com/Vertaler","followers_url":"https://api.github.com/users/Vertaler/followers","following_url":"https://api.github.com/users/Vertaler/following{/other_user}","gists_url":"https://api.github.com/users/Vertaler/gists{/gist_id}","starred_url":"https://api.github.com/users/Vertaler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Vertaler/subscriptions","organizations_url":"https://api.github.com/users/Vertaler/orgs","repos_url":"https://api.github.com/users/Vertaler/repos","events_url":"https://api.github.com/users/Vertaler/events{/privacy}","received_events_url":"https://api.github.com/users/Vertaler/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Vertaler/seismograph","description":"framework for test development","fork":true,"url":"https://api.github.com/repos/Vertaler/seismograph","forks_url":"https://api.github.com/repos/Vertaler/seismograph/forks","keys_url":"https://api.github.com/repos/Vertaler/seismograph/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Vertaler/seismograph/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Vertaler/seismograph/teams","hooks_url":"https://api.github.com/repos/Vertaler/seismograph/hooks","issue_events_url":"https://api.github.com/repos/Vertaler/seismograph/issues/events{/number}","events_url":"https://api.github.com/repos/Vertaler/seismograph/events","assignees_url":"https://api.github.com/repos/Vertaler/seismograph/assignees{/user}","branches_url":"https://api.github.com/repos/Vertaler/seismograph/branches{/branch}","tags_url":"https://api.github.com/repos/Vertaler/seismograph/tags","blobs_url":"https://api.github.com/repos/Vertaler/seismograph/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Vertaler/seismograph/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Vertaler/seismograph/git/refs{/sha}","trees_url":"https://api.github.com/repos/Vertaler/seismograph/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Vertaler/seismograph/statuses/{sha}","languages_url":"https://api.github.com/repos/Vertaler/seismograph/languages","stargazers_url":"https://api.github.com/repos/Vertaler/seismograph/stargazers","contributors_url":"https://api.github.com/repos/Vertaler/seismograph/contributors","subscribers_url":"https://api.github.com/repos/Vertaler/seismograph/subscribers","subscription_url":"https://api.github.com/repos/Vertaler/seismograph/subscription","commits_url":"https://api.github.com/repos/Vertaler/seismograph/commits{/sha}","git_commits_url":"https://api.github.com/repos/Vertaler/seismograph/git/commits{/sha}","comments_url":"https://api.github.com/repos/Vertaler/seismograph/comments{/number}","issue_comment_url":"https://api.github.com/repos/Vertaler/seismograph/issues/comments{/number}","contents_url":"https://api.github.com/repos/Vertaler/seismograph/contents/{+path}","compare_url":"https://api.github.com/repos/Vertaler/seismograph/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Vertaler/seismograph/merges","archive_url":"https://api.github.com/repos/Vertaler/seismograph/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Vertaler/seismograph/downloads","issues_url":"https://api.github.com/repos/Vertaler/seismograph/issues{/number}","pulls_url":"https://api.github.com/repos/Vertaler/seismograph/pulls{/number}","milestones_url":"https://api.github.com/repos/Vertaler/seismograph/milestones{/number}","notifications_url":"https://api.github.com/repos/Vertaler/seismograph/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Vertaler/seismograph/labels{/name}","releases_url":"https://api.github.com/repos/Vertaler/seismograph/releases{/id}","deployments_url":"https://api.github.com/repos/Vertaler/seismograph/deployments","created_at":"2016-11-17T19:40:22Z","updated_at":"2016-11-17T19:40:24Z","pushed_at":"2016-11-27T14:07:19Z","git_url":"git://github.com/Vertaler/seismograph.git","ssh_url":"git@github.com:Vertaler/seismograph.git","clone_url":"https://github.com/Vertaler/seismograph.git","svn_url":"https://github.com/Vertaler/seismograph","homepage":null,"size":456,"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":"dkotegov:master","ref":"master","sha":"e4ea4480fb759041f61f1d9124390c4c4ca83b8d","user":{"login":"dkotegov","id":11413412,"avatar_url":"https://avatars.githubusercontent.com/u/11413412?v=3","gravatar_id":"","url":"https://api.github.com/users/dkotegov","html_url":"https://github.com/dkotegov","followers_url":"https://api.github.com/users/dkotegov/followers","following_url":"https://api.github.com/users/dkotegov/following{/other_user}","gists_url":"https://api.github.com/users/dkotegov/gists{/gist_id}","starred_url":"https://api.github.com/users/dkotegov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dkotegov/subscriptions","organizations_url":"https://api.github.com/users/dkotegov/orgs","repos_url":"https://api.github.com/users/dkotegov/repos","events_url":"https://api.github.com/users/dkotegov/events{/privacy}","received_events_url":"https://api.github.com/users/dkotegov/received_events","type":"User","site_admin":false},"repo":{"id":73647093,"name":"seismograph","full_name":"dkotegov/seismograph","owner":{"login":"dkotegov","id":11413412,"avatar_url":"https://avatars.githubusercontent.com/u/11413412?v=3","gravatar_id":"","url":"https://api.github.com/users/dkotegov","html_url":"https://github.com/dkotegov","followers_url":"https://api.github.com/users/dkotegov/followers","following_url":"https://api.github.com/users/dkotegov/following{/other_user}","gists_url":"https://api.github.com/users/dkotegov/gists{/gist_id}","starred_url":"https://api.github.com/users/dkotegov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dkotegov/subscriptions","organizations_url":"https://api.github.com/users/dkotegov/orgs","repos_url":"https://api.github.com/users/dkotegov/repos","events_url":"https://api.github.com/users/dkotegov/events{/privacy}","received_events_url":"https://api.github.com/users/dkotegov/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dkotegov/seismograph","description":"framework for test development","fork":true,"url":"https://api.github.com/repos/dkotegov/seismograph","forks_url":"https://api.github.com/repos/dkotegov/seismograph/forks","keys_url":"https://api.github.com/repos/dkotegov/seismograph/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dkotegov/seismograph/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dkotegov/seismograph/teams","hooks_url":"https://api.github.com/repos/dkotegov/seismograph/hooks","issue_events_url":"https://api.github.com/repos/dkotegov/seismograph/issues/events{/number}","events_url":"https://api.github.com/repos/dkotegov/seismograph/events","assignees_url":"https://api.github.com/repos/dkotegov/seismograph/assignees{/user}","branches_url":"https://api.github.com/repos/dkotegov/seismograph/branches{/branch}","tags_url":"https://api.github.com/repos/dkotegov/seismograph/tags","blobs_url":"https://api.github.com/repos/dkotegov/seismograph/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dkotegov/seismograph/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dkotegov/seismograph/git/refs{/sha}","trees_url":"https://api.github.com/repos/dkotegov/seismograph/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dkotegov/seismograph/statuses/{sha}","languages_url":"https://api.github.com/repos/dkotegov/seismograph/languages","stargazers_url":"https://api.github.com/repos/dkotegov/seismograph/stargazers","contributors_url":"https://api.github.com/repos/dkotegov/seismograph/contributors","subscribers_url":"https://api.github.com/repos/dkotegov/seismograph/subscribers","subscription_url":"https://api.github.com/repos/dkotegov/seismograph/subscription","commits_url":"https://api.github.com/repos/dkotegov/seismograph/commits{/sha}","git_commits_url":"https://api.github.com/repos/dkotegov/seismograph/git/commits{/sha}","comments_url":"https://api.github.com/repos/dkotegov/seismograph/comments{/number}","issue_comment_url":"https://api.github.com/repos/dkotegov/seismograph/issues/comments{/number}","contents_url":"https://api.github.com/repos/dkotegov/seismograph/contents/{+path}","compare_url":"https://api.github.com/repos/dkotegov/seismograph/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dkotegov/seismograph/merges","archive_url":"https://api.github.com/repos/dkotegov/seismograph/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dkotegov/seismograph/downloads","issues_url":"https://api.github.com/repos/dkotegov/seismograph/issues{/number}","pulls_url":"https://api.github.com/repos/dkotegov/seismograph/pulls{/number}","milestones_url":"https://api.github.com/repos/dkotegov/seismograph/milestones{/number}","notifications_url":"https://api.github.com/repos/dkotegov/seismograph/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dkotegov/seismograph/labels{/name}","releases_url":"https://api.github.com/repos/dkotegov/seismograph/releases{/id}","deployments_url":"https://api.github.com/repos/dkotegov/seismograph/deployments","created_at":"2016-11-13T22:28:57Z","updated_at":"2016-11-13T22:28:58Z","pushed_at":"2016-11-27T17:27:22Z","git_url":"git://github.com/dkotegov/seismograph.git","ssh_url":"git@github.com:dkotegov/seismograph.git","clone_url":"https://github.com/dkotegov/seismograph.git","svn_url":"https://github.com/dkotegov/seismograph","homepage":null,"size":399,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":15,"mirror_url":null,"open_issues_count":6,"forks":15,"open_issues":6,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dkotegov/seismograph/pulls/5"},"html":{"href":"https://github.com/dkotegov/seismograph/pull/5"},"issue":{"href":"https://api.github.com/repos/dkotegov/seismograph/issues/5"},"comments":{"href":"https://api.github.com/repos/dkotegov/seismograph/issues/5/comments"},"review_comments":{"href":"https://api.github.com/repos/dkotegov/seismograph/pulls/5/comments"},"review_comment":{"href":"https://api.github.com/repos/dkotegov/seismograph/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dkotegov/seismograph/pulls/5/commits"},"statuses":{"href":"https://api.github.com/repos/dkotegov/seismograph/statuses/3988901f80d51837d03c2c532ad90240d685e540"}}}}
{"actor":{"display_login":"dkotegov"}}