{"action":"created","comment":{"url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/pulls/comments/47270392","id":47270392,"diff_hunk":"@@ -0,0 +1,202 @@\n+#!/usr/bin/env python\n+# -- encoding: utf-8 --\n+#\n+# Copyright 2015 Telefónica Investigación y Desarrollo, S.A.U\n+#\n+# This file is part of FI-Core project.\n+#\n+# Licensed under the Apache License, Version 2.0 (the \"License\");\n+# you may not use this file except in compliance with the License.\n+#\n+# You may obtain a copy of the License at:\n+#\n+# http://www.apache.org/licenses/LICENSE-2.0\n+#\n+# Unless required by applicable law or agreed to in writing, software\n+# distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+#\n+# See the License for the specific language governing permissions and\n+# limitations under the License.\n+#\n+# For those usages not covered by the Apache version 2.0 License please\n+# contact with opensource@tid.es\n+#\n+__author__ = 'chema'\n+\n+from mock import MagicMock, patch, call, ANY\n+import unittest\n+import datetime\n+import os\n+import logging\n+import time\n+\n+from sync import Sync\n+\n+class TestSync(unittest.TestCase):\n+    \"\"\"Class to test all methods but constructor and parallel sync\"\"\"\n+    @patch('sync.GlanceSync', auto_spec=True)\n+    def setUp(self, glancesync):\n+        \"\"\"create constructor, mock with glancesync, Set a master region\"\"\"\n+        self.regions = []\n+        self.sync = Sync(self.regions)\n+        self.glancesync = glancesync\n+        config = {'return_value.master_region': 'MasterRegion'}\n+        self.glancesync.configure_mock(**config)\n+\n+    def test_report_status(self):\n+        \"\"\"check that calls to export_sync_region_status are done\"\"\"\n+        self.sync.regions = ['region1', 'region2']\n+        self.sync.report_status()\n+        calls = [call('region1', ANY), call('region2', ANY)]\n+        self.glancesync.return_value.export_sync_region_status.\\\n+            assert_has_calls(calls)\n+\n+    def test_sequential_sync(self):\n+        \"\"\"check that calls to sync_region are done\"\"\"\n+        self.sync.regions = ['region1', 'region2']\n+        self.sync.sequential_sync(dry_run=True)\n+        calls = [call('region1', dry_run=True), call('region2', dry_run=True)]\n+        self.glancesync.return_value.sync_region.assert_has_calls(calls)\n+\n+    def test_show_regions(self):\n+        \"\"\"check that calls to get_regions are done\"\"\"\n+        targets = {'master': None, 'other_target': None}\n+        config = {'return_value.targets': targets}\n+        self.glancesync.configure_mock(**config)\n+        self.sync.show_regions()\n+        calls = [call(), call(target='other_target')]\n+        self.glancesync.return_value.get_regions.assert_has_calls(calls)\n+\n+    @patch('sync.os')\n+    @patch('sync.datetime')\n+    def test_make_backup(self, datetime_mock, os_mock):\n+        \"\"\"check make backup; calls are correct and mkdir is invoked with\n+        right parameters\"\"\"\n+        datetime_str = '2020-02-06T23:57:09.205378'\n+        config = {'datetime.now.return_value.isoformat.return_value':\n+                  datetime_str}\n+        datetime_mock.configure_mock(**config)\n+        self.sync.make_backup()\n+        dir_name = 'backup_glance_' + datetime_str\n+        os_mock.mkdir.assert_called_with(dir_name)\n+        self.glancesync.return_value.backup_glancemetadata_region.\\\n+            assert_called_with('MasterRegion', dir_name)\n+\n+class TestSyncConstr(unittest.TestCase):\n+    \"\"\"tests to check constructor, the expansion of the target and the\n+    configuration parameter preferable_order\"\"\"\n+\n+    def setUp(self):\n+        \"\"\"prepare configuration for the mock: there are two targets, master\n+        with regions r1 and r2 y other with other:r1. The preferable order\n+        is other:r1, r2, r1.\"\"\"\n+        regions = {'master': ['r1', 'r2'], 'other': ['other:r1']}\n+        self.config = {\n+            'return_value.get_regions.side_effect': lambda target='master':\n+                regions[target],\n+            'return_value.preferable_order': ['other:r1', 'r2', 'r3']\n+        }\n+\n+    @patch('sync.GlanceSync', auto_spec=True)\n+    def test_constructor_simple(self, glancesync):\n+        \"\"\"test constructor without regions\"\"\"\n+        glancesync.configure_mock(**self.config)\n+        sync = Sync([])\n+        self.assertEqual(['r2', 'r1'], sync.regions)\n+\n+    @patch('sync.GlanceSync', auto_spec=True)\n+    def test_constructor_targets(self, glancesync):\n+        \"\"\"test constructor with two targets\"\"\"\n+        glancesync.configure_mock(**self.config)\n+        sync = Sync(['master:', 'other:'])\n+        self.assertEqual(['other:r1', 'r2', 'r1'], sync.regions)\n+\n+    @patch('sync.GlanceSync', auto_spec=True)\n+    def test_constructor_mix(self, glancesync):\n+        \"\"\"test constructor with a target and a region\"\"\"\n+        glancesync.configure_mock(**self.config)\n+        sync = Sync(['r1', 'other:'])\n+        self.assertEqual(['other:r1', 'r1'], sync.regions)\n+\n+    @patch('sync.GlanceSync', auto_spec=True)\n+    def test_constructor_ignore_order(self, glancesync):\n+        \"\"\"test a constructor with a list of regions. Preferable order should\n+        be ignored\"\"\"\n+        glancesync.configure_mock(**self.config)\n+        sync = Sync(['r1', 'r2', 'other:r1'])\n+        self.assertEqual(['r1', 'r2', 'other:r1'], sync.regions)\n+","path":"tests/unit/test_sync.py","position":129,"original_position":129,"commit_id":"9f5bb732e0784fc4bc73b37fc935f48650a5e01f","original_commit_id":"9f5bb732e0784fc4bc73b37fc935f48650a5e01f","user":{"login":"flopezag","id":1379796,"avatar_url":"https://avatars.githubusercontent.com/u/1379796?v=3","gravatar_id":"","url":"https://api.github.com/users/flopezag","html_url":"https://github.com/flopezag","followers_url":"https://api.github.com/users/flopezag/followers","following_url":"https://api.github.com/users/flopezag/following{/other_user}","gists_url":"https://api.github.com/users/flopezag/gists{/gist_id}","starred_url":"https://api.github.com/users/flopezag/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flopezag/subscriptions","organizations_url":"https://api.github.com/users/flopezag/orgs","repos_url":"https://api.github.com/users/flopezag/repos","events_url":"https://api.github.com/users/flopezag/events{/privacy}","received_events_url":"https://api.github.com/users/flopezag/received_events","type":"User","site_admin":false},"body":"add new line, before a class declaration there should be 2 blank spaces.","created_at":"2015-12-10T19:14:33Z","updated_at":"2015-12-10T19:14:33Z","html_url":"https://github.com/telefonicaid/fiware-glancesync/pull/50#discussion_r47270392","pull_request_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/pulls/50","_links":{"self":{"href":"https://api.github.com/repos/telefonicaid/fiware-glancesync/pulls/comments/47270392"},"html":{"href":"https://github.com/telefonicaid/fiware-glancesync/pull/50#discussion_r47270392"},"pull_request":{"href":"https://api.github.com/repos/telefonicaid/fiware-glancesync/pulls/50"}}},"pull_request":{"url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/pulls/50","id":53271536,"html_url":"https://github.com/telefonicaid/fiware-glancesync/pull/50","diff_url":"https://github.com/telefonicaid/fiware-glancesync/pull/50.diff","patch_url":"https://github.com/telefonicaid/fiware-glancesync/pull/50.patch","issue_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/issues/50","number":50,"state":"open","locked":false,"title":"Claudia 4548","user":{"login":"chemaper","id":8962900,"avatar_url":"https://avatars.githubusercontent.com/u/8962900?v=3","gravatar_id":"","url":"https://api.github.com/users/chemaper","html_url":"https://github.com/chemaper","followers_url":"https://api.github.com/users/chemaper/followers","following_url":"https://api.github.com/users/chemaper/following{/other_user}","gists_url":"https://api.github.com/users/chemaper/gists{/gist_id}","starred_url":"https://api.github.com/users/chemaper/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chemaper/subscriptions","organizations_url":"https://api.github.com/users/chemaper/orgs","repos_url":"https://api.github.com/users/chemaper/repos","events_url":"https://api.github.com/users/chemaper/events{/privacy}","received_events_url":"https://api.github.com/users/chemaper/received_events","type":"User","site_admin":false},"body":"#### Reviewers\r\n@flopezag @jframos \r\n \r\n#### Description\r\ntests for sync class, specially the parallel sync\r\n \r\n#### Testing\r\nLocally","created_at":"2015-12-10T15:18:54Z","updated_at":"2015-12-10T19:14:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"110cd9460a033ca0dc2d01d082209334a43d8bb2","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/pulls/50/commits","review_comments_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/pulls/50/comments","review_comment_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/pulls/comments{/number}","comments_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/issues/50/comments","statuses_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/statuses/9f5bb732e0784fc4bc73b37fc935f48650a5e01f","head":{"label":"telefonicaid:claudia-4548","ref":"claudia-4548","sha":"9f5bb732e0784fc4bc73b37fc935f48650a5e01f","user":{"login":"telefonicaid","id":968363,"avatar_url":"https://avatars.githubusercontent.com/u/968363?v=3","gravatar_id":"","url":"https://api.github.com/users/telefonicaid","html_url":"https://github.com/telefonicaid","followers_url":"https://api.github.com/users/telefonicaid/followers","following_url":"https://api.github.com/users/telefonicaid/following{/other_user}","gists_url":"https://api.github.com/users/telefonicaid/gists{/gist_id}","starred_url":"https://api.github.com/users/telefonicaid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/telefonicaid/subscriptions","organizations_url":"https://api.github.com/users/telefonicaid/orgs","repos_url":"https://api.github.com/users/telefonicaid/repos","events_url":"https://api.github.com/users/telefonicaid/events{/privacy}","received_events_url":"https://api.github.com/users/telefonicaid/received_events","type":"Organization","site_admin":false},"repo":{"id":39255854,"name":"fiware-glancesync","full_name":"telefonicaid/fiware-glancesync","owner":{"login":"telefonicaid","id":968363,"avatar_url":"https://avatars.githubusercontent.com/u/968363?v=3","gravatar_id":"","url":"https://api.github.com/users/telefonicaid","html_url":"https://github.com/telefonicaid","followers_url":"https://api.github.com/users/telefonicaid/followers","following_url":"https://api.github.com/users/telefonicaid/following{/other_user}","gists_url":"https://api.github.com/users/telefonicaid/gists{/gist_id}","starred_url":"https://api.github.com/users/telefonicaid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/telefonicaid/subscriptions","organizations_url":"https://api.github.com/users/telefonicaid/orgs","repos_url":"https://api.github.com/users/telefonicaid/repos","events_url":"https://api.github.com/users/telefonicaid/events{/privacy}","received_events_url":"https://api.github.com/users/telefonicaid/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/telefonicaid/fiware-glancesync","description":"","fork":false,"url":"https://api.github.com/repos/telefonicaid/fiware-glancesync","forks_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/forks","keys_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/keys{/key_id}","collaborators_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/teams","hooks_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/hooks","issue_events_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/issues/events{/number}","events_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/events","assignees_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/assignees{/user}","branches_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/branches{/branch}","tags_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/tags","blobs_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/git/refs{/sha}","trees_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/git/trees{/sha}","statuses_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/statuses/{sha}","languages_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/languages","stargazers_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/stargazers","contributors_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/contributors","subscribers_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/subscribers","subscription_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/subscription","commits_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/commits{/sha}","git_commits_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/git/commits{/sha}","comments_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/comments{/number}","issue_comment_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/issues/comments{/number}","contents_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/contents/{+path}","compare_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/compare/{base}...{head}","merges_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/merges","archive_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/downloads","issues_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/issues{/number}","pulls_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/pulls{/number}","milestones_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/milestones{/number}","notifications_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/labels{/name}","releases_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/releases{/id}","created_at":"2015-07-17T13:38:48Z","updated_at":"2015-07-17T14:15:55Z","pushed_at":"2015-12-10T19:00:50Z","git_url":"git://github.com/telefonicaid/fiware-glancesync.git","ssh_url":"git@github.com:telefonicaid/fiware-glancesync.git","clone_url":"https://github.com/telefonicaid/fiware-glancesync.git","svn_url":"https://github.com/telefonicaid/fiware-glancesync","homepage":null,"size":10653,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"develop"}},"base":{"label":"telefonicaid:develop","ref":"develop","sha":"883ec509826629f2d761c85d7239941a061f4eb7","user":{"login":"telefonicaid","id":968363,"avatar_url":"https://avatars.githubusercontent.com/u/968363?v=3","gravatar_id":"","url":"https://api.github.com/users/telefonicaid","html_url":"https://github.com/telefonicaid","followers_url":"https://api.github.com/users/telefonicaid/followers","following_url":"https://api.github.com/users/telefonicaid/following{/other_user}","gists_url":"https://api.github.com/users/telefonicaid/gists{/gist_id}","starred_url":"https://api.github.com/users/telefonicaid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/telefonicaid/subscriptions","organizations_url":"https://api.github.com/users/telefonicaid/orgs","repos_url":"https://api.github.com/users/telefonicaid/repos","events_url":"https://api.github.com/users/telefonicaid/events{/privacy}","received_events_url":"https://api.github.com/users/telefonicaid/received_events","type":"Organization","site_admin":false},"repo":{"id":39255854,"name":"fiware-glancesync","full_name":"telefonicaid/fiware-glancesync","owner":{"login":"telefonicaid","id":968363,"avatar_url":"https://avatars.githubusercontent.com/u/968363?v=3","gravatar_id":"","url":"https://api.github.com/users/telefonicaid","html_url":"https://github.com/telefonicaid","followers_url":"https://api.github.com/users/telefonicaid/followers","following_url":"https://api.github.com/users/telefonicaid/following{/other_user}","gists_url":"https://api.github.com/users/telefonicaid/gists{/gist_id}","starred_url":"https://api.github.com/users/telefonicaid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/telefonicaid/subscriptions","organizations_url":"https://api.github.com/users/telefonicaid/orgs","repos_url":"https://api.github.com/users/telefonicaid/repos","events_url":"https://api.github.com/users/telefonicaid/events{/privacy}","received_events_url":"https://api.github.com/users/telefonicaid/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/telefonicaid/fiware-glancesync","description":"","fork":false,"url":"https://api.github.com/repos/telefonicaid/fiware-glancesync","forks_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/forks","keys_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/keys{/key_id}","collaborators_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/teams","hooks_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/hooks","issue_events_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/issues/events{/number}","events_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/events","assignees_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/assignees{/user}","branches_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/branches{/branch}","tags_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/tags","blobs_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/git/refs{/sha}","trees_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/git/trees{/sha}","statuses_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/statuses/{sha}","languages_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/languages","stargazers_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/stargazers","contributors_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/contributors","subscribers_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/subscribers","subscription_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/subscription","commits_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/commits{/sha}","git_commits_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/git/commits{/sha}","comments_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/comments{/number}","issue_comment_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/issues/comments{/number}","contents_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/contents/{+path}","compare_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/compare/{base}...{head}","merges_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/merges","archive_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/downloads","issues_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/issues{/number}","pulls_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/pulls{/number}","milestones_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/milestones{/number}","notifications_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/labels{/name}","releases_url":"https://api.github.com/repos/telefonicaid/fiware-glancesync/releases{/id}","created_at":"2015-07-17T13:38:48Z","updated_at":"2015-07-17T14:15:55Z","pushed_at":"2015-12-10T19:00:50Z","git_url":"git://github.com/telefonicaid/fiware-glancesync.git","ssh_url":"git@github.com:telefonicaid/fiware-glancesync.git","clone_url":"https://github.com/telefonicaid/fiware-glancesync.git","svn_url":"https://github.com/telefonicaid/fiware-glancesync","homepage":null,"size":10653,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/telefonicaid/fiware-glancesync/pulls/50"},"html":{"href":"https://github.com/telefonicaid/fiware-glancesync/pull/50"},"issue":{"href":"https://api.github.com/repos/telefonicaid/fiware-glancesync/issues/50"},"comments":{"href":"https://api.github.com/repos/telefonicaid/fiware-glancesync/issues/50/comments"},"review_comments":{"href":"https://api.github.com/repos/telefonicaid/fiware-glancesync/pulls/50/comments"},"review_comment":{"href":"https://api.github.com/repos/telefonicaid/fiware-glancesync/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/telefonicaid/fiware-glancesync/pulls/50/commits"},"statuses":{"href":"https://api.github.com/repos/telefonicaid/fiware-glancesync/statuses/9f5bb732e0784fc4bc73b37fc935f48650a5e01f"}}}}