{"action":"created","comment":{"url":"https://api.github.com/repos/SatelliteQE/betelgeuse/pulls/comments/72523401","id":72523401,"diff_hunk":"@@ -644,31 +644,52 @@ def test_case(context, path, collect_only, project):\n     '--parent-name',\n     help='Name of parent Test Plan to link to.',\n )\n+@click.option(\n+    '--custom-fields',\n+    help='Custom fields for the test plan.',\n+    multiple=True,\n+)\n @click.argument('project')\n @click.pass_context\n-def test_plan(context, name, plan_type, parent_name, project):\n+def test_plan(context, name, plan_type, parent_name, custom_fields, project):\n     \"\"\"Create a new test plan in Polarion.\"\"\"\n     # Sanitize names to valid values for IDs...\n+    custom_fields = load_custom_fields(custom_fields)\n     plan_id = re.sub(INVALID_CHARS_REGEX, '_', name).replace(' ', '_')\n     parent_plan_id = (\n         re.sub(INVALID_CHARS_REGEX, '_', parent_name).replace(' ', '_')\n         if parent_name else parent_name\n     )\n-\n     # Check if the test plan already exists\n     result = Plan.search('id:{0}'.format(plan_id))\n     if len(result) == 1:\n         click.echo('Found Test Plan {0}.'.format(name))\n-        return\n+        test_plan = result[0]\n+    else:\n+        # Unlike Testrun, Pylarion current does not accept **kwargs in\n+        # Plan.create() so the custom fields need to be updated after the\n+        # creation\n+        test_plan = Plan.create(\n+            parent_id=parent_plan_id,\n+            plan_id=plan_id,\n+            plan_name=name,\n+            project_id=project,\n+            template_id=plan_type\n+        )\n+        click.echo(\n+            'Created new Test Plan {0} with ID {1}.'.format(name, plan_id))\n \n-    Plan.create(\n-        parent_id=parent_plan_id,\n-        plan_id=plan_id,\n-        plan_name=name,\n-        project_id=project,\n-        template_id=plan_type\n-    )\n-    click.echo('Created new Test Plan {0} with ID {1}.'.format(name, plan_id))\n+    update = False\n+    for field, value in custom_fields.items():\n+        if getattr(test_plan, field) != value:\n+            setattr(test_plan, field, value)\n+            click.echo(\n+                'Test Plan {0} updated with {1}={2}.'.format(","path":"betelgeuse.py","position":55,"original_position":55,"commit_id":"de8d0a0750364ac0ef5fd12d433ecc9e3254174b","original_commit_id":"de8d0a0750364ac0ef5fd12d433ecc9e3254174b","user":{"login":"elyezer","id":48132,"avatar_url":"https://avatars.githubusercontent.com/u/48132?v=3","gravatar_id":"","url":"https://api.github.com/users/elyezer","html_url":"https://github.com/elyezer","followers_url":"https://api.github.com/users/elyezer/followers","following_url":"https://api.github.com/users/elyezer/following{/other_user}","gists_url":"https://api.github.com/users/elyezer/gists{/gist_id}","starred_url":"https://api.github.com/users/elyezer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elyezer/subscriptions","organizations_url":"https://api.github.com/users/elyezer/orgs","repos_url":"https://api.github.com/users/elyezer/repos","events_url":"https://api.github.com/users/elyezer/events{/privacy}","received_events_url":"https://api.github.com/users/elyezer/received_events","type":"User","site_admin":false},"body":"This message is really useful.","created_at":"2016-07-27T21:04:24Z","updated_at":"2016-07-27T21:04:24Z","html_url":"https://github.com/SatelliteQE/betelgeuse/pull/69#discussion_r72523401","pull_request_url":"https://api.github.com/repos/SatelliteQE/betelgeuse/pulls/69","_links":{"self":{"href":"https://api.github.com/repos/SatelliteQE/betelgeuse/pulls/comments/72523401"},"html":{"href":"https://github.com/SatelliteQE/betelgeuse/pull/69#discussion_r72523401"},"pull_request":{"href":"https://api.github.com/repos/SatelliteQE/betelgeuse/pulls/69"}}},"pull_request":{"url":"https://api.github.com/repos/SatelliteQE/betelgeuse/pulls/69","id":78750368,"html_url":"https://github.com/SatelliteQE/betelgeuse/pull/69","diff_url":"https://github.com/SatelliteQE/betelgeuse/pull/69.diff","patch_url":"https://github.com/SatelliteQE/betelgeuse/pull/69.patch","issue_url":"https://api.github.com/repos/SatelliteQE/betelgeuse/issues/69","number":69,"state":"open","locked":false,"title":"Added ability to update custom fields for the test plan","user":{"login":"sthirugn","id":3309189,"avatar_url":"https://avatars.githubusercontent.com/u/3309189?v=3","gravatar_id":"","url":"https://api.github.com/users/sthirugn","html_url":"https://github.com/sthirugn","followers_url":"https://api.github.com/users/sthirugn/followers","following_url":"https://api.github.com/users/sthirugn/following{/other_user}","gists_url":"https://api.github.com/users/sthirugn/gists{/gist_id}","starred_url":"https://api.github.com/users/sthirugn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sthirugn/subscriptions","organizations_url":"https://api.github.com/users/sthirugn/orgs","repos_url":"https://api.github.com/users/sthirugn/repos","events_url":"https://api.github.com/users/sthirugn/events{/privacy}","received_events_url":"https://api.github.com/users/sthirugn/received_events","type":"User","site_admin":false},"body":"Test result:\r\n```bash\r\n$ betelgeuse test-plan --name iteration122 --status blah CLOUDTP\r\nUsage: betelgeuse test-plan [OPTIONS] PROJECT\r\n\r\nError: Invalid value for \"--status\": invalid choice: blah. (choose from open, inprogress, done)\r\n\r\n$ betelgeuse test-plan --name iteration122 --status open CLOUDTP\r\nFound Test Plan iteration122.\r\nUpdated test plan iteration122 with status open.\r\n\r\n$ betelgeuse test-plan --name iteration122 --status done CLOUDTP\r\nFound Test Plan iteration122.\r\nUpdated test plan iteration122 with status done.\r\n\r\n$ betelgeuse test-plan --name iteration122 --status inprogress CLOUDTP\r\nFound Test Plan iteration122.\r\nUpdated test plan iteration122 with status inprogress.\r\n```","created_at":"2016-07-25T20:55:07Z","updated_at":"2016-07-27T21:04:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cb1137b2a4adde34b970a0bc9492ddf668fd43a2","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/SatelliteQE/betelgeuse/pulls/69/commits","review_comments_url":"https://api.github.com/repos/SatelliteQE/betelgeuse/pulls/69/comments","review_comment_url":"https://api.github.com/repos/SatelliteQE/betelgeuse/pulls/comments{/number}","comments_url":"https://api.github.com/repos/SatelliteQE/betelgeuse/issues/69/comments","statuses_url":"https://api.github.com/repos/SatelliteQE/betelgeuse/statuses/de8d0a0750364ac0ef5fd12d433ecc9e3254174b","head":{"label":"sthirugn:status_update","ref":"status_update","sha":"de8d0a0750364ac0ef5fd12d433ecc9e3254174b","user":{"login":"sthirugn","id":3309189,"avatar_url":"https://avatars.githubusercontent.com/u/3309189?v=3","gravatar_id":"","url":"https://api.github.com/users/sthirugn","html_url":"https://github.com/sthirugn","followers_url":"https://api.github.com/users/sthirugn/followers","following_url":"https://api.github.com/users/sthirugn/following{/other_user}","gists_url":"https://api.github.com/users/sthirugn/gists{/gist_id}","starred_url":"https://api.github.com/users/sthirugn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sthirugn/subscriptions","organizations_url":"https://api.github.com/users/sthirugn/orgs","repos_url":"https://api.github.com/users/sthirugn/repos","events_url":"https://api.github.com/users/sthirugn/events{/privacy}","received_events_url":"https://api.github.com/users/sthirugn/received_events","type":"User","site_admin":false},"repo":{"id":62733867,"name":"betelgeuse","full_name":"sthirugn/betelgeuse","owner":{"login":"sthirugn","id":3309189,"avatar_url":"https://avatars.githubusercontent.com/u/3309189?v=3","gravatar_id":"","url":"https://api.github.com/users/sthirugn","html_url":"https://github.com/sthirugn","followers_url":"https://api.github.com/users/sthirugn/followers","following_url":"https://api.github.com/users/sthirugn/following{/other_user}","gists_url":"https://api.github.com/users/sthirugn/gists{/gist_id}","starred_url":"https://api.github.com/users/sthirugn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sthirugn/subscriptions","organizations_url":"https://api.github.com/users/sthirugn/orgs","repos_url":"https://api.github.com/users/sthirugn/repos","events_url":"https://api.github.com/users/sthirugn/events{/privacy}","received_events_url":"https://api.github.com/users/sthirugn/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sthirugn/betelgeuse","description":"Betelgeuse reads standard Python test cases and offers tools   to interact with Polarion.","fork":true,"url":"https://api.github.com/repos/sthirugn/betelgeuse","forks_url":"https://api.github.com/repos/sthirugn/betelgeuse/forks","keys_url":"https://api.github.com/repos/sthirugn/betelgeuse/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sthirugn/betelgeuse/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sthirugn/betelgeuse/teams","hooks_url":"https://api.github.com/repos/sthirugn/betelgeuse/hooks","issue_events_url":"https://api.github.com/repos/sthirugn/betelgeuse/issues/events{/number}","events_url":"https://api.github.com/repos/sthirugn/betelgeuse/events","assignees_url":"https://api.github.com/repos/sthirugn/betelgeuse/assignees{/user}","branches_url":"https://api.github.com/repos/sthirugn/betelgeuse/branches{/branch}","tags_url":"https://api.github.com/repos/sthirugn/betelgeuse/tags","blobs_url":"https://api.github.com/repos/sthirugn/betelgeuse/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sthirugn/betelgeuse/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sthirugn/betelgeuse/git/refs{/sha}","trees_url":"https://api.github.com/repos/sthirugn/betelgeuse/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sthirugn/betelgeuse/statuses/{sha}","languages_url":"https://api.github.com/repos/sthirugn/betelgeuse/languages","stargazers_url":"https://api.github.com/repos/sthirugn/betelgeuse/stargazers","contributors_url":"https://api.github.com/repos/sthirugn/betelgeuse/contributors","subscribers_url":"https://api.github.com/repos/sthirugn/betelgeuse/subscribers","subscription_url":"https://api.github.com/repos/sthirugn/betelgeuse/subscription","commits_url":"https://api.github.com/repos/sthirugn/betelgeuse/commits{/sha}","git_commits_url":"https://api.github.com/repos/sthirugn/betelgeuse/git/commits{/sha}","comments_url":"https://api.github.com/repos/sthirugn/betelgeuse/comments{/number}","issue_comment_url":"https://api.github.com/repos/sthirugn/betelgeuse/issues/comments{/number}","contents_url":"https://api.github.com/repos/sthirugn/betelgeuse/contents/{+path}","compare_url":"https://api.github.com/repos/sthirugn/betelgeuse/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sthirugn/betelgeuse/merges","archive_url":"https://api.github.com/repos/sthirugn/betelgeuse/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sthirugn/betelgeuse/downloads","issues_url":"https://api.github.com/repos/sthirugn/betelgeuse/issues{/number}","pulls_url":"https://api.github.com/repos/sthirugn/betelgeuse/pulls{/number}","milestones_url":"https://api.github.com/repos/sthirugn/betelgeuse/milestones{/number}","notifications_url":"https://api.github.com/repos/sthirugn/betelgeuse/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sthirugn/betelgeuse/labels{/name}","releases_url":"https://api.github.com/repos/sthirugn/betelgeuse/releases{/id}","deployments_url":"https://api.github.com/repos/sthirugn/betelgeuse/deployments","created_at":"2016-07-06T15:51:43Z","updated_at":"2016-07-06T15:51:44Z","pushed_at":"2016-07-27T20:21:26Z","git_url":"git://github.com/sthirugn/betelgeuse.git","ssh_url":"git@github.com:sthirugn/betelgeuse.git","clone_url":"https://github.com/sthirugn/betelgeuse.git","svn_url":"https://github.com/sthirugn/betelgeuse","homepage":null,"size":98,"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":"SatelliteQE:master","ref":"master","sha":"7be93eef242b6de71523827f0ca142323880599c","user":{"login":"SatelliteQE","id":8754276,"avatar_url":"https://avatars.githubusercontent.com/u/8754276?v=3","gravatar_id":"","url":"https://api.github.com/users/SatelliteQE","html_url":"https://github.com/SatelliteQE","followers_url":"https://api.github.com/users/SatelliteQE/followers","following_url":"https://api.github.com/users/SatelliteQE/following{/other_user}","gists_url":"https://api.github.com/users/SatelliteQE/gists{/gist_id}","starred_url":"https://api.github.com/users/SatelliteQE/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SatelliteQE/subscriptions","organizations_url":"https://api.github.com/users/SatelliteQE/orgs","repos_url":"https://api.github.com/users/SatelliteQE/repos","events_url":"https://api.github.com/users/SatelliteQE/events{/privacy}","received_events_url":"https://api.github.com/users/SatelliteQE/received_events","type":"Organization","site_admin":false},"repo":{"id":45935272,"name":"betelgeuse","full_name":"SatelliteQE/betelgeuse","owner":{"login":"SatelliteQE","id":8754276,"avatar_url":"https://avatars.githubusercontent.com/u/8754276?v=3","gravatar_id":"","url":"https://api.github.com/users/SatelliteQE","html_url":"https://github.com/SatelliteQE","followers_url":"https://api.github.com/users/SatelliteQE/followers","following_url":"https://api.github.com/users/SatelliteQE/following{/other_user}","gists_url":"https://api.github.com/users/SatelliteQE/gists{/gist_id}","starred_url":"https://api.github.com/users/SatelliteQE/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SatelliteQE/subscriptions","organizations_url":"https://api.github.com/users/SatelliteQE/orgs","repos_url":"https://api.github.com/users/SatelliteQE/repos","events_url":"https://api.github.com/users/SatelliteQE/events{/privacy}","received_events_url":"https://api.github.com/users/SatelliteQE/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/SatelliteQE/betelgeuse","description":"Betelgeuse reads standard Python test cases and offers tools   to interact with Polarion.","fork":false,"url":"https://api.github.com/repos/SatelliteQE/betelgeuse","forks_url":"https://api.github.com/repos/SatelliteQE/betelgeuse/forks","keys_url":"https://api.github.com/repos/SatelliteQE/betelgeuse/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SatelliteQE/betelgeuse/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SatelliteQE/betelgeuse/teams","hooks_url":"https://api.github.com/repos/SatelliteQE/betelgeuse/hooks","issue_events_url":"https://api.github.com/repos/SatelliteQE/betelgeuse/issues/events{/number}","events_url":"https://api.github.com/repos/SatelliteQE/betelgeuse/events","assignees_url":"https://api.github.com/repos/SatelliteQE/betelgeuse/assignees{/user}","branches_url":"https://api.github.com/repos/SatelliteQE/betelgeuse/branches{/branch}","tags_url":"https://api.github.com/repos/SatelliteQE/betelgeuse/tags","blobs_url":"https://api.github.com/repos/SatelliteQE/betelgeuse/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SatelliteQE/betelgeuse/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SatelliteQE/betelgeuse/git/refs{/sha}","trees_url":"https://api.github.com/repos/SatelliteQE/betelgeuse/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SatelliteQE/betelgeuse/statuses/{sha}","languages_url":"https://api.github.com/repos/SatelliteQE/betelgeuse/languages","stargazers_url":"https://api.github.com/repos/SatelliteQE/betelgeuse/stargazers","contributors_url":"https://api.github.com/repos/SatelliteQE/betelgeuse/contributors","subscribers_url":"https://api.github.com/repos/SatelliteQE/betelgeuse/subscribers","subscription_url":"https://api.github.com/repos/SatelliteQE/betelgeuse/subscription","commits_url":"https://api.github.com/repos/SatelliteQE/betelgeuse/commits{/sha}","git_commits_url":"https://api.github.com/repos/SatelliteQE/betelgeuse/git/commits{/sha}","comments_url":"https://api.github.com/repos/SatelliteQE/betelgeuse/comments{/number}","issue_comment_url":"https://api.github.com/repos/SatelliteQE/betelgeuse/issues/comments{/number}","contents_url":"https://api.github.com/repos/SatelliteQE/betelgeuse/contents/{+path}","compare_url":"https://api.github.com/repos/SatelliteQE/betelgeuse/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SatelliteQE/betelgeuse/merges","archive_url":"https://api.github.com/repos/SatelliteQE/betelgeuse/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SatelliteQE/betelgeuse/downloads","issues_url":"https://api.github.com/repos/SatelliteQE/betelgeuse/issues{/number}","pulls_url":"https://api.github.com/repos/SatelliteQE/betelgeuse/pulls{/number}","milestones_url":"https://api.github.com/repos/SatelliteQE/betelgeuse/milestones{/number}","notifications_url":"https://api.github.com/repos/SatelliteQE/betelgeuse/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SatelliteQE/betelgeuse/labels{/name}","releases_url":"https://api.github.com/repos/SatelliteQE/betelgeuse/releases{/id}","deployments_url":"https://api.github.com/repos/SatelliteQE/betelgeuse/deployments","created_at":"2015-11-10T19:30:12Z","updated_at":"2016-03-16T20:36:44Z","pushed_at":"2016-07-27T20:49:09Z","git_url":"git://github.com/SatelliteQE/betelgeuse.git","ssh_url":"git@github.com:SatelliteQE/betelgeuse.git","clone_url":"https://github.com/SatelliteQE/betelgeuse.git","svn_url":"https://github.com/SatelliteQE/betelgeuse","homepage":null,"size":124,"stargazers_count":3,"watchers_count":3,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":13,"forks":8,"open_issues":13,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/SatelliteQE/betelgeuse/pulls/69"},"html":{"href":"https://github.com/SatelliteQE/betelgeuse/pull/69"},"issue":{"href":"https://api.github.com/repos/SatelliteQE/betelgeuse/issues/69"},"comments":{"href":"https://api.github.com/repos/SatelliteQE/betelgeuse/issues/69/comments"},"review_comments":{"href":"https://api.github.com/repos/SatelliteQE/betelgeuse/pulls/69/comments"},"review_comment":{"href":"https://api.github.com/repos/SatelliteQE/betelgeuse/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/SatelliteQE/betelgeuse/pulls/69/commits"},"statuses":{"href":"https://api.github.com/repos/SatelliteQE/betelgeuse/statuses/de8d0a0750364ac0ef5fd12d433ecc9e3254174b"}}}}
{"actor":{"display_login":"elyezer"}}