def test_generate_jwt_calls_encode(jwt):
    """It should pass the right arguments to encode()."""
    before = datetime.datetime.utcnow()
    request = mock_request()

    tokens.generate_jwt(request, 3600)

    assert jwt.encode.call_args[0][0]['sub'] == 'acct:testuser@hypothes.is', (
        "It should encode the userid as 'sub'")
    after = datetime.datetime.utcnow() + datetime.timedelta(seconds=3600)
    assert before < jwt.encode.call_args[0][0]['exp'] < after, (
        "It should encode the expiration time as 'exp'")
    assert jwt.encode.call_args[0][0]['aud'] == request.host_url, (
        "It should encode request.host_url as 'aud'")
    assert jwt.encode.call_args[1]['algorithm'] == 'HS256', (
        "It should pass the right algorithm to encode()")
dataset/ETHPy150Open hypothesis/h/h/auth/test/tokens_test.py/test_generate_jwt_calls_encode/original