+ def test_error_name_without_collection(self):
+ self.assertRaises(SystemExit, self.call_main_with_args,
+ ['--name', 'test without Collection',
+ '--stream', '/dev/null'])
+
+ def test_error_when_project_not_found(self):
+ self.assertRaises(SystemExit,
+ self.call_main_with_args,
+ ['--project-uuid', self.Z_UUID])
+
+ def test_error_bad_project_uuid(self):
+ self.assertRaises(SystemExit,
+ self.call_main_with_args,
+ ['--project-uuid', self.Z_UUID, '--stream'])
+
+class ArvPutIntegrationTest(run_test_server.TestCaseWithServers,
+ ArvadosBaseTestCase):
+ def _getKeepServerConfig():
+ for config_file in ['application.yml', 'application.default.yml']:
+ with open(os.path.join(run_test_server.SERVICES_SRC_DIR,
+ "api", "config", config_file)) as f:
+ rails_config = yaml.load(f.read())
+ for config_section in ['test', 'common']:
+ try:
+ key = rails_config[config_section]["blob_signing_key"]
+ except (KeyError, TypeError):
+ pass
+ else:
+ return {'blob_signing_key': key,
+ 'enforce_permissions': True}
+ return {'blog_signing_key': None, 'enforce_permissions': False}
+
+ MAIN_SERVER = {}
+ KEEP_SERVER = _getKeepServerConfig()
+ PROJECT_UUID = run_test_server.fixture('groups')['aproject']['uuid']
+
+ @classmethod
+ def setUpClass(cls):
+ super(ArvPutIntegrationTest, cls).setUpClass()
+ cls.ENVIRON = os.environ.copy()
+ cls.ENVIRON['PYTHONPATH'] = ':'.join(sys.path)
+
+ def setUp(self):
+ super(ArvPutIntegrationTest, self).setUp()
+ arv_put.api_client = None
+
+ def authorize_with(self, token_name):
+ run_test_server.authorize_with(token_name)
+ for v in ["ARVADOS_API_HOST",
+ "ARVADOS_API_HOST_INSECURE",
+ "ARVADOS_API_TOKEN"]:
+ self.ENVIRON[v] = arvados.config.settings()[v]
+ arv_put.api_client = arvados.api('v1')
+
+ def current_user(self):
+ return arv_put.api_client.users().current().execute()
+
+ def test_check_real_project_found(self):
+ self.authorize_with('active')
+ self.assertTrue(arv_put.desired_project_uuid(arv_put.api_client, self.PROJECT_UUID, 0),
+ "did not correctly find test fixture project")
+
+ def test_check_error_finding_nonexistent_uuid(self):
+ BAD_UUID = 'zzzzz-zzzzz-zzzzzzzzzzzzzzz'
+ self.authorize_with('active')
+ try:
+ result = arv_put.desired_project_uuid(arv_put.api_client, BAD_UUID,
+ 0)
+ except ValueError as error:
+ self.assertIn(BAD_UUID, error.message)
+ else:
+ self.assertFalse(result, "incorrectly found nonexistent project")
+
+ def test_check_error_finding_nonexistent_project(self):
+ BAD_UUID = 'zzzzz-tpzed-zzzzzzzzzzzzzzz'
+ self.authorize_with('active')
+ with self.assertRaises(apiclient.errors.HttpError):
+ result = arv_put.desired_project_uuid(arv_put.api_client, BAD_UUID,
+ 0)
+