GitHub PullRequestReviewCommentEvent at 2014-08-07 05:53:08
Repository: ralph_pricing
Actor: mkurek
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/allegro/ralph_pricing/pulls/comments/15919478","id":15919478,"diff_hunk":"@@ -0,0 +1,119 @@\n+# -*- coding: utf-8 -*-\n+\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 datetime import date\n+from mock import patch, MagicMock\n+\n+from django.test import TestCase\n+from django.conf import settings\n+\n+from ralph_scrooge.models import DailyUsage, UsageType\n+from ralph_scrooge.plugins.collect import share\n+\n+from ralph_scrooge.tests.utils.factory import (\n+    AssetInfoFactory,\n+    DailyPricingObjectFactory,\n+    UsageTypeFactory,\n+)\n+\n+\n+class TestSharesPlugin(TestCase):\n+    def setUp(self):\n+        self.date = date.today()\n+        self.data = {\n+            'size': 100,\n+            'mount_device_id': 1,\n+            'storage_device_id': 1,\n+            'label': 'test share',\n+        }\n+        self.asset_info = AssetInfoFactory.create(\n+            device_id=self.data['mount_device_id']\n+        )\n+        self.usage_type = UsageTypeFactory.create()\n+\n+    def test_update_usage(self):\n+        DailyPricingObjectFactory.create(\n+            pricing_object=self.asset_info,\n+            date=self.date,\n+        )\n+        share.update_usage(\n+            self.asset_info,\n+            self.usage_type,\n+            self.data,\n+            self.date,\n+        )\n+        self.assertEqual(DailyUsage.objects.count(), 1)\n+        daily_usage = DailyUsage.objects.all()[0]\n+        self.assertEqual(daily_usage.value, self.data['size'])\n+        self.assertEqual(daily_usage.type, self.usage_type)\n+        self.assertEqual(daily_usage.service, self.asset_info.service)\n+\n+    def test_update_when_unknown_mount_device_id_error(self):\n+        self.data['mount_device_id'] = None\n+        self.assertRaises(\n+            share.UnknownMountDeviceIdError,\n+            share.update,\n+            usage_type=self.usage_type,\n+            data=self.data,\n+            date=self.date,\n+        )\n+\n+    def test_update_when_asset_info_does_not_exist_error(self):\n+        self.data['mount_device_id'] = 2\n+        self.assertRaises(\n+            share.AssetInfoDoesNotExistError,\n+            share.update,\n+            usage_type=self.usage_type,\n+            data=self.data,\n+            date=self.date,\n+        )\n+\n+    @patch.object(share, 'update_usage', lambda x, y, z, k: True)\n+    def test_update(self):\n+        self.assertEqual(\n+            share.update(self.usage_type, self.data, self.date),\n+            True,\n+        )\n+\n+    def test_get_usage(self):\n+        self.assertEqual(\n+            share.get_usage('Test usage'),\n+            UsageType.objects.all()[1]\n+        )\n+\n+    @patch.object(share, 'logger', MagicMock())\n+    @patch.object(settings, 'SHARE_SERVICE_CI_UID', {'group': ['ci_uid']})\n+    def test_share_when_unknown_mount_device_id_error(self):\n+        share.get_shares = lambda service_ci_uid, include_virtual: [self.data]\n+        self.data['mount_device_id'] = None\n+        self.assertEqual(\n+            share.share(today=self.date),\n+            (True, 'None new, 0 updated, 1 total'),\n+        )\n+\n+    @patch.object(share, 'logger', MagicMock())\n+    @patch.object(settings, 'SHARE_SERVICE_CI_UID', {'group': ['ci_uid']})","path":"src/ralph_scrooge/tests/plugins/collect/test_shares.py","position":99,"original_position":99,"commit_id":"65b323ff0a16de1d9c772aacb3204daf6f995f35","original_commit_id":"65b323ff0a16de1d9c772aacb3204daf6f995f35","user":{"login":"mkurek","id":107437,"avatar_url":"https://avatars.githubusercontent.com/u/107437?v=2","gravatar_id":"392533ae1380db7827abba93ea5a31ae","url":"https://api.github.com/users/mkurek","html_url":"https://github.com/mkurek","followers_url":"https://api.github.com/users/mkurek/followers","following_url":"https://api.github.com/users/mkurek/following{/other_user}","gists_url":"https://api.github.com/users/mkurek/gists{/gist_id}","starred_url":"https://api.github.com/users/mkurek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkurek/subscriptions","organizations_url":"https://api.github.com/users/mkurek/orgs","repos_url":"https://api.github.com/users/mkurek/repos","events_url":"https://api.github.com/users/mkurek/events{/privacy}","received_events_url":"https://api.github.com/users/mkurek/received_events","type":"User","site_admin":false},"body":"override_settings","created_at":"2014-08-07T05:53:08Z","updated_at":"2014-08-07T05:53:08Z","html_url":"https://github.com/allegro/ralph_pricing/pull/239#discussion_r15919478","pull_request_url":"https://api.github.com/repos/allegro/ralph_pricing/pulls/239","_links":{"self":{"href":"https://api.github.com/repos/allegro/ralph_pricing/pulls/comments/15919478"},"html":{"href":"https://github.com/allegro/ralph_pricing/pull/239#discussion_r15919478"},"pull_request":{"href":"https://api.github.com/repos/allegro/ralph_pricing/pulls/239"}}},"pull_request":{"url":"https://api.github.com/repos/allegro/ralph_pricing/pulls/239","id":19400478,"html_url":"https://github.com/allegro/ralph_pricing/pull/239","diff_url":"https://github.com/allegro/ralph_pricing/pull/239.diff","patch_url":"https://github.com/allegro/ralph_pricing/pull/239.patch","issue_url":"https://api.github.com/repos/allegro/ralph_pricing/issues/239","number":239,"state":"open","title":"Share plugin on service","user":{"login":"kula1922","id":2130852,"avatar_url":"https://avatars.githubusercontent.com/u/2130852?v=2","gravatar_id":"4e9db77cc232a4b6fcd7b73308e00a38","url":"https://api.github.com/users/kula1922","html_url":"https://github.com/kula1922","followers_url":"https://api.github.com/users/kula1922/followers","following_url":"https://api.github.com/users/kula1922/following{/other_user}","gists_url":"https://api.github.com/users/kula1922/gists{/gist_id}","starred_url":"https://api.github.com/users/kula1922/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kula1922/subscriptions","organizations_url":"https://api.github.com/users/kula1922/orgs","repos_url":"https://api.github.com/users/kula1922/repos","events_url":"https://api.github.com/users/kula1922/events{/privacy}","received_events_url":"https://api.github.com/users/kula1922/received_events","type":"User","site_admin":false},"body":"- Shares collect plugin on service","created_at":"2014-08-06T12:26:34Z","updated_at":"2014-08-07T05:53:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"45f53bb658d6e6a7f5445632c87fda1c97a2e060","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/allegro/ralph_pricing/pulls/239/commits","review_comments_url":"https://api.github.com/repos/allegro/ralph_pricing/pulls/239/comments","review_comment_url":"https://api.github.com/repos/allegro/ralph_pricing/pulls/comments/{number}","comments_url":"https://api.github.com/repos/allegro/ralph_pricing/issues/239/comments","statuses_url":"https://api.github.com/repos/allegro/ralph_pricing/statuses/65b323ff0a16de1d9c772aacb3204daf6f995f35","head":{"label":"kula1922:feature/shares-collect-plugin","ref":"feature/shares-collect-plugin","sha":"65b323ff0a16de1d9c772aacb3204daf6f995f35","user":{"login":"kula1922","id":2130852,"avatar_url":"https://avatars.githubusercontent.com/u/2130852?v=2","gravatar_id":"4e9db77cc232a4b6fcd7b73308e00a38","url":"https://api.github.com/users/kula1922","html_url":"https://github.com/kula1922","followers_url":"https://api.github.com/users/kula1922/followers","following_url":"https://api.github.com/users/kula1922/following{/other_user}","gists_url":"https://api.github.com/users/kula1922/gists{/gist_id}","starred_url":"https://api.github.com/users/kula1922/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kula1922/subscriptions","organizations_url":"https://api.github.com/users/kula1922/orgs","repos_url":"https://api.github.com/users/kula1922/repos","events_url":"https://api.github.com/users/kula1922/events{/privacy}","received_events_url":"https://api.github.com/users/kula1922/received_events","type":"User","site_admin":false},"repo":{"id":15075699,"name":"ralph_pricing","full_name":"kula1922/ralph_pricing","owner":{"login":"kula1922","id":2130852,"avatar_url":"https://avatars.githubusercontent.com/u/2130852?v=2","gravatar_id":"4e9db77cc232a4b6fcd7b73308e00a38","url":"https://api.github.com/users/kula1922","html_url":"https://github.com/kula1922","followers_url":"https://api.github.com/users/kula1922/followers","following_url":"https://api.github.com/users/kula1922/following{/other_user}","gists_url":"https://api.github.com/users/kula1922/gists{/gist_id}","starred_url":"https://api.github.com/users/kula1922/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kula1922/subscriptions","organizations_url":"https://api.github.com/users/kula1922/orgs","repos_url":"https://api.github.com/users/kula1922/repos","events_url":"https://api.github.com/users/kula1922/events{/privacy}","received_events_url":"https://api.github.com/users/kula1922/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kula1922/ralph_pricing","description":"A pricing module for Ralph","fork":true,"url":"https://api.github.com/repos/kula1922/ralph_pricing","forks_url":"https://api.github.com/repos/kula1922/ralph_pricing/forks","keys_url":"https://api.github.com/repos/kula1922/ralph_pricing/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kula1922/ralph_pricing/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kula1922/ralph_pricing/teams","hooks_url":"https://api.github.com/repos/kula1922/ralph_pricing/hooks","issue_events_url":"https://api.github.com/repos/kula1922/ralph_pricing/issues/events{/number}","events_url":"https://api.github.com/repos/kula1922/ralph_pricing/events","assignees_url":"https://api.github.com/repos/kula1922/ralph_pricing/assignees{/user}","branches_url":"https://api.github.com/repos/kula1922/ralph_pricing/branches{/branch}","tags_url":"https://api.github.com/repos/kula1922/ralph_pricing/tags","blobs_url":"https://api.github.com/repos/kula1922/ralph_pricing/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kula1922/ralph_pricing/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kula1922/ralph_pricing/git/refs{/sha}","trees_url":"https://api.github.com/repos/kula1922/ralph_pricing/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kula1922/ralph_pricing/statuses/{sha}","languages_url":"https://api.github.com/repos/kula1922/ralph_pricing/languages","stargazers_url":"https://api.github.com/repos/kula1922/ralph_pricing/stargazers","contributors_url":"https://api.github.com/repos/kula1922/ralph_pricing/contributors","subscribers_url":"https://api.github.com/repos/kula1922/ralph_pricing/subscribers","subscription_url":"https://api.github.com/repos/kula1922/ralph_pricing/subscription","commits_url":"https://api.github.com/repos/kula1922/ralph_pricing/commits{/sha}","git_commits_url":"https://api.github.com/repos/kula1922/ralph_pricing/git/commits{/sha}","comments_url":"https://api.github.com/repos/kula1922/ralph_pricing/comments{/number}","issue_comment_url":"https://api.github.com/repos/kula1922/ralph_pricing/issues/comments/{number}","contents_url":"https://api.github.com/repos/kula1922/ralph_pricing/contents/{+path}","compare_url":"https://api.github.com/repos/kula1922/ralph_pricing/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kula1922/ralph_pricing/merges","archive_url":"https://api.github.com/repos/kula1922/ralph_pricing/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kula1922/ralph_pricing/downloads","issues_url":"https://api.github.com/repos/kula1922/ralph_pricing/issues{/number}","pulls_url":"https://api.github.com/repos/kula1922/ralph_pricing/pulls{/number}","milestones_url":"https://api.github.com/repos/kula1922/ralph_pricing/milestones{/number}","notifications_url":"https://api.github.com/repos/kula1922/ralph_pricing/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kula1922/ralph_pricing/labels{/name}","releases_url":"https://api.github.com/repos/kula1922/ralph_pricing/releases{/id}","created_at":"2013-12-10T11:47:32Z","updated_at":"2014-06-23T07:40:42Z","pushed_at":"2014-08-06T12:24:27Z","git_url":"git://github.com/kula1922/ralph_pricing.git","ssh_url":"git@github.com:kula1922/ralph_pricing.git","clone_url":"https://github.com/kula1922/ralph_pricing.git","svn_url":"https://github.com/kula1922/ralph_pricing","homepage":null,"size":4924,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"allegro:services","ref":"services","sha":"bfde2e821736d67168e36f0f6791eafed4100bd5","user":{"login":"allegro","id":562236,"avatar_url":"https://avatars.githubusercontent.com/u/562236?v=2","gravatar_id":"7aa24c1a2da927f8961bf8ff0936a812","url":"https://api.github.com/users/allegro","html_url":"https://github.com/allegro","followers_url":"https://api.github.com/users/allegro/followers","following_url":"https://api.github.com/users/allegro/following{/other_user}","gists_url":"https://api.github.com/users/allegro/gists{/gist_id}","starred_url":"https://api.github.com/users/allegro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/allegro/subscriptions","organizations_url":"https://api.github.com/users/allegro/orgs","repos_url":"https://api.github.com/users/allegro/repos","events_url":"https://api.github.com/users/allegro/events{/privacy}","received_events_url":"https://api.github.com/users/allegro/received_events","type":"Organization","site_admin":false},"repo":{"id":9495095,"name":"ralph_pricing","full_name":"allegro/ralph_pricing","owner":{"login":"allegro","id":562236,"avatar_url":"https://avatars.githubusercontent.com/u/562236?v=2","gravatar_id":"7aa24c1a2da927f8961bf8ff0936a812","url":"https://api.github.com/users/allegro","html_url":"https://github.com/allegro","followers_url":"https://api.github.com/users/allegro/followers","following_url":"https://api.github.com/users/allegro/following{/other_user}","gists_url":"https://api.github.com/users/allegro/gists{/gist_id}","starred_url":"https://api.github.com/users/allegro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/allegro/subscriptions","organizations_url":"https://api.github.com/users/allegro/orgs","repos_url":"https://api.github.com/users/allegro/repos","events_url":"https://api.github.com/users/allegro/events{/privacy}","received_events_url":"https://api.github.com/users/allegro/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/allegro/ralph_pricing","description":"A pricing module for Ralph","fork":false,"url":"https://api.github.com/repos/allegro/ralph_pricing","forks_url":"https://api.github.com/repos/allegro/ralph_pricing/forks","keys_url":"https://api.github.com/repos/allegro/ralph_pricing/keys{/key_id}","collaborators_url":"https://api.github.com/repos/allegro/ralph_pricing/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/allegro/ralph_pricing/teams","hooks_url":"https://api.github.com/repos/allegro/ralph_pricing/hooks","issue_events_url":"https://api.github.com/repos/allegro/ralph_pricing/issues/events{/number}","events_url":"https://api.github.com/repos/allegro/ralph_pricing/events","assignees_url":"https://api.github.com/repos/allegro/ralph_pricing/assignees{/user}","branches_url":"https://api.github.com/repos/allegro/ralph_pricing/branches{/branch}","tags_url":"https://api.github.com/repos/allegro/ralph_pricing/tags","blobs_url":"https://api.github.com/repos/allegro/ralph_pricing/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/allegro/ralph_pricing/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/allegro/ralph_pricing/git/refs{/sha}","trees_url":"https://api.github.com/repos/allegro/ralph_pricing/git/trees{/sha}","statuses_url":"https://api.github.com/repos/allegro/ralph_pricing/statuses/{sha}","languages_url":"https://api.github.com/repos/allegro/ralph_pricing/languages","stargazers_url":"https://api.github.com/repos/allegro/ralph_pricing/stargazers","contributors_url":"https://api.github.com/repos/allegro/ralph_pricing/contributors","subscribers_url":"https://api.github.com/repos/allegro/ralph_pricing/subscribers","subscription_url":"https://api.github.com/repos/allegro/ralph_pricing/subscription","commits_url":"https://api.github.com/repos/allegro/ralph_pricing/commits{/sha}","git_commits_url":"https://api.github.com/repos/allegro/ralph_pricing/git/commits{/sha}","comments_url":"https://api.github.com/repos/allegro/ralph_pricing/comments{/number}","issue_comment_url":"https://api.github.com/repos/allegro/ralph_pricing/issues/comments/{number}","contents_url":"https://api.github.com/repos/allegro/ralph_pricing/contents/{+path}","compare_url":"https://api.github.com/repos/allegro/ralph_pricing/compare/{base}...{head}","merges_url":"https://api.github.com/repos/allegro/ralph_pricing/merges","archive_url":"https://api.github.com/repos/allegro/ralph_pricing/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/allegro/ralph_pricing/downloads","issues_url":"https://api.github.com/repos/allegro/ralph_pricing/issues{/number}","pulls_url":"https://api.github.com/repos/allegro/ralph_pricing/pulls{/number}","milestones_url":"https://api.github.com/repos/allegro/ralph_pricing/milestones{/number}","notifications_url":"https://api.github.com/repos/allegro/ralph_pricing/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/allegro/ralph_pricing/labels{/name}","releases_url":"https://api.github.com/repos/allegro/ralph_pricing/releases{/id}","created_at":"2013-04-17T10:30:06Z","updated_at":"2014-06-26T09:13:09Z","pushed_at":"2014-08-06T07:16:15Z","git_url":"git://github.com/allegro/ralph_pricing.git","ssh_url":"git@github.com:allegro/ralph_pricing.git","clone_url":"https://github.com/allegro/ralph_pricing.git","svn_url":"https://github.com/allegro/ralph_pricing","homepage":null,"size":6829,"stargazers_count":5,"watchers_count":5,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":11,"mirror_url":null,"open_issues_count":7,"forks":11,"open_issues":7,"watchers":5,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/allegro/ralph_pricing/pulls/239"},"html":{"href":"https://github.com/allegro/ralph_pricing/pull/239"},"issue":{"href":"https://api.github.com/repos/allegro/ralph_pricing/issues/239"},"comments":{"href":"https://api.github.com/repos/allegro/ralph_pricing/issues/239/comments"},"review_comments":{"href":"https://api.github.com/repos/allegro/ralph_pricing/pulls/239/comments"},"review_comment":{"href":"https://api.github.com/repos/allegro/ralph_pricing/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/allegro/ralph_pricing/pulls/239/commits"},"statuses":{"href":"https://api.github.com/repos/allegro/ralph_pricing/statuses/65b323ff0a16de1d9c772aacb3204daf6f995f35"}}}}