def test_registered_upload_archive(self): """Test the /upload api endpoint via Satellite 6""" self.system_id = archive_functions.get_system_id(self.archive_location) files = {'file': open(self.archive_location, "rb")} self.upload = self.session.post(self.base_url + upload_api + '/' + self.system_id, files=files) LOGGER.info(self.upload.json()) Util.log_assert(self.upload.status_code == 201, "Upload archive was not successful!") LOGGER.info("Upload done successfully")
def test_product_used_by_account(self): """ Test products used by this current user """ self.product = self.session.get(self.base_url + account_products) LOGGER.info(self.product.json()) Util.log_assert(self.product.status_code == 200, "Response is not 200 OK") product_info = json.loads(self.product.text) product_used = product_info[0] Util.log_assert(product_used == 'rhel', "Product used is not RHEL")
def test_register_machine_sat6(self): """ Test if the system is registered with Satellite 6""" register = self.session.post(self.base_url + system_api_v2, json={'system_id': self.system_id, 'hostname': self.hostname, 'remote_branch': self.remote_branch, 'remote_leaf': self.remote_leaf, }) LOGGER.info(register.status_code) LOGGER.info(register.json()) Util.log_assert(register.status_code == 200, "Machine register status code is not 200 OK")
def test_current_user_info(self): """ Request current user information """ self.user_info = self.session.get(self.base_url + me) LOGGER.info(self.user_info.json()) Util.log_assert(self.user_info.status_code == 200, "Response is not 200 OK") self.text = self.user_info.text response = json.loads(self.text) account_number = response['account_number'] Util.log_assert(account_number == str(477931), "Account number is incorrect")
def test_register_machine_sat6(self): """ Test if the system is registered with Satellite 6""" register = self.session.post(self.base_url + system_api_v2, json={ 'system_id': self.system_id, 'hostname': self.hostname, 'remote_branch': self.remote_branch, 'remote_leaf': self.remote_leaf, }) LOGGER.info(register.status_code) LOGGER.info(register.json()) Util.log_assert(register.status_code == 200, "Machine register status code is not 200 OK")
def test_unregister_machine_sat6(self): """ Test if the above registered system has been unregistered and not checking in.[sat 6] """ unregister = self.session.delete(self.base_url + system_api + '/' + self.system_id) Util.log_assert(unregister.status_code == 204, "Unregister machine status code is not 204") check_if_unregistered = self.session.get(self.base_url + system_api + '/' + self.system_id) response = check_if_unregistered.json() LOGGER.info(response) Util.log_assert(response['isCheckingIn'] == False, "Incorrect value of isCheckingIn") Util.log_assert(response['unregistered_at'] is not None, "Unregistered at field is None") reports = self.session.get(self.base_url + report_api + '?system_id=' + self.system_id) LOGGER.info(reports.json()) LOGGER.info(reports.status_code)
def setup_method(self, method): Util.print_testname(type(self).__name__, method)