def test_upload_content(self): """@Test: Create repository and upload content @Feature: Repository @Assert: upload content is successful """ name = gen_string('alpha', 15) try: new_repo = self._make_repository({'name': name}) except CLIFactoryError as err: self.fail(err) ssh.upload_file(local_file=get_data_file(RPM_TO_UPLOAD), remote_file="/tmp/{0}".format(RPM_TO_UPLOAD)) result = Repository.upload_content({ 'name': new_repo['name'], 'path': "/tmp/{0}".format(RPM_TO_UPLOAD), 'product-id': new_repo['product']['id'], 'organization': new_repo['organization'], }) self.assertEqual( result.return_code, 0, "return code must be 0, instead got {0}" ''.format(result.return_code)) self.assertEqual(len(result.stderr), 0, "No error was expected") self.assertIn( "Successfully uploaded file '{0}'" ''.format(RPM_TO_UPLOAD), result.stdout[0]['message'])
def test_upload_content(self): """@Test: Create repository and upload content @Feature: Repository @Assert: upload content is successful """ name = gen_string('alpha', 15) try: new_repo = self._make_repository({'name': name}) except CLIFactoryError as err: self.fail(err) ssh.upload_file(local_file=get_data_file(RPM_TO_UPLOAD), remote_file="/tmp/{0}".format(RPM_TO_UPLOAD)) result = Repository.upload_content({ 'name': new_repo['name'], 'path': "/tmp/{0}".format(RPM_TO_UPLOAD), 'product-id': new_repo['product']['id'], 'organization': new_repo['organization'], }) self.assertEqual(result.return_code, 0, "return code must be 0, instead got {0}" ''.format(result.return_code)) self.assertEqual( len(result.stderr), 0, "No error was expected") self.assertIn("Successfully uploaded file '{0}'" ''.format(RPM_TO_UPLOAD), result.stdout[0]['message'])
def make_file_repository_upload_contents(self, options=None): """Makes a new File repository, Upload File/Multiple Files and asserts its success. """ if options is None: options = { 'name': self.file_repo_name, 'product-id': self.product['id'], 'content-type': 'file', } if not options.get('content-type'): raise CLIFactoryError('Please provide a valid Content Type.') file_repo = make_repository(options) remote_path = "/tmp/{0}".format(RPM_TO_UPLOAD) if 'multi_upload' not in options or not options['multi_upload']: ssh.upload_file(local_file=get_data_file(RPM_TO_UPLOAD), remote_file=remote_path) else: remote_path = "/tmp/{}/".format(gen_string('alpha')) ssh.upload_files(local_dir=os.getcwd() + "/../data/", remote_dir=remote_path) result = Repository.upload_content( { 'name': file_repo['name'], 'organization': file_repo['organization'], 'path': remote_path, 'product-id': file_repo['product']['id'], } ) self.assertIn( "Successfully uploaded file '{0}'".format(RPM_TO_UPLOAD), result[0]['message'] ) file_repo = Repository.info({'id': file_repo['id']}) self.assertGreater(int(file_repo['content-counts']['files']), 0) return file_repo
def test_positive_upload_content_srpm(self): """Create repository and upload a SRPM content @id: 706dc3e2-dacb-4fdd-8eef-5715ce498888 @Assert: File successfully uploaded """ new_repo = self._make_repository({"name": gen_string("alpha", 15)}) ssh.upload_file(local_file=get_data_file(SRPM_TO_UPLOAD), remote_file="/tmp/{0}".format(SRPM_TO_UPLOAD)) result = Repository.upload_content( { "name": new_repo["name"], "organization": new_repo["organization"], "path": "/tmp/{0}".format(SRPM_TO_UPLOAD), "product-id": new_repo["product"]["id"], } ) self.assertIn("Successfully uploaded file '{0}'".format(SRPM_TO_UPLOAD), result[0]["message"])
def test_positive_upload_content(self): """Create repository and upload content @id: eb0ec599-2bf1-483a-8215-66652f948d67 @Assert: upload content is successful """ new_repo = self._make_repository({"name": gen_string("alpha", 15)}) ssh.upload_file(local_file=get_data_file(RPM_TO_UPLOAD), remote_file="/tmp/{0}".format(RPM_TO_UPLOAD)) result = Repository.upload_content( { "name": new_repo["name"], "organization": new_repo["organization"], "path": "/tmp/{0}".format(RPM_TO_UPLOAD), "product-id": new_repo["product"]["id"], } ) self.assertIn("Successfully uploaded file '{0}'".format(RPM_TO_UPLOAD), result[0]["message"])
def test_positive_upload_content(self): """Create repository and upload content @Feature: Repository @Assert: upload content is successful """ new_repo = self._make_repository({'name': gen_string('alpha', 15)}) ssh.upload_file(local_file=get_data_file(RPM_TO_UPLOAD), remote_file="/tmp/{0}".format(RPM_TO_UPLOAD)) result = Repository.upload_content({ 'name': new_repo['name'], 'organization': new_repo['organization'], 'path': "/tmp/{0}".format(RPM_TO_UPLOAD), 'product-id': new_repo['product']['id'], }) self.assertIn( "Successfully uploaded file '{0}'".format(RPM_TO_UPLOAD), result[0]['message'], )
def make_file_repository_upload_contents(self, options=None): """Makes a new File repository, Upload File/Multiple Files and asserts its success. """ if options is None: options = { 'name': self.file_repo_name, 'product-id': self.product['id'], 'content-type': 'file' } if not options.get('content-type'): raise CLIFactoryError('Please provide a valid Content Type.') file_repo = make_repository(options) remote_path = "/tmp/{0}".format(RPM_TO_UPLOAD) if 'multi_upload' not in options or not options['multi_upload']: ssh.upload_file( local_file=get_data_file(RPM_TO_UPLOAD), remote_file=remote_path ) else: remote_path = "/tmp/{}/".format(gen_string('alpha')) ssh.upload_files(local_dir=os.getcwd() + "/../data/", remote_dir=remote_path) result = Repository.upload_content({ 'name': file_repo['name'], 'organization': file_repo['organization'], 'path': remote_path, 'product-id': file_repo['product']['id'], }) self.assertIn( "Successfully uploaded file '{0}'".format(RPM_TO_UPLOAD), result[0]['message'], ) file_repo = Repository.info({'id': file_repo['id']}) self.assertGreater(int(file_repo['content-counts']['files']), 0) return file_repo
def test_positive_upload_content_srpm(self): """Create repository and upload a SRPM content @id: 706dc3e2-dacb-4fdd-8eef-5715ce498888 @Assert: File successfully uploaded """ new_repo = self._make_repository({'name': gen_string('alpha', 15)}) ssh.upload_file(local_file=get_data_file(SRPM_TO_UPLOAD), remote_file="/tmp/{0}".format(SRPM_TO_UPLOAD)) result = Repository.upload_content({ 'name': new_repo['name'], 'organization': new_repo['organization'], 'path': "/tmp/{0}".format(SRPM_TO_UPLOAD), 'product-id': new_repo['product']['id'], }) self.assertIn( "Successfully uploaded file '{0}'".format(SRPM_TO_UPLOAD), result[0]['message'], )
def test_positive_upload_content(self): """Create repository and upload content @id: eb0ec599-2bf1-483a-8215-66652f948d67 @Assert: upload content is successful """ new_repo = self._make_repository({'name': gen_string('alpha', 15)}) ssh.upload_file(local_file=get_data_file(RPM_TO_UPLOAD), remote_file="/tmp/{0}".format(RPM_TO_UPLOAD)) result = Repository.upload_content({ 'name': new_repo['name'], 'organization': new_repo['organization'], 'path': "/tmp/{0}".format(RPM_TO_UPLOAD), 'product-id': new_repo['product']['id'], }) self.assertIn( "Successfully uploaded file '{0}'".format(RPM_TO_UPLOAD), result[0]['message'], )