{"action":"created","comment":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/comments/32474090","id":32474090,"diff_hunk":"@@ -0,0 +1,230 @@\n+\"\"\"\n+Test cases for Call Stack Manager\n+\"\"\"\n+from mock import patch\n+# from .models import ModelMixin, ModelNothing, ModelMixinCSM, ModelAnotherCSM, ModelWithCSM, ModelWithCSMChild\n+from django.test import TestCase\n+from openedx.core.djangoapps.call_stack_manager import donottrack\n+from django.db import models\n+from openedx.core.djangoapps.call_stack_manager import CallStackManager, CallStackMixin\n+\n+\n+class ModelMixinCSM(CallStackMixin, models.Model):\n+    \"\"\"\n+    Test Model class which uses both CallStackManager, and CallStackMixin\n+    \"\"\"\n+    # override Manager objects\n+    objects = CallStackManager()\n+    id_field = models.IntegerField()\n+\n+\n+class ModelMixin(CallStackMixin, models.Model):\n+    \"\"\"\n+    Test Model that uses CallStackMixin but does not use CallStackManager\n+    \"\"\"\n+    id_field = models.IntegerField()\n+\n+\n+class ModelNothing(models.Model):\n+    \"\"\"\n+    Test Model class that neither uses CallStackMixin nor CallStackManager\n+    \"\"\"\n+    id_field = models.IntegerField()\n+\n+\n+class ModelAnotherCSM(models.Model):\n+    \"\"\"\n+    Test Model class that only uses overridden Manager CallStackManager\n+    \"\"\"\n+    objects = CallStackManager()\n+    id_field = models.IntegerField()\n+\n+\n+class ModelWithCSM(models.Model):\n+    \"\"\"\n+    Test Model Classes\n+    \"\"\"\n+    objects = CallStackManager()\n+    id_field = models.IntegerField()\n+\n+\n+class ModelWithCSMChild(ModelWithCSM):\n+    \"\"\"child class of ModelWithCSM\n+\n+    \"\"\"\n+    objects = CallStackManager()\n+    id1_field = models.IntegerField()\n+\n+\n+class TestingCallStackManager(TestCase):\n+    \"\"\"\n+    Tests for call_stack_manager package\n+    \"\"\"\n+    @patch('openedx.core.djangoapps.call_stack_manager.core.log.info')\n+    def test_save(self, log_capt):\n+        \"\"\" tests save functionality of call stack manager/ applies same for delete()\n+        1. classes with CallStackMixin should participate in logging.\n+        \"\"\"\n+        ModelMixin(id_field=1).save()\n+        self.assertEqual(ModelMixin, log_capt.call_args[0][1])\n+\n+    @patch('openedx.core.djangoapps.call_stack_manager.core.log.info')\n+    def test_withoutmixin_save(self, log_capt):\n+        \"\"\"tests save functionality of call stack manager / applies same for delete()\n+        1. classes without CallStackMixin should not participate in logging\n+        \"\"\"\n+        ModelAnotherCSM(id_field=1).save()\n+        self.assertEqual(len(log_capt.call_args_list), 0)\n+\n+    @patch('openedx.core.djangoapps.call_stack_manager.core.log.info')\n+    def test_queryset(self, log_capt):\n+        \"\"\" Tests for Overriding QuerySet API\n+        1. Classes with CallStackManager gets logged.\n+        \"\"\"\n+        ModelMixinCSM(id_field=1).save()\n+        ModelMixinCSM.objects.all()\n+        self.assertEqual(ModelMixinCSM, log_capt.call_args[0][1])\n+\n+    @patch('openedx.core.djangoapps.call_stack_manager.core.log.info')\n+    def test_withoutqueryset(self, log_capt):\n+        \"\"\" Tests for Overriding QuerySet API\n+        1. Classes without CallStackManager does not log\n+        \"\"\"\n+        # create and save objects of class not overriding queryset API\n+        ModelNothing(id_field=1).save()\n+        # class not using Manager, should not get logged\n+        ModelNothing.objects.all()\n+        self.assertEqual(len(log_capt.call_args_list), 0)\n+\n+    @patch('openedx.core.djangoapps.call_stack_manager.core.log.info')\n+    def test_donottrack(self, log_capt):\n+        \"\"\" Test for @donottrack\n+        1. calls in decorated function should not get tracked\n+        \"\"\"\n+        donottrack_func()\n+        self.assertEqual(len(log_capt.call_args_list), 0)\n+\n+    @patch('openedx.core.djangoapps.call_stack_manager.core.log.info')\n+    def test_parameterized_donottrack(self, log_capt):\n+        \"\"\" Test for parameterized @donottrack\n+        1. Should not log calls of classes specified in the decorator @donotrack\n+        \"\"\"\n+        donottrack_child_func()\n+        self.assertEqual(ModelMixinCSM, log_capt.call_args[0][1])\n+\n+    @patch('openedx.core.djangoapps.call_stack_manager.core.log.info')\n+    def test_nested_parameterized_donottrack(self, log_capt):\n+        \"\"\" Tests parameterized nested @donottrack\n+        1. should not track call of classes specified in decorated with scope bounded to the respective class\n+        \"\"\"\n+        ModelAnotherCSM(id_field=1).save()\n+        donottrack_parent_func()\n+        self.assertEqual(ModelAnotherCSM, log_capt.call_args_list[0][0][1])\n+        self.assertEqual(ModelMixinCSM, log_capt.call_args_list[1][0][1])\n+\n+    @patch('openedx.core.djangoapps.call_stack_manager.core.log.info')\n+    def test_nested_parameterized_donottrack_after(self, log_capt):\n+        \"\"\" Tests parameterized nested @donottrack\n+        1. should not track call of classes specified in decorated with scope bounded to the respective function\n+        \"\"\"\n+        donottrack_child_func()\n+        # class with CallStackManager as Manager\n+        ModelAnotherCSM(id_field=1).save()\n+        # test is this- that this should get called.","path":"openedx/core/djangoapps/call_stack_manager/tests.py","position":133,"original_position":133,"commit_id":"18049e437b5fa69cc637bc214238d647df42b674","original_commit_id":"18049e437b5fa69cc637bc214238d647df42b674","user":{"login":"doctoryes","id":7285237,"avatar_url":"https://avatars.githubusercontent.com/u/7285237?v=3","gravatar_id":"","url":"https://api.github.com/users/doctoryes","html_url":"https://github.com/doctoryes","followers_url":"https://api.github.com/users/doctoryes/followers","following_url":"https://api.github.com/users/doctoryes/following{/other_user}","gists_url":"https://api.github.com/users/doctoryes/gists{/gist_id}","starred_url":"https://api.github.com/users/doctoryes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/doctoryes/subscriptions","organizations_url":"https://api.github.com/users/doctoryes/orgs","repos_url":"https://api.github.com/users/doctoryes/repos","events_url":"https://api.github.com/users/doctoryes/events{/privacy}","received_events_url":"https://api.github.com/users/doctoryes/received_events","type":"User","site_admin":false},"body":"Rewording?","created_at":"2015-06-15T22:24:10Z","updated_at":"2015-06-15T22:24:10Z","html_url":"https://github.com/edx/edx-platform/pull/8280#discussion_r32474090","pull_request_url":"https://api.github.com/repos/edx/edx-platform/pulls/8280","_links":{"self":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/comments/32474090"},"html":{"href":"https://github.com/edx/edx-platform/pull/8280#discussion_r32474090"},"pull_request":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/8280"}}},"pull_request":{"url":"https://api.github.com/repos/edx/edx-platform/pulls/8280","id":36545247,"html_url":"https://github.com/edx/edx-platform/pull/8280","diff_url":"https://github.com/edx/edx-platform/pull/8280.diff","patch_url":"https://github.com/edx/edx-platform/pull/8280.patch","issue_url":"https://api.github.com/repos/edx/edx-platform/issues/8280","number":8280,"state":"open","locked":false,"title":"Adding call stack manager","user":{"login":"utkjad","id":5477150,"avatar_url":"https://avatars.githubusercontent.com/u/5477150?v=3","gravatar_id":"","url":"https://api.github.com/users/utkjad","html_url":"https://github.com/utkjad","followers_url":"https://api.github.com/users/utkjad/followers","following_url":"https://api.github.com/users/utkjad/following{/other_user}","gists_url":"https://api.github.com/users/utkjad/gists{/gist_id}","starred_url":"https://api.github.com/users/utkjad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/utkjad/subscriptions","organizations_url":"https://api.github.com/users/utkjad/orgs","repos_url":"https://api.github.com/users/utkjad/repos","events_url":"https://api.github.com/users/utkjad/events{/privacy}","received_events_url":"https://api.github.com/users/utkjad/received_events","type":"User","site_admin":false},"body":"added call stack manager to trace classes defined in Model classes.\r\n\r\n@doctoryes  @cpennington  - can you please review?","created_at":"2015-05-29T21:09:18Z","updated_at":"2015-06-15T22:24:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/edx/edx-platform/pulls/8280/commits","review_comments_url":"https://api.github.com/repos/edx/edx-platform/pulls/8280/comments","review_comment_url":"https://api.github.com/repos/edx/edx-platform/pulls/comments{/number}","comments_url":"https://api.github.com/repos/edx/edx-platform/issues/8280/comments","statuses_url":"https://api.github.com/repos/edx/edx-platform/statuses/18049e437b5fa69cc637bc214238d647df42b674","head":{"label":"edx:utkjad/callstackmanager","ref":"utkjad/callstackmanager","sha":"18049e437b5fa69cc637bc214238d647df42b674","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"repo":{"id":10391073,"name":"edx-platform","full_name":"edx/edx-platform","owner":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/edx/edx-platform","description":"The Open edX platform, the software that powers edX!","fork":false,"url":"https://api.github.com/repos/edx/edx-platform","forks_url":"https://api.github.com/repos/edx/edx-platform/forks","keys_url":"https://api.github.com/repos/edx/edx-platform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/edx-platform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/edx-platform/teams","hooks_url":"https://api.github.com/repos/edx/edx-platform/hooks","issue_events_url":"https://api.github.com/repos/edx/edx-platform/issues/events{/number}","events_url":"https://api.github.com/repos/edx/edx-platform/events","assignees_url":"https://api.github.com/repos/edx/edx-platform/assignees{/user}","branches_url":"https://api.github.com/repos/edx/edx-platform/branches{/branch}","tags_url":"https://api.github.com/repos/edx/edx-platform/tags","blobs_url":"https://api.github.com/repos/edx/edx-platform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/edx-platform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/edx-platform/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/edx-platform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/edx-platform/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/edx-platform/languages","stargazers_url":"https://api.github.com/repos/edx/edx-platform/stargazers","contributors_url":"https://api.github.com/repos/edx/edx-platform/contributors","subscribers_url":"https://api.github.com/repos/edx/edx-platform/subscribers","subscription_url":"https://api.github.com/repos/edx/edx-platform/subscription","commits_url":"https://api.github.com/repos/edx/edx-platform/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/edx-platform/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/edx-platform/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/edx-platform/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/edx-platform/contents/{+path}","compare_url":"https://api.github.com/repos/edx/edx-platform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/edx-platform/merges","archive_url":"https://api.github.com/repos/edx/edx-platform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/edx-platform/downloads","issues_url":"https://api.github.com/repos/edx/edx-platform/issues{/number}","pulls_url":"https://api.github.com/repos/edx/edx-platform/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/edx-platform/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/edx-platform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/edx-platform/labels{/name}","releases_url":"https://api.github.com/repos/edx/edx-platform/releases{/id}","created_at":"2013-05-30T20:20:38Z","updated_at":"2015-06-15T17:02:48Z","pushed_at":"2015-06-15T21:36:37Z","git_url":"git://github.com/edx/edx-platform.git","ssh_url":"git@github.com:edx/edx-platform.git","clone_url":"https://github.com/edx/edx-platform.git","svn_url":"https://github.com/edx/edx-platform","homepage":"http://open.edx.org/","size":1891744,"stargazers_count":1983,"watchers_count":1983,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1138,"mirror_url":null,"open_issues_count":165,"forks":1138,"open_issues":165,"watchers":1983,"default_branch":"master"}},"base":{"label":"edx:master","ref":"master","sha":"acbc2113a283e7f037183bebee13850377b7767e","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"repo":{"id":10391073,"name":"edx-platform","full_name":"edx/edx-platform","owner":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/edx/edx-platform","description":"The Open edX platform, the software that powers edX!","fork":false,"url":"https://api.github.com/repos/edx/edx-platform","forks_url":"https://api.github.com/repos/edx/edx-platform/forks","keys_url":"https://api.github.com/repos/edx/edx-platform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/edx-platform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/edx-platform/teams","hooks_url":"https://api.github.com/repos/edx/edx-platform/hooks","issue_events_url":"https://api.github.com/repos/edx/edx-platform/issues/events{/number}","events_url":"https://api.github.com/repos/edx/edx-platform/events","assignees_url":"https://api.github.com/repos/edx/edx-platform/assignees{/user}","branches_url":"https://api.github.com/repos/edx/edx-platform/branches{/branch}","tags_url":"https://api.github.com/repos/edx/edx-platform/tags","blobs_url":"https://api.github.com/repos/edx/edx-platform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/edx-platform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/edx-platform/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/edx-platform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/edx-platform/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/edx-platform/languages","stargazers_url":"https://api.github.com/repos/edx/edx-platform/stargazers","contributors_url":"https://api.github.com/repos/edx/edx-platform/contributors","subscribers_url":"https://api.github.com/repos/edx/edx-platform/subscribers","subscription_url":"https://api.github.com/repos/edx/edx-platform/subscription","commits_url":"https://api.github.com/repos/edx/edx-platform/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/edx-platform/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/edx-platform/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/edx-platform/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/edx-platform/contents/{+path}","compare_url":"https://api.github.com/repos/edx/edx-platform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/edx-platform/merges","archive_url":"https://api.github.com/repos/edx/edx-platform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/edx-platform/downloads","issues_url":"https://api.github.com/repos/edx/edx-platform/issues{/number}","pulls_url":"https://api.github.com/repos/edx/edx-platform/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/edx-platform/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/edx-platform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/edx-platform/labels{/name}","releases_url":"https://api.github.com/repos/edx/edx-platform/releases{/id}","created_at":"2013-05-30T20:20:38Z","updated_at":"2015-06-15T17:02:48Z","pushed_at":"2015-06-15T21:36:37Z","git_url":"git://github.com/edx/edx-platform.git","ssh_url":"git@github.com:edx/edx-platform.git","clone_url":"https://github.com/edx/edx-platform.git","svn_url":"https://github.com/edx/edx-platform","homepage":"http://open.edx.org/","size":1891744,"stargazers_count":1983,"watchers_count":1983,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1138,"mirror_url":null,"open_issues_count":165,"forks":1138,"open_issues":165,"watchers":1983,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/8280"},"html":{"href":"https://github.com/edx/edx-platform/pull/8280"},"issue":{"href":"https://api.github.com/repos/edx/edx-platform/issues/8280"},"comments":{"href":"https://api.github.com/repos/edx/edx-platform/issues/8280/comments"},"review_comments":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/8280/comments"},"review_comment":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/edx/edx-platform/pulls/8280/commits"},"statuses":{"href":"https://api.github.com/repos/edx/edx-platform/statuses/18049e437b5fa69cc637bc214238d647df42b674"}}}}