@mock.patch('certbot._internal.eff.handle_subscription')
@mock.patch('certbot._internal.log.post_arg_parse_setup')
@mock.patch('certbot._internal.main._report_new_cert')
@mock.patch('certbot._internal.main.client.acme_client.Client')
@mock.patch('certbot._internal.main._determine_account')
@mock.patch('certbot._internal.main.client.Client.obtain_and_enroll_certificate')
@mock.patch('certbot._internal.main._get_and_save_cert')
def test_user_agent(self, gsc, _obt, det, _client, _, __, ___):
    args = (['--standalone', 'certonly', '-m', 'example@example.com', '-d', 'example.com', '--agree-tos'] + self.standard_args)
    det.return_value = (mock.MagicMock(), None)
    gsc.return_value = mock.MagicMock()
    with mock.patch('certbot._internal.main.client.acme_client.ClientNetwork') as acme_net:
        self._call_no_clientmock(args)
        os_ver = util.get_os_info_ua()
        ua = acme_net.call_args[1]['user_agent']
        self.assertTrue((os_ver in ua))
        import platform
        plat = platform.platform()
        if ('linux' in plat.lower()):
            self.assertTrue((util.get_os_info_ua() in ua))
    with mock.patch('certbot._internal.main.client.acme_client.ClientNetwork') as acme_net:
        ua = 'bandersnatch'
        args += ['--user-agent', ua]
        self._call_no_clientmock(args)
        acme_net.assert_called_once_with(mock.ANY, account=mock.ANY, verify_ssl=True, user_agent=ua)
@mock.patch('certbot._internal.eff.handle_subscription')
@mock.patch('certbot._internal.log.post_arg_parse_setup')
@mock.patch('certbot._internal.main._report_new_cert')
@mock.patch('certbot._internal.main.client.acme_client.Client')
@mock.patch('certbot._internal.main._determine_account')
@mock.patch('certbot._internal.main.client.Client.obtain_and_enroll_certificate')
@mock.patch('certbot._internal.main._get_and_save_cert')
def test_user_agent(self, gsc, _obt, det, _client, _, __, ___):
    args = (['--standalone', 'certonly', '-m', 'example@example.com', '-d', 'example.com', '--agree-tos'] + self.standard_args)
    det.return_value = (mock.MagicMock(), None)
    gsc.return_value = mock.MagicMock()
    with mock.patch('certbot._internal.main.client.acme_client.ClientNetwork') as acme_net:
        self._call_no_clientmock(args)
        os_ver = util.get_os_info_ua()
        ua = acme_net.call_args[1]['user_agent']
        self.assertTrue((os_ver in ua))
        import platform
        plat = platform.platform()
        if ('linux' in plat.lower()):
            self.assertTrue((util.get_os_info_ua() in ua))
    with mock.patch('certbot._internal.main.client.acme_client.ClientNetwork') as acme_net:
        ua = 'bandersnatch'
        args += ['--user-agent', ua]
        self._call_no_clientmock(args)
        acme_net.assert_called_once_with(mock.ANY, account=mock.ANY, verify_ssl=True, user_agent=ua)