{"action":"created","comment":{"url":"https://api.github.com/repos/saltstack/salt/pulls/comments/56088987","id":56088987,"diff_hunk":"@@ -0,0 +1,184 @@\n+# -*- coding: utf-8 -*-\n+'''\n+integration tests for mac_system\n+'''\n+\n+# Import python libs\n+from __future__ import absolute_import\n+import random\n+import string\n+\n+# Import Salt Testing libs\n+from salttesting.helpers import ensure_in_syspath, destructiveTest\n+from salt.ext.six.moves import range\n+ensure_in_syspath('../../')\n+\n+# Import salt libs\n+import integration\n+import salt.utils\n+\n+ATRUN_ENABLED = False\n+REMOTE_LOGIN_ENABLED = False\n+REMOTE_EVENTS_ENABLED = False\n+COMPUTER_NAME = ''\n+SUBNET_NAME = ''\n+KEYBOARD_DISABLED = False\n+SET_COMPUTER_NAME = __random_string()\n+SET_SUBNET_NAME = __random_string()\n+\n+\n+def __random_string(size=6):\n+    '''\n+    Generates a random username\n+    '''\n+    return 'RS-' + ''.join(\n+        random.choice(string.ascii_uppercase + string.digits)\n+        for x in range(size)\n+    )\n+\n+\n+class MacSystemModuleTest(integration.ModuleCase):\n+    '''\n+    Validate the mac_system module\n+    '''\n+\n+    def setUp(self):\n+        '''\n+        Get current settings\n+        '''\n+        if not salt.utils.is_darwin():\n+            self.skipTest('Test only available on Mac OS X')\n+\n+        if not salt.utils.which('systemsetup'):\n+            self.skipTest('Test requires systemsetup binary')\n+\n+        if not salt.utils.which('launchctl'):\n+            self.skipTest('Test requires launchctl binary')\n+\n+        if salt.utils.get_uid(salt.utils.get_user()) != 0:\n+            self.skipTest('Test requires root')\n+\n+        ATRUN_ENABLED = self.run_function('service.enabled',\n+                                          ['com.apple.atrun'])\n+        REMOTE_LOGIN_ENABLED = self.run_function('system.get_remote_login')\n+        REMOTE_EVENTS_ENABLED = self.run_function('system.get_remote_events')\n+        COMPUTER_NAME = self.run_function('system.get_computer_name')\n+        SUBNET_NAME = self.run_function('system.get_subnet_name')\n+        KEYBOARD_DISABLED = self.run_function(\n+            'system.get_disable_keyboard_on_lock')\n+\n+        super(MacSystemModuleTest, self).setUp()\n+\n+    def tearDown(self):\n+        '''\n+        Reset to original settings\n+        '''\n+        if not ATRUN_ENABLED:\n+            atrun = '/System/Library/LaunchDaemons/com.apple.atrun.plist'\n+            self.run_function('service.stop', [atrun])\n+\n+        self.run_function('system.set_remote_login', [REMOTE_LOGIN_ENABLED])\n+        self.run_function('system.set_remote_events', [REMOTE_EVENTS_ENABLED])\n+        self.run_function('system.set_computer_name', [COMPUTER_NAME])\n+        self.run_function('system.set_subnet_name', [SUBNET_NAME])\n+        self.run_function('system.set_disable_keyboard_on_lock',\n+                          [KEYBOARD_DISABLED])\n+\n+        super(MacSystemModuleTest, self).tearDown()\n+\n+    @destructiveTest\n+    def test_get_set_remote_login(self):\n+        '''\n+        Test system.get_remote_login\n+        Test system.set_remote_login\n+        '''\n+        self.run_function('system.set_remote_login', [True])\n+        self.assertTrue(self.run_function('system.get_remote_login'))","path":"tests/integration/modules/mac_system.py","position":96,"original_position":96,"commit_id":"f4493053eb669e239240e6e3423ae9d57b991238","original_commit_id":"f4493053eb669e239240e6e3423ae9d57b991238","user":{"login":"cachedout","id":111616,"avatar_url":"https://avatars.githubusercontent.com/u/111616?v=3","gravatar_id":"","url":"https://api.github.com/users/cachedout","html_url":"https://github.com/cachedout","followers_url":"https://api.github.com/users/cachedout/followers","following_url":"https://api.github.com/users/cachedout/following{/other_user}","gists_url":"https://api.github.com/users/cachedout/gists{/gist_id}","starred_url":"https://api.github.com/users/cachedout/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cachedout/subscriptions","organizations_url":"https://api.github.com/users/cachedout/orgs","repos_url":"https://api.github.com/users/cachedout/repos","events_url":"https://api.github.com/users/cachedout/events{/privacy}","received_events_url":"https://api.github.com/users/cachedout/received_events","type":"User","site_admin":false},"body":"This function appears to _always_ return True indicating that the command was run, versus actually looking at the actual return from the shell command. This may be a bug.","created_at":"2016-03-14T22:42:20Z","updated_at":"2016-03-14T22:42:20Z","html_url":"https://github.com/saltstack/salt/pull/31790#discussion_r56088987","pull_request_url":"https://api.github.com/repos/saltstack/salt/pulls/31790","_links":{"self":{"href":"https://api.github.com/repos/saltstack/salt/pulls/comments/56088987"},"html":{"href":"https://github.com/saltstack/salt/pull/31790#discussion_r56088987"},"pull_request":{"href":"https://api.github.com/repos/saltstack/salt/pulls/31790"}}},"pull_request":{"url":"https://api.github.com/repos/saltstack/salt/pulls/31790","id":62401148,"html_url":"https://github.com/saltstack/salt/pull/31790","diff_url":"https://github.com/saltstack/salt/pull/31790.diff","patch_url":"https://github.com/saltstack/salt/pull/31790.patch","issue_url":"https://api.github.com/repos/saltstack/salt/issues/31790","number":31790,"state":"open","locked":false,"title":"Integration tests for mac_system","user":{"login":"twangboy","id":9383935,"avatar_url":"https://avatars.githubusercontent.com/u/9383935?v=3","gravatar_id":"","url":"https://api.github.com/users/twangboy","html_url":"https://github.com/twangboy","followers_url":"https://api.github.com/users/twangboy/followers","following_url":"https://api.github.com/users/twangboy/following{/other_user}","gists_url":"https://api.github.com/users/twangboy/gists{/gist_id}","starred_url":"https://api.github.com/users/twangboy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twangboy/subscriptions","organizations_url":"https://api.github.com/users/twangboy/orgs","repos_url":"https://api.github.com/users/twangboy/repos","events_url":"https://api.github.com/users/twangboy/events{/privacy}","received_events_url":"https://api.github.com/users/twangboy/received_events","type":"User","site_admin":false},"body":"### What does this PR do?\r\nAdds integration tests for `mac_system.py` execution module\r\nFixes `service.start` and `service.stop` functions in mac_service\r\n`mac_system.py` now uses `mac_utils.py`\r\n\r\n### What issues does this PR fix or reference?\r\nhttps://github.com/saltstack/zh/issues/553\r\n\r\n### Previous Behavior\r\n`service.start` and `service.stop` incorrectly checked `service.get_all` to see if the service was already enabled.\r\n`mac_system.py` used incorrect import method: `from salt.utils.mac_utils import validate_enabled, parse_return, execute_return_success, execute_return_results`\r\n\r\n### New Behavior\r\n`service.start` and `service.stop` now use `service._get_enabled` to see if the service is already running\r\n`mac_system.py` now uses correct import method: `import salt.utils.mac_utils`\r\n\r\n### Tests written?\r\n- [x] Yes\r\n- [ ] No\r\n","created_at":"2016-03-10T14:55:54Z","updated_at":"2016-03-14T22:42:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fb6718a12d564bf48f149278603c7a9344e00f6c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/saltstack/salt/pulls/31790/commits","review_comments_url":"https://api.github.com/repos/saltstack/salt/pulls/31790/comments","review_comment_url":"https://api.github.com/repos/saltstack/salt/pulls/comments{/number}","comments_url":"https://api.github.com/repos/saltstack/salt/issues/31790/comments","statuses_url":"https://api.github.com/repos/saltstack/salt/statuses/f4493053eb669e239240e6e3423ae9d57b991238","head":{"label":"twangboy:mac_system_int","ref":"mac_system_int","sha":"f4493053eb669e239240e6e3423ae9d57b991238","user":{"login":"twangboy","id":9383935,"avatar_url":"https://avatars.githubusercontent.com/u/9383935?v=3","gravatar_id":"","url":"https://api.github.com/users/twangboy","html_url":"https://github.com/twangboy","followers_url":"https://api.github.com/users/twangboy/followers","following_url":"https://api.github.com/users/twangboy/following{/other_user}","gists_url":"https://api.github.com/users/twangboy/gists{/gist_id}","starred_url":"https://api.github.com/users/twangboy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twangboy/subscriptions","organizations_url":"https://api.github.com/users/twangboy/orgs","repos_url":"https://api.github.com/users/twangboy/repos","events_url":"https://api.github.com/users/twangboy/events{/privacy}","received_events_url":"https://api.github.com/users/twangboy/received_events","type":"User","site_admin":false},"repo":{"id":52046096,"name":"salt","full_name":"twangboy/salt","owner":{"login":"twangboy","id":9383935,"avatar_url":"https://avatars.githubusercontent.com/u/9383935?v=3","gravatar_id":"","url":"https://api.github.com/users/twangboy","html_url":"https://github.com/twangboy","followers_url":"https://api.github.com/users/twangboy/followers","following_url":"https://api.github.com/users/twangboy/following{/other_user}","gists_url":"https://api.github.com/users/twangboy/gists{/gist_id}","starred_url":"https://api.github.com/users/twangboy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twangboy/subscriptions","organizations_url":"https://api.github.com/users/twangboy/orgs","repos_url":"https://api.github.com/users/twangboy/repos","events_url":"https://api.github.com/users/twangboy/events{/privacy}","received_events_url":"https://api.github.com/users/twangboy/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/twangboy/salt","description":"Software to automate the management and configuration of any infrastructure or application at scale. Get access to the Salt Open software package repository here: ","fork":true,"url":"https://api.github.com/repos/twangboy/salt","forks_url":"https://api.github.com/repos/twangboy/salt/forks","keys_url":"https://api.github.com/repos/twangboy/salt/keys{/key_id}","collaborators_url":"https://api.github.com/repos/twangboy/salt/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/twangboy/salt/teams","hooks_url":"https://api.github.com/repos/twangboy/salt/hooks","issue_events_url":"https://api.github.com/repos/twangboy/salt/issues/events{/number}","events_url":"https://api.github.com/repos/twangboy/salt/events","assignees_url":"https://api.github.com/repos/twangboy/salt/assignees{/user}","branches_url":"https://api.github.com/repos/twangboy/salt/branches{/branch}","tags_url":"https://api.github.com/repos/twangboy/salt/tags","blobs_url":"https://api.github.com/repos/twangboy/salt/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/twangboy/salt/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/twangboy/salt/git/refs{/sha}","trees_url":"https://api.github.com/repos/twangboy/salt/git/trees{/sha}","statuses_url":"https://api.github.com/repos/twangboy/salt/statuses/{sha}","languages_url":"https://api.github.com/repos/twangboy/salt/languages","stargazers_url":"https://api.github.com/repos/twangboy/salt/stargazers","contributors_url":"https://api.github.com/repos/twangboy/salt/contributors","subscribers_url":"https://api.github.com/repos/twangboy/salt/subscribers","subscription_url":"https://api.github.com/repos/twangboy/salt/subscription","commits_url":"https://api.github.com/repos/twangboy/salt/commits{/sha}","git_commits_url":"https://api.github.com/repos/twangboy/salt/git/commits{/sha}","comments_url":"https://api.github.com/repos/twangboy/salt/comments{/number}","issue_comment_url":"https://api.github.com/repos/twangboy/salt/issues/comments{/number}","contents_url":"https://api.github.com/repos/twangboy/salt/contents/{+path}","compare_url":"https://api.github.com/repos/twangboy/salt/compare/{base}...{head}","merges_url":"https://api.github.com/repos/twangboy/salt/merges","archive_url":"https://api.github.com/repos/twangboy/salt/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/twangboy/salt/downloads","issues_url":"https://api.github.com/repos/twangboy/salt/issues{/number}","pulls_url":"https://api.github.com/repos/twangboy/salt/pulls{/number}","milestones_url":"https://api.github.com/repos/twangboy/salt/milestones{/number}","notifications_url":"https://api.github.com/repos/twangboy/salt/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/twangboy/salt/labels{/name}","releases_url":"https://api.github.com/repos/twangboy/salt/releases{/id}","deployments_url":"https://api.github.com/repos/twangboy/salt/deployments","created_at":"2016-02-18T23:18:37Z","updated_at":"2016-02-18T23:18:49Z","pushed_at":"2016-03-12T02:31:15Z","git_url":"git://github.com/twangboy/salt.git","ssh_url":"git@github.com:twangboy/salt.git","clone_url":"https://github.com/twangboy/salt.git","svn_url":"https://github.com/twangboy/salt","homepage":"https://repo.saltstack.com/","size":151287,"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":"develop"}},"base":{"label":"saltstack:2016.3","ref":"2016.3","sha":"5424159604726aa187de0ff6129e8cd0d0a5030a","user":{"login":"saltstack","id":1147473,"avatar_url":"https://avatars.githubusercontent.com/u/1147473?v=3","gravatar_id":"","url":"https://api.github.com/users/saltstack","html_url":"https://github.com/saltstack","followers_url":"https://api.github.com/users/saltstack/followers","following_url":"https://api.github.com/users/saltstack/following{/other_user}","gists_url":"https://api.github.com/users/saltstack/gists{/gist_id}","starred_url":"https://api.github.com/users/saltstack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saltstack/subscriptions","organizations_url":"https://api.github.com/users/saltstack/orgs","repos_url":"https://api.github.com/users/saltstack/repos","events_url":"https://api.github.com/users/saltstack/events{/privacy}","received_events_url":"https://api.github.com/users/saltstack/received_events","type":"Organization","site_admin":false},"repo":{"id":1390248,"name":"salt","full_name":"saltstack/salt","owner":{"login":"saltstack","id":1147473,"avatar_url":"https://avatars.githubusercontent.com/u/1147473?v=3","gravatar_id":"","url":"https://api.github.com/users/saltstack","html_url":"https://github.com/saltstack","followers_url":"https://api.github.com/users/saltstack/followers","following_url":"https://api.github.com/users/saltstack/following{/other_user}","gists_url":"https://api.github.com/users/saltstack/gists{/gist_id}","starred_url":"https://api.github.com/users/saltstack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saltstack/subscriptions","organizations_url":"https://api.github.com/users/saltstack/orgs","repos_url":"https://api.github.com/users/saltstack/repos","events_url":"https://api.github.com/users/saltstack/events{/privacy}","received_events_url":"https://api.github.com/users/saltstack/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/saltstack/salt","description":"Software to automate the management and configuration of any infrastructure or application at scale. Get access to the Salt Open software package repository here: ","fork":false,"url":"https://api.github.com/repos/saltstack/salt","forks_url":"https://api.github.com/repos/saltstack/salt/forks","keys_url":"https://api.github.com/repos/saltstack/salt/keys{/key_id}","collaborators_url":"https://api.github.com/repos/saltstack/salt/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/saltstack/salt/teams","hooks_url":"https://api.github.com/repos/saltstack/salt/hooks","issue_events_url":"https://api.github.com/repos/saltstack/salt/issues/events{/number}","events_url":"https://api.github.com/repos/saltstack/salt/events","assignees_url":"https://api.github.com/repos/saltstack/salt/assignees{/user}","branches_url":"https://api.github.com/repos/saltstack/salt/branches{/branch}","tags_url":"https://api.github.com/repos/saltstack/salt/tags","blobs_url":"https://api.github.com/repos/saltstack/salt/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/saltstack/salt/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/saltstack/salt/git/refs{/sha}","trees_url":"https://api.github.com/repos/saltstack/salt/git/trees{/sha}","statuses_url":"https://api.github.com/repos/saltstack/salt/statuses/{sha}","languages_url":"https://api.github.com/repos/saltstack/salt/languages","stargazers_url":"https://api.github.com/repos/saltstack/salt/stargazers","contributors_url":"https://api.github.com/repos/saltstack/salt/contributors","subscribers_url":"https://api.github.com/repos/saltstack/salt/subscribers","subscription_url":"https://api.github.com/repos/saltstack/salt/subscription","commits_url":"https://api.github.com/repos/saltstack/salt/commits{/sha}","git_commits_url":"https://api.github.com/repos/saltstack/salt/git/commits{/sha}","comments_url":"https://api.github.com/repos/saltstack/salt/comments{/number}","issue_comment_url":"https://api.github.com/repos/saltstack/salt/issues/comments{/number}","contents_url":"https://api.github.com/repos/saltstack/salt/contents/{+path}","compare_url":"https://api.github.com/repos/saltstack/salt/compare/{base}...{head}","merges_url":"https://api.github.com/repos/saltstack/salt/merges","archive_url":"https://api.github.com/repos/saltstack/salt/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/saltstack/salt/downloads","issues_url":"https://api.github.com/repos/saltstack/salt/issues{/number}","pulls_url":"https://api.github.com/repos/saltstack/salt/pulls{/number}","milestones_url":"https://api.github.com/repos/saltstack/salt/milestones{/number}","notifications_url":"https://api.github.com/repos/saltstack/salt/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/saltstack/salt/labels{/name}","releases_url":"https://api.github.com/repos/saltstack/salt/releases{/id}","deployments_url":"https://api.github.com/repos/saltstack/salt/deployments","created_at":"2011-02-20T20:16:56Z","updated_at":"2016-03-14T14:32:45Z","pushed_at":"2016-03-14T22:40:22Z","git_url":"git://github.com/saltstack/salt.git","ssh_url":"git@github.com:saltstack/salt.git","clone_url":"https://github.com/saltstack/salt.git","svn_url":"https://github.com/saltstack/salt","homepage":"https://repo.saltstack.com/","size":166783,"stargazers_count":6317,"watchers_count":6317,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2768,"mirror_url":null,"open_issues_count":3434,"forks":2768,"open_issues":3434,"watchers":6317,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/saltstack/salt/pulls/31790"},"html":{"href":"https://github.com/saltstack/salt/pull/31790"},"issue":{"href":"https://api.github.com/repos/saltstack/salt/issues/31790"},"comments":{"href":"https://api.github.com/repos/saltstack/salt/issues/31790/comments"},"review_comments":{"href":"https://api.github.com/repos/saltstack/salt/pulls/31790/comments"},"review_comment":{"href":"https://api.github.com/repos/saltstack/salt/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/saltstack/salt/pulls/31790/commits"},"statuses":{"href":"https://api.github.com/repos/saltstack/salt/statuses/f4493053eb669e239240e6e3423ae9d57b991238"}}}}