def test_http_fail(self, cache_save, cache_valid, fake_consumer_id, fake_uep): fake_uep().conn.request_put.side_effect = RemoteServerException(500) cache_valid.return_value = False enabled_repos_upload.upload_enabled_repos_report(Mock()) # validation cache_save.assert_not_called()
def test_cached(self, cache_save, cache_valid, fake_report_enabled, fake_read, fake_report, plugin_enabled): consumer_id = '1234' fake_certificate = Mock() fake_certificate.getConsumerId.return_value = consumer_id fake_read.return_value = fake_certificate cache_valid.return_value = True report = Mock() fake_report.return_value = report report.content = FAKE_REPORT enabled_repos_upload.upload_enabled_repos_report(report) # validation fake_certificate.getConsumerId.assert_called_with() fake_report_enabled.assert_not_called()
def test_send(self, cache_save, cache_valid, fake_report_enabled, fake_read, fake_report): consumer_id = '1234' fake_certificate = Mock() fake_certificate.getConsumerId.return_value = consumer_id fake_read.return_value = fake_certificate cache_valid.return_value = False report = Mock() fake_report.return_value = report report.content = FAKE_REPORT enabled_repos_upload.upload_enabled_repos_report() # validation fake_report.assert_called_with('/etc/yum.repos.d/redhat.repo') fake_certificate.getConsumerId.assert_called_with() fake_report_enabled.assert_called_with(consumer_id, FAKE_REPORT)
def certificate_changed(path): """ A certificate change has been detected. On registration: setup the plugin; attach to the message broker. On un-registration: detach from the message broker. :param path: The path to the file that changed. :type path: str """ log.info('changed: %s', path) while True: try: validate_registration() if registered: update_settings() enabled_repos_upload.upload_enabled_repos_report() plugin.attach() else: plugin.detach() # DONE break except Exception, e: log.warn(str(e)) sleep(60)
def send_enabled_report(path=REPOSITORY_PATH): enabled_repos_upload.upload_enabled_repos_report()
def send_enabled_report(path=REPOSITORY_PATH): report = enabled_repos_upload.EnabledReport(path) enabled_repos_upload.upload_enabled_repos_report(report)