{"action":"created","comment":{"url":"https://api.github.com/repos/SatelliteQE/robottelo/pulls/comments/34678173","id":34678173,"diff_hunk":"@@ -0,0 +1,166 @@\n+\"\"\"Tests for Red Hat Access Insights\n+\"\"\"\n+\n+from robottelo.test import UITestCase\n+from fauxfactory import gen_string\n+from robottelo.ui.session import Session\n+from robottelo.common import conf\n+from robottelo.vm import VirtualMachine\n+from robottelo.common import manifests\n+from robottelo.ui.navigator import Navigator\n+from nailgun import entities, entity_mixins\n+from unittest import TestCase\n+from robottelo.common.constants import (\n+    DEFAULT_SUBSCRIPTION_NAME,\n+)\n+\n+\n+class RHAITestCase(UITestCase, TestCase):\n+    def test_rhai_client_setup(self):\n+        # only needed if playing outside Robottelo\n+        # entity_mixins.CREATE_MISSING = True\n+\n+        activation_key_name = gen_string('alpha')\n+\n+        # Create a new organization with prefix 'insights'\n+        org = entities.Organization(\n+            name='insights_{0}'.format(gen_string(\"alpha\", 6))\n+        ).create()\n+\n+        # Create new lifecycle environment\n+        lifecycle_env = entities.LifecycleEnvironment(\n+            name='rhai_env_{0}'.format(gen_string(\"alpha\", 6)),\n+            organization=org.id\n+        ).create()\n+\n+        # Upload manifest\n+        manifest_path = manifests.clone()\n+        org.upload_manifest(path=manifest_path)\n+\n+        # Create a custom product for RHAI\n+        custom_product = entities.Product(\n+            name='rhai_product_{0}'.format(gen_string(\"alpha\", 6)),\n+            organization=org\n+        ).create()\n+\n+        # Add insights repo to the custom product\n+        custom_repo = entities.Repository(\n+            name='insights_repo_{0}'.format(gen_string(\"alpha\", 6)),\n+            product=custom_product, content_type=u'yum',\n+            url=u'http://access.redhat.com/insights/repo/6/'\n+        ).create()\n+\n+        # Sync custom repository\n+        custom_repo.sync()\n+\n+        # Create content view\n+        content_view = entities.ContentView(\n+            name='rhai_cv_{0}'.format(gen_string(\"alpha\", 6)),\n+            organization=org\n+        ).create()\n+\n+        # Associate custom repository to new content view\n+        content_view.set_repository_ids([custom_repo.id])\n+\n+        # Publish content view\n+        content_view.publish()\n+\n+        # Promote content view to lifecycle_env\n+        versions = content_view.read_json()['versions']\n+        self.assertEqual(len(versions), 1)\n+        entities.ContentViewVersion(\n+            id=versions[0]['id']\n+        ).promote(lifecycle_env.id)\n+\n+        # Create activation key\n+        activation_key = entities.ActivationKey(\n+            auto_attach=True,\n+            name=activation_key_name,\n+            environment=lifecycle_env.id,\n+            organization=org.id,\n+            content_view=content_view.id,\n+        ).create()\n+\n+        # Walk through the list of subscriptions.\n+        # Find the \"Red Hat Employee Subscription\" and attach it to the\n+        # recently-created activation key.\n+        for subscription in org.subscriptions():\n+            if subscription['product_name'] == DEFAULT_SUBSCRIPTION_NAME:\n+                # 'quantity' must be 1, not subscription['quantity']. Greater\n+                # values produce this error: \"RuntimeError: Error: Only pools\n+                # with multi-entitlement product subscriptions can be added to\n+                # the activation key with a quantity greater than one.\"\n+                activation_key.add_subscriptions({\n+                    'quantity': 1,\n+                    'subscription_id': subscription['id'],\n+                })\n+\n+            # Attach custom product subscription to the activation key\n+            if subscription['product_name'] == custom_product.name:\n+                activation_key.add_subscriptions({\n+                    'quantity': 1,\n+                    'subscription_id': subscription['id'],\n+                })\n+                break\n+\n+        # Create VM\n+        vm = VirtualMachine(distro='rhel66')\n+        vm.create()\n+\n+        print vm.ip_addr\n+        print vm.hostname\n+\n+        # Download and Install ketello-ca rpm\n+        result = vm.run(\n+            \"wget -nd -r -l1 --no-parent -A '*.noarch.rpm' http://{0}/pub/\".\n+            format(self.server_name))","path":"tests/foreman/ui/test_rhai.py","position":116,"original_position":116,"commit_id":"bf6c41f2265014df7e90cbed3855bec42c9dce33","original_commit_id":"bf6c41f2265014df7e90cbed3855bec42c9dce33","user":{"login":"Ichimonji10","id":1012989,"avatar_url":"https://avatars.githubusercontent.com/u/1012989?v=3","gravatar_id":"","url":"https://api.github.com/users/Ichimonji10","html_url":"https://github.com/Ichimonji10","followers_url":"https://api.github.com/users/Ichimonji10/followers","following_url":"https://api.github.com/users/Ichimonji10/following{/other_user}","gists_url":"https://api.github.com/users/Ichimonji10/gists{/gist_id}","starred_url":"https://api.github.com/users/Ichimonji10/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ichimonji10/subscriptions","organizations_url":"https://api.github.com/users/Ichimonji10/orgs","repos_url":"https://api.github.com/users/Ichimonji10/repos","events_url":"https://api.github.com/users/Ichimonji10/events{/privacy}","received_events_url":"https://api.github.com/users/Ichimonji10/received_events","type":"User","site_admin":false},"body":"Please reformat:\r\n\r\n```python\r\n        result = vm.run(\r\n            \"wget -nd -r -l1 --no-parent -A '*.noarch.rpm' http://{0}/pub/\"\r\n            .format(self.server_name)\r\n        )\r\n```","created_at":"2015-07-15T13:37:24Z","updated_at":"2015-07-15T13:37:24Z","html_url":"https://github.com/SatelliteQE/robottelo/pull/2567#discussion_r34678173","pull_request_url":"https://api.github.com/repos/SatelliteQE/robottelo/pulls/2567","_links":{"self":{"href":"https://api.github.com/repos/SatelliteQE/robottelo/pulls/comments/34678173"},"html":{"href":"https://github.com/SatelliteQE/robottelo/pull/2567#discussion_r34678173"},"pull_request":{"href":"https://api.github.com/repos/SatelliteQE/robottelo/pulls/2567"}}},"pull_request":{"url":"https://api.github.com/repos/SatelliteQE/robottelo/pulls/2567","id":39920082,"html_url":"https://github.com/SatelliteQE/robottelo/pull/2567","diff_url":"https://github.com/SatelliteQE/robottelo/pull/2567.diff","patch_url":"https://github.com/SatelliteQE/robottelo/pull/2567.patch","issue_url":"https://api.github.com/repos/SatelliteQE/robottelo/issues/2567","number":2567,"state":"open","locked":false,"title":"Initial test for registering a client to redhat-access-insights service","user":{"login":"anarang","id":2485885,"avatar_url":"https://avatars.githubusercontent.com/u/2485885?v=3","gravatar_id":"","url":"https://api.github.com/users/anarang","html_url":"https://github.com/anarang","followers_url":"https://api.github.com/users/anarang/followers","following_url":"https://api.github.com/users/anarang/following{/other_user}","gists_url":"https://api.github.com/users/anarang/gists{/gist_id}","starred_url":"https://api.github.com/users/anarang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anarang/subscriptions","organizations_url":"https://api.github.com/users/anarang/orgs","repos_url":"https://api.github.com/users/anarang/repos","events_url":"https://api.github.com/users/anarang/events{/privacy}","received_events_url":"https://api.github.com/users/anarang/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-07-14T14:17:00Z","updated_at":"2015-07-15T13:37:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e02e6abd70b447c82c893ca3f67c84126e36b0fc","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/SatelliteQE/robottelo/pulls/2567/commits","review_comments_url":"https://api.github.com/repos/SatelliteQE/robottelo/pulls/2567/comments","review_comment_url":"https://api.github.com/repos/SatelliteQE/robottelo/pulls/comments{/number}","comments_url":"https://api.github.com/repos/SatelliteQE/robottelo/issues/2567/comments","statuses_url":"https://api.github.com/repos/SatelliteQE/robottelo/statuses/bf6c41f2265014df7e90cbed3855bec42c9dce33","head":{"label":"anarang:rhai","ref":"rhai","sha":"bf6c41f2265014df7e90cbed3855bec42c9dce33","user":{"login":"anarang","id":2485885,"avatar_url":"https://avatars.githubusercontent.com/u/2485885?v=3","gravatar_id":"","url":"https://api.github.com/users/anarang","html_url":"https://github.com/anarang","followers_url":"https://api.github.com/users/anarang/followers","following_url":"https://api.github.com/users/anarang/following{/other_user}","gists_url":"https://api.github.com/users/anarang/gists{/gist_id}","starred_url":"https://api.github.com/users/anarang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anarang/subscriptions","organizations_url":"https://api.github.com/users/anarang/orgs","repos_url":"https://api.github.com/users/anarang/repos","events_url":"https://api.github.com/users/anarang/events{/privacy}","received_events_url":"https://api.github.com/users/anarang/received_events","type":"User","site_admin":false},"repo":{"id":38251875,"name":"robottelo","full_name":"anarang/robottelo","owner":{"login":"anarang","id":2485885,"avatar_url":"https://avatars.githubusercontent.com/u/2485885?v=3","gravatar_id":"","url":"https://api.github.com/users/anarang","html_url":"https://github.com/anarang","followers_url":"https://api.github.com/users/anarang/followers","following_url":"https://api.github.com/users/anarang/following{/other_user}","gists_url":"https://api.github.com/users/anarang/gists{/gist_id}","starred_url":"https://api.github.com/users/anarang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anarang/subscriptions","organizations_url":"https://api.github.com/users/anarang/orgs","repos_url":"https://api.github.com/users/anarang/repos","events_url":"https://api.github.com/users/anarang/events{/privacy}","received_events_url":"https://api.github.com/users/anarang/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/anarang/robottelo","description":"Robottelo is a test suite which exercises The Foreman.","fork":true,"url":"https://api.github.com/repos/anarang/robottelo","forks_url":"https://api.github.com/repos/anarang/robottelo/forks","keys_url":"https://api.github.com/repos/anarang/robottelo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/anarang/robottelo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/anarang/robottelo/teams","hooks_url":"https://api.github.com/repos/anarang/robottelo/hooks","issue_events_url":"https://api.github.com/repos/anarang/robottelo/issues/events{/number}","events_url":"https://api.github.com/repos/anarang/robottelo/events","assignees_url":"https://api.github.com/repos/anarang/robottelo/assignees{/user}","branches_url":"https://api.github.com/repos/anarang/robottelo/branches{/branch}","tags_url":"https://api.github.com/repos/anarang/robottelo/tags","blobs_url":"https://api.github.com/repos/anarang/robottelo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/anarang/robottelo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/anarang/robottelo/git/refs{/sha}","trees_url":"https://api.github.com/repos/anarang/robottelo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/anarang/robottelo/statuses/{sha}","languages_url":"https://api.github.com/repos/anarang/robottelo/languages","stargazers_url":"https://api.github.com/repos/anarang/robottelo/stargazers","contributors_url":"https://api.github.com/repos/anarang/robottelo/contributors","subscribers_url":"https://api.github.com/repos/anarang/robottelo/subscribers","subscription_url":"https://api.github.com/repos/anarang/robottelo/subscription","commits_url":"https://api.github.com/repos/anarang/robottelo/commits{/sha}","git_commits_url":"https://api.github.com/repos/anarang/robottelo/git/commits{/sha}","comments_url":"https://api.github.com/repos/anarang/robottelo/comments{/number}","issue_comment_url":"https://api.github.com/repos/anarang/robottelo/issues/comments{/number}","contents_url":"https://api.github.com/repos/anarang/robottelo/contents/{+path}","compare_url":"https://api.github.com/repos/anarang/robottelo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/anarang/robottelo/merges","archive_url":"https://api.github.com/repos/anarang/robottelo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/anarang/robottelo/downloads","issues_url":"https://api.github.com/repos/anarang/robottelo/issues{/number}","pulls_url":"https://api.github.com/repos/anarang/robottelo/pulls{/number}","milestones_url":"https://api.github.com/repos/anarang/robottelo/milestones{/number}","notifications_url":"https://api.github.com/repos/anarang/robottelo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/anarang/robottelo/labels{/name}","releases_url":"https://api.github.com/repos/anarang/robottelo/releases{/id}","created_at":"2015-06-29T14:25:28Z","updated_at":"2015-06-29T14:25:30Z","pushed_at":"2015-07-15T10:09:12Z","git_url":"git://github.com/anarang/robottelo.git","ssh_url":"git@github.com:anarang/robottelo.git","clone_url":"https://github.com/anarang/robottelo.git","svn_url":"https://github.com/anarang/robottelo","homepage":"","size":8230,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"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":"c2b91920a66dfa248200ddf03e02f6c993d97783","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":4000279,"name":"robottelo","full_name":"SatelliteQE/robottelo","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/robottelo","description":"Robottelo is a test suite which exercises The Foreman.","fork":false,"url":"https://api.github.com/repos/SatelliteQE/robottelo","forks_url":"https://api.github.com/repos/SatelliteQE/robottelo/forks","keys_url":"https://api.github.com/repos/SatelliteQE/robottelo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SatelliteQE/robottelo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SatelliteQE/robottelo/teams","hooks_url":"https://api.github.com/repos/SatelliteQE/robottelo/hooks","issue_events_url":"https://api.github.com/repos/SatelliteQE/robottelo/issues/events{/number}","events_url":"https://api.github.com/repos/SatelliteQE/robottelo/events","assignees_url":"https://api.github.com/repos/SatelliteQE/robottelo/assignees{/user}","branches_url":"https://api.github.com/repos/SatelliteQE/robottelo/branches{/branch}","tags_url":"https://api.github.com/repos/SatelliteQE/robottelo/tags","blobs_url":"https://api.github.com/repos/SatelliteQE/robottelo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SatelliteQE/robottelo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SatelliteQE/robottelo/git/refs{/sha}","trees_url":"https://api.github.com/repos/SatelliteQE/robottelo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SatelliteQE/robottelo/statuses/{sha}","languages_url":"https://api.github.com/repos/SatelliteQE/robottelo/languages","stargazers_url":"https://api.github.com/repos/SatelliteQE/robottelo/stargazers","contributors_url":"https://api.github.com/repos/SatelliteQE/robottelo/contributors","subscribers_url":"https://api.github.com/repos/SatelliteQE/robottelo/subscribers","subscription_url":"https://api.github.com/repos/SatelliteQE/robottelo/subscription","commits_url":"https://api.github.com/repos/SatelliteQE/robottelo/commits{/sha}","git_commits_url":"https://api.github.com/repos/SatelliteQE/robottelo/git/commits{/sha}","comments_url":"https://api.github.com/repos/SatelliteQE/robottelo/comments{/number}","issue_comment_url":"https://api.github.com/repos/SatelliteQE/robottelo/issues/comments{/number}","contents_url":"https://api.github.com/repos/SatelliteQE/robottelo/contents/{+path}","compare_url":"https://api.github.com/repos/SatelliteQE/robottelo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SatelliteQE/robottelo/merges","archive_url":"https://api.github.com/repos/SatelliteQE/robottelo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SatelliteQE/robottelo/downloads","issues_url":"https://api.github.com/repos/SatelliteQE/robottelo/issues{/number}","pulls_url":"https://api.github.com/repos/SatelliteQE/robottelo/pulls{/number}","milestones_url":"https://api.github.com/repos/SatelliteQE/robottelo/milestones{/number}","notifications_url":"https://api.github.com/repos/SatelliteQE/robottelo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SatelliteQE/robottelo/labels{/name}","releases_url":"https://api.github.com/repos/SatelliteQE/robottelo/releases{/id}","created_at":"2012-04-12T01:36:39Z","updated_at":"2015-06-23T17:21:41Z","pushed_at":"2015-07-15T13:21:51Z","git_url":"git://github.com/SatelliteQE/robottelo.git","ssh_url":"git@github.com:SatelliteQE/robottelo.git","clone_url":"https://github.com/SatelliteQE/robottelo.git","svn_url":"https://github.com/SatelliteQE/robottelo","homepage":"","size":17801,"stargazers_count":22,"watchers_count":22,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":29,"mirror_url":null,"open_issues_count":202,"forks":29,"open_issues":202,"watchers":22,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/SatelliteQE/robottelo/pulls/2567"},"html":{"href":"https://github.com/SatelliteQE/robottelo/pull/2567"},"issue":{"href":"https://api.github.com/repos/SatelliteQE/robottelo/issues/2567"},"comments":{"href":"https://api.github.com/repos/SatelliteQE/robottelo/issues/2567/comments"},"review_comments":{"href":"https://api.github.com/repos/SatelliteQE/robottelo/pulls/2567/comments"},"review_comment":{"href":"https://api.github.com/repos/SatelliteQE/robottelo/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/SatelliteQE/robottelo/pulls/2567/commits"},"statuses":{"href":"https://api.github.com/repos/SatelliteQE/robottelo/statuses/bf6c41f2265014df7e90cbed3855bec42c9dce33"}}}}