| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2015 The LUCI Authors. All rights reserved. | 2 # Copyright 2015 The LUCI Authors. All rights reserved. |
| 3 # Use of this source code is governed under the Apache License, Version 2.0 | 3 # Use of this source code is governed under the Apache License, Version 2.0 |
| 4 # that can be found in the LICENSE file. | 4 # that can be found in the LICENSE file. |
| 5 | 5 |
| 6 import base64 | 6 import base64 |
| 7 import datetime | 7 import datetime |
| 8 import httplib | 8 import httplib |
| 9 | 9 |
| 10 import test_env | 10 import test_env |
| (...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 648 | 648 |
| 649 ############################################################################## | 649 ############################################################################## |
| 650 # reimport | 650 # reimport |
| 651 | 651 |
| 652 def test_reimport_without_permissions(self): | 652 def test_reimport_without_permissions(self): |
| 653 req = {'config_set': 'services/x'} | 653 req = {'config_set': 'services/x'} |
| 654 with self.call_should_fail(403): | 654 with self.call_should_fail(403): |
| 655 self.call_api('reimport', req) | 655 self.call_api('reimport', req) |
| 656 | 656 |
| 657 def test_reimport(self): | 657 def test_reimport(self): |
| 658 self.mock(auth, 'is_admin', mock.Mock(return_value=True)) | 658 self.mock(acl, 'is_admin', mock.Mock(return_value=True)) |
| 659 self.mock(gitiles_import, 'import_config_set', mock.Mock()) | 659 self.mock(gitiles_import, 'import_config_set', mock.Mock()) |
| 660 req = {'config_set': 'services/x'} | 660 req = {'config_set': 'services/x'} |
| 661 self.call_api('reimport', req) | 661 self.call_api('reimport', req) |
| 662 gitiles_import.import_config_set.assert_called_once_with('services/x') | 662 gitiles_import.import_config_set.assert_called_once_with('services/x') |
| 663 | 663 |
| 664 def test_reimport_not_found(self): | 664 def test_reimport_not_found(self): |
| 665 self.mock(auth, 'is_admin', mock.Mock(return_value=True)) | 665 self.mock(acl, 'is_admin', mock.Mock(return_value=True)) |
| 666 self.mock(gitiles_import, 'import_config_set', mock.Mock()) | 666 self.mock(gitiles_import, 'import_config_set', mock.Mock()) |
| 667 gitiles_import.import_config_set.side_effect = gitiles_import.NotFoundError | 667 gitiles_import.import_config_set.side_effect = gitiles_import.NotFoundError |
| 668 req = {'config_set': 'services/x'} | 668 req = {'config_set': 'services/x'} |
| 669 with self.call_should_fail(404): | 669 with self.call_should_fail(404): |
| 670 self.call_api('reimport', req) | 670 self.call_api('reimport', req) |
| 671 | 671 |
| 672 def test_reimport_bad_request(self): | 672 def test_reimport_bad_request(self): |
| 673 self.mock(auth, 'is_admin', mock.Mock(return_value=True)) | 673 self.mock(acl, 'is_admin', mock.Mock(return_value=True)) |
| 674 self.mock(gitiles_import, 'import_config_set', mock.Mock()) | 674 self.mock(gitiles_import, 'import_config_set', mock.Mock()) |
| 675 gitiles_import.import_config_set.side_effect = gitiles_import.Error | 675 gitiles_import.import_config_set.side_effect = gitiles_import.Error |
| 676 req = {'config_set': 'services/x'} | 676 req = {'config_set': 'services/x'} |
| 677 with self.call_should_fail(500): | 677 with self.call_should_fail(500): |
| 678 self.call_api('reimport', req) | 678 self.call_api('reimport', req) |
| 679 | 679 |
| 680 | 680 |
| 681 if __name__ == '__main__': | 681 if __name__ == '__main__': |
| 682 test_env.main() | 682 test_env.main() |
| OLD | NEW |