| """Test for cipd_upload_utils.""" |
| import unittest |
| import unittest.mock |
| |
| from cq.scripts.helpers import cipd_upload_utils |
| |
| |
| class CIPDUploadUtilsTest(unittest.TestCase): |
| |
| def setUp(self): |
| self._executor = unittest.mock.MagicMock() |
| |
| def testUploadCIPDPackage(self): |
| """Verifies simple UploadCIPDPackage call.""" |
| pkg_def = '/path/to/pkg.yaml' |
| |
| cipd_upload_utils.UploadCIPDPackage(self._executor, pkg_def, dry_run=False) |
| |
| self._executor.exec_subprocess.assert_called_once_with([ |
| 'cipd', 'create', '-pkg-def', pkg_def]) |
| |
| def testUploadCIPDPackageAllArgs(self): |
| """Verifies UploadCIPDPackage with all args specified.""" |
| pkg_def = '/path/to/pkg.yaml' |
| refs = ['test', 'latest'] |
| tags = {'tag1': 'this', 'tag2': 'that'} |
| verification_timeout = '5m0s' |
| service_account_json = '/path/to/token.json' |
| |
| cipd_upload_utils.UploadCIPDPackage( |
| self._executor, |
| pkg_def, |
| refs=refs, |
| tags=tags, |
| verification_timeout=verification_timeout, |
| service_account_json=service_account_json, |
| dry_run=False) |
| |
| self._executor.exec_subprocess.assert_called_once_with([ |
| 'cipd', 'create', |
| '-pkg-def', pkg_def, |
| '-ref', 'test', |
| '-ref', 'latest', |
| '-tag', 'tag1:this', '-tag', 'tag2:that', |
| '-verification-timeout', verification_timeout, |
| '-service-account-json', service_account_json,]) |
| |
| |
| if __name__ == '__main__': |
| unittest.main() |