def test_save_grant(mocker, freeze_time): freeze_time(datetime.utcnow()) mocker.patch.object(OAuthGrant, 'save') request = MagicMock() request.scopes = 'api' request.redirect_uri = 'http://localhost:5000' client_id = str(uuid4()) code = {'code': 'foobar'} expires = datetime.utcnow() + timedelta(seconds=120) grant = save_grant(client_id, code, request) assert grant.client_id == client_id assert grant.code == code['code'] assert grant.redirect_uri == request.redirect_uri assert grant.user == session.user assert grant.scopes == request.scopes assert grant.expires == expires assert grant.save.called
def test_save_grant(mocker, freeze_time): freeze_time(datetime.utcnow()) mocker.patch.object(OAuthGrant, 'save') request = MagicMock() request.scopes = 'api' request.redirect_uri = 'http://localhost:5000' client_id = unicode(uuid4()) code = {'code': 'foobar'} expires = datetime.utcnow() + timedelta(seconds=120) grant = save_grant(client_id, code, request) assert grant.client_id == client_id assert grant.code == code['code'] assert grant.redirect_uri == request.redirect_uri assert grant.user == session.user assert grant.scopes == request.scopes assert grant.expires == expires assert grant.save.called