Instruction
stringlengths
362
7.83k
output_code
stringlengths
1
945
Given the following code snippet before the placeholder: <|code_start|> class AuthorizationTests(testing.TestCase): clean_collections = ('authorization_codes', 'access_codes', 'users') def test_authorization_codes(self): codes = AuthorizationCodes(self.db) url = codes.get_redirect_url('1234',...
codes = AccessCodes(self.db)
Given the code snippet: <|code_start|> self.assertNotEqual(code1, code2) self.assertNotEqual(None, codes.find(code2)) self.assertEqual(None, codes.find(code1)) codes.remove(codes.find(code1)) self.assertEqual(self.db.authorization_codes.count(), 0) def test_access_codes(se...
authorizator = Authorizator(self.db, app)
Given the code snippet: <|code_start|># Yith Library Server is a password storage server. # Copyright (C) 2012-2013 Yaco Sistemas # Copyright (C) 2012-2013 Alejandro Blanco Escudero <alejandro.b.e@gmail.com> # Copyright (C) 2012-2013 Lorenzo Gil Sanchez <lorenzo.gil.sanchez@gmail.com> # # This file is part of Yith Libr...
mdb = MongoDB(MONGO_URI)
Based on the snippet: <|code_start|># Yith Library Server is a password storage server. # Copyright (C) 2012-2013 Yaco Sistemas # Copyright (C) 2012-2013 Alejandro Blanco Escudero <alejandro.b.e@gmail.com> # Copyright (C) 2012-2013 Lorenzo Gil Sanchez <lorenzo.gil.sanchez@gmail.com> # # This file is part of Yith Librar...
self.pm = PasswordsManager(self.db)
Here is a snippet: <|code_start|># Yith Library Server is a password storage server. # Copyright (C) 2012-2013 Yaco Sistemas # Copyright (C) 2012-2013 Alejandro Blanco Escudero <alejandro.b.e@gmail.com> # Copyright (C) 2012-2013 Lorenzo Gil Sanchez <lorenzo.gil.sanchez@gmail.com> # # This file is part of Yith Library S...
mdb = MongoDB(MONGO_URI)
Given the code snippet: <|code_start|> ) pstruct = field.schema.deserialize(cstruct) email_verified_output = field.renderer( self.email_verified_template, email=pstruct.get('email', ''), email_verified=pstruct.get('email_verified', False), ) ...
title=_('First name'),
Given snippet: <|code_start|># This file is part of Yith Library Server. # # Yith Library Server is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) an...
buf = BytesIO()
Based on the snippet: <|code_start|> class RootFactory(object): __acl__ = ( (Allow, Authenticated, 'user-registration'), (Allow, Authenticated, 'view-applications'), (Allow, Authenticated, 'edit-application'), (Allow, Authenticated, 'add-application'), (Allow, Authenticated...
access_code = AccessCodes(request.db).find(credentials)
Using the snippet: <|code_start|># the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Yith Library Server is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTIC...
return text_type(self['_id'])
Given snippet: <|code_start|> context, "Yith Library announcement", [user['email']], ) def announce(): usage = "migrate: %prog config_uri migration_name" description = "Add a 'send_email_periodically' preference to every user." parser = optparse.OptionParser( usage=usage...
preferences_link = urlparse.urljoin(
Here is a snippet: <|code_start|># MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with Yith Library Server. If not, see <http://www.gnu.org/licenses/>. def get_all_u...
return create_message(
Predict the next line for this snippet: <|code_start|># Yith Library Server is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should ha...
safe_print('Sending email to %s' % get_user_display_name(user))
Using the snippet: <|code_start|># Yith Library Server is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of...
safe_print('Sending email to %s' % get_user_display_name(user))
Given snippet: <|code_start|> user_id = self.db.users.insert({ 'twitter_id': 'twitter1', 'screen_name': 'John Doe', 'first_name': 'John', 'last_name': 'Doe', 'email': '', 'email_verified': False, 'auth...
content = get_gzip_data(text_type('[{}'))
Predict the next line after this snippet: <|code_start|># Yith Library Server is a password storage server. # Copyright (C) 2013 Lorenzo Gil Sanchez <lorenzo.gil.sanchez@gmail.com> # # This file is part of Yith Library Server. # # Yith Library Server is free software: you can redistribute it and/or modify # it under th...
class ViewTests(TestCase):
Based on the snippet: <|code_start|># # This file is part of Yith Library Server. # # Yith Library Server is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your o...
add_identity_provider)
Given the following code snippet before the placeholder: <|code_start|># (at your option) any later version. # # Yith Library Server is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU G...
payload = PayPalPayload(request, 'method1')
Based on the snippet: <|code_start|> request = testing.DummyRequest() payload = PayPalPayload(request, 'method_with_callbacks') payload.add_token('12345', '6789') self.assertEqual(payload, { 'METHOD': 'method_with_callbacks', 'VERSION': '72.0', ...
pec = PayPalExpressCheckout(request)
Next line prediction: <|code_start|> token = paypal.get_express_checkout_token(amount) return HTTPFound(paypal.get_express_checkout_url(token)) return HTTPBadRequest('Wrong action or method') @view_config(route_name='contributions_paypal_success_callback', renderer='templates/contribu...
send_thankyou_email(request, donation)
Given the following code snippet before the placeholder: <|code_start|> return HTTPFound(paypal.get_express_checkout_url(token)) return HTTPBadRequest('Wrong action or method') @view_config(route_name='contributions_paypal_success_callback', renderer='templates/contributions_confirm.pt') def ...
send_notification_to_admins(request, donation)
Using the snippet: <|code_start|> return HTTPBadRequest('Amount must be an integer') token = paypal.get_express_checkout_token(amount) return HTTPFound(paypal.get_express_checkout_url(token)) return HTTPBadRequest('Wrong action or method') @view_config(route_name='contributions_paypal_...
donation = create_donation(request, request.POST)
Based on the snippet: <|code_start|> donation = create_donation(request, request.POST) send_thankyou_email(request, donation) send_notification_to_admins(request, donation) request.session.flash( _('Thank you very much for your great con...
details['include_sticker'] = include_sticker(amount)
Continue the code snippet: <|code_start|> @view_config(route_name='contributions_index', renderer='templates/contributions_index.pt') def contributions_index(request): locale_name = get_locale_name(request) return {'locale': locale_name, 'random': random} @view_config(route_name='contributions...
error_msg = _('There was a problem in the confirmation process. Please start the checkout again')
Predict the next line for this snippet: <|code_start|># # This file is part of Yith Library Server. # # Yith Library Server is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the Licens...
user_info_url + '?' + url_encode({'user_id': user_id}),
Continue the code snippet: <|code_start|># Copyright (C) 2012-2013 Yaco Sistemas # Copyright (C) 2012-2013 Alejandro Blanco Escudero <alejandro.b.e@gmail.com> # Copyright (C) 2012-2013 Lorenzo Gil Sanchez <lorenzo.gil.sanchez@gmail.com> # # This file is part of Yith Library Server. # # Yith Library Server is free softw...
auth = auth_header('GET', user_info_url, params, settings, oauth_token)
Given the following code snippet before the placeholder: <|code_start|> self['PAYMENTREQUEST_0_DESC'] = 'Donation' self['PAYMENTREQUEST_0_CURRENCYCODE'] = 'USD' self['PAYMENTREQUEST_0_PAYMENTACTION'] = 'Sale' self['LOCALECODE'] = 'ES' def add_callbacks(self, return_url, cancel_url): ...
data = urlparse.parse_qs(response.text)
Predict the next line after this snippet: <|code_start|># # Yith Library Server is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. ...
ga = GoogleAnalytics(request)
Based on the snippet: <|code_start|> request.session = {USER_ATTR: True} request.user = {USER_ATTR: False} ga = GoogleAnalytics(request) self.assertFalse(ga.show) def test_clean_session(self): request = DummyRequest() request.session = {} request.user = None ...
ga = get_google_analytics(request)
Predict the next line for this snippet: <|code_start|> class DummyRegistry(object): def __init__(self, **kwargs): self.settings = kwargs class GoogleAnalyticsTests(unittest.TestCase): def test_enabled(self): request = DummyRequest() request.session = {} request.registry = Dum...
request.session = {USER_ATTR: True}
Given snippet: <|code_start|> log = logging.getLogger(__name__) @view_config(route_name='home', renderer='templates/home.pt') def home(request): return {} @view_config(route_name='contact', renderer='templates/contact.pt') def contact(request): button1 = Button('submit', _('Send message')) button1.css_c...
result = send_email_to_admins(
Using the snippet: <|code_start|># # This file is part of Yith Library Server. # # Yith Library Server is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your opti...
button1 = Button('submit', _('Send message'))
Given the following code snippet before the placeholder: <|code_start|># the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Yith Library Server is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # M...
form = Form(ContactSchema(), buttons=(button1, button2))
Based on the snippet: <|code_start|> return str(uuid.uuid4()) def store(self, db, user): result = db.users.update({'_id': user['_id']}, { '$set': {'email_verification_code': self.code}, }, safe=True) return result['n'] == 1 def remove(self, db, email, ver...
return send_email(
Predict the next line after this snippet: <|code_start|># # This file is part of Yith Library Server. # # Yith Library Server is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the Lice...
self.assertEqual('foo', deform_translator('foo'))
Given snippet: <|code_start|># Yith Library Server is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the...
self.assertEqual(locale_negotiator(request), 'en')
Given the following code snippet before the placeholder: <|code_start|># Yith Library Server is a password storage server. # Copyright (C) 2013 Lorenzo Gil Sanchez <lorenzo.gil.sanchez@gmail.com> # # This file is part of Yith Library Server. # # Yith Library Server is free software: you can redistribute it and/or modif...
safe_print('Adding attribute "%s" to %s' % (attribute, obj_repr))
Next line prediction: <|code_start|># but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with Yith Library Serve...
add_attribute(db.users, user, get_user_display_name(user),
Based on the snippet: <|code_start|># Yith Library Server is a password storage server. # Copyright (C) 2013 Lorenzo Gil Sanchez <lorenzo.gil.sanchez@gmail.com> # # This file is part of Yith Library Server. # # Yith Library Server is free software: you can redistribute it and/or modify # it under the terms of the GNU A...
ds = FakeDateService(None)
Given the following code snippet before the placeholder: <|code_start|># (at your option) any later version. # # Yith Library Server is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU G...
date = get_fake_date(request)
Here is a snippet: <|code_start|> class FakeDateServiceTests(unittest.TestCase): def assertDateEqual(self, date1, date2): delta = date2 - date1 self.assertEqual(delta.days, 0) def test_dateservice(self): ds = FakeDateService(None) fake_today = datetime.date(2012, 1, 10) ...
ds = FakeDatetimeService(None)
Here is a snippet: <|code_start|> fake_today = datetime.date(2012, 1, 10) os.environ['YITH_FAKE_DATE'] = '2012-1-10' self.assertTrue(isinstance(ds.today(), datetime.date)) self.assertDateEqual(ds.today(), fake_today) del os.environ['YITH_FAKE_DATE'] def test_get_fake_date(sel...
datetime = get_fake_datetime(request)
Using the snippet: <|code_start|># Yith Library Server is a password storage server. # Copyright (C) 2012-2013 Yaco Sistemas # Copyright (C) 2012-2013 Alejandro Blanco Escudero <alejandro.b.e@gmail.com> # Copyright (C) 2012-2013 Lorenzo Gil Sanchez <lorenzo.gil.sanchez@gmail.com> # # This file is part of Yith Library S...
self.assertEqual(len(nonce()), 8)
Predict the next line after this snippet: <|code_start|># This file is part of Yith Library Server. # # Yith Library Server is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the Licens...
t1 = timestamp()
Given snippet: <|code_start|> def test_nonce(self): self.assertEqual(len(nonce()), 8) self.assertEqual(len(nonce(10)), 10) self.assertNotEqual(nonce(), nonce()) def test_timestamp(self): t1 = timestamp() time.sleep(1) t2 = timestamp() self.assertTrue(t2 >...
self.assertEqual(sign(method, url, params,
Using the snippet: <|code_start|> params = ( ('status', quote('Hello Ladies + Gentlemen, a signed OAuth request!')), ('include_entities', quote('true')), ('oauth_consumer_key', quote('xvz1evFS4wEEPTGEFPHBog')), ('oauth_nonce', quote('kYjzVBB8Y0ZFabxSWbWovY3uYSQ2pTg...
res = auth_header('post', 'https://api.twitter.com/oauth/request_token',
Predict the next line after this snippet: <|code_start|> def test_send_passwords(self): preferences_link = 'http://localhost/preferences' backups_link = 'http://localhost/backups' user_id = self.db.users.insert({ 'first_name': 'John', 'last_name': 'Doe', ...
request.date_service = FakeDateService(request)
Given snippet: <|code_start|># Yith Library Server is a password storage server. # Copyright (C) 2013 Lorenzo Gil Sanchez <lorenzo.gil.sanchez@gmail.com> # # This file is part of Yith Library Server. # # Yith Library Server is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero G...
self.assertEqual(5, get_day_to_send(user, 28))
Given snippet: <|code_start|> return month month = fill_month(30, 1000) empty_days = [i for i, d in enumerate(month) if d == 0] self.assertEqual(empty_days, []) class SendPasswordsTests(TestCase): clean_collections = ('users', 'passwords', ) def setUp(self): self....
self.assertFalse(send_passwords(request, user,
Here is a snippet: <|code_start|># This file is part of Yith Library Server. # # Yith Library Server is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option...
self.db_uri = urlparse.urlparse(db_uri)
Next line prediction: <|code_start|># Yith Library Server is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Yith Library Serve...
filename = get_backup_filename(today)
Based on the snippet: <|code_start|># Copyright (C) 2013 Lorenzo Gil Sanchez <lorenzo.gil.sanchez@gmail.com> # # This file is part of Yith Library Server. # # Yith Library Server is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the F...
passwords = get_user_passwords(request.db, request.user)
Next line prediction: <|code_start|># # This file is part of Yith Library Server. # # Yith Library Server is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your o...
data = compress(passwords)
Given the following code snippet before the placeholder: <|code_start|> @view_config(route_name='backups_index', renderer='templates/backups_index.pt', permission='backups') def backups_index(request): return {} @view_config(route_name='backups_export', permission='backups')...
json_data = uncompress(passwords_field.file.read())
Given the following code snippet before the placeholder: <|code_start|> response.content_disposition = 'attachment; filename=%s' % filename return response @view_config(route_name='backups_import', renderer='string', permission='backups') def backups_import(request): response = HT...
domain=translation_domain,
Predict the next line after this snippet: <|code_start|> @view_config(route_name='backups_export', permission='backups') def backups_export(request): passwords = get_user_passwords(request.db, request.user) data = compress(passwords) response = Response(body=data, content_type='application/yit...
_('There was a problem reading your passwords file'),
Given snippet: <|code_start|>@view_config(route_name='backups_index', renderer='templates/backups_index.pt', permission='backups') def backups_index(request): return {} @view_config(route_name='backups_export', permission='backups') def backups_export(request): passwords...
passwords_manager = PasswordsManager(request.db)
Continue the code snippet: <|code_start|># Yith Library Server is a password storage server. # Copyright (C) 2012-2013 Yaco Sistemas # Copyright (C) 2012-2013 Alejandro Blanco Escudero <alejandro.b.e@gmail.com> # Copyright (C) 2012-2013 Lorenzo Gil Sanchez <lorenzo.gil.sanchez@gmail.com> # # This file is part of Yith L...
self.assertRaises(HTTPUnauthorized, authenticate_client, request)
Predict the next line after this snippet: <|code_start|># it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Yith Library Server is distributed in the hope that it will be useful, # but...
'Authorization': auth_basic_encode('foo', 'bar'),
Next line prediction: <|code_start|>@view_config(route_name='oauth2_developer_application_new', renderer='templates/developer_application_new.pt', permission='add-application') def developer_application_new(request): assert_authenticated_user_is_registered(request) schema = Application...
create_client_id_and_secret(application)
Given the code snippet: <|code_start|> return HTTPFound(location=url) else: authorship_information = '' owner_id = app.get('owner', None) if owner_id is not None: owner = request.db.users.find_one({'_id': owner_id}) if owner: ...
app = authenticate_client(request)
Here is a snippet: <|code_start|>def authorization_endpoint(request): response_type = request.params.get('response_type') if response_type is None: return HTTPBadRequest('Missing required response_type') if response_type != 'code': return HTTPNotImplemented('Only code is supported') cl...
authorizator = Authorizator(request.db, app)
Given snippet: <|code_start|># You should have received a copy of the GNU Affero General Public License # along with Yith Library Server. If not, see <http://www.gnu.org/licenses/>. DEFAULT_SCOPE = 'passwords' SCOPE_NAMES = { 'passwords': _('Access your passwords'), } @view_config(route_name='oauth2_de...
schema = ApplicationSchema()
Continue the code snippet: <|code_start|> request.db.applications.insert(application, safe=True) return HTTPFound( location=request.route_path('oauth2_developer_applications')) elif 'cancel' in request.POST: return HTTPFound( location=request.route_path('oauth2_develo...
schema = FullApplicationSchema()
Predict the next line for this snippet: <|code_start|># This file is part of Yith Library Server. # # Yith Library Server is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License,...
assert_authenticated_user_is_registered(request)
Using the snippet: <|code_start|># Copyright (C) 2012-2013 Lorenzo Gil Sanchez <lorenzo.gil.sanchez@gmail.com> # # This file is part of Yith Library Server. # # Yith Library Server is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the...
if not result is colander.null and isinstance(result, string_types):
Based on the snippet: <|code_start|># Yith Library Server is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy...
name = colander.SchemaNode(colander.String(), title=_('Name'))
Continue the code snippet: <|code_start|># Yith Library Server is a password storage server. # Copyright (C) 2012-2013 Lorenzo Gil Sanchez <lorenzo.gil.sanchez@gmail.com> # # This file is part of Yith Library Server. # # Yith Library Server is free software: you can redistribute it and/or modify # it under the terms of...
self.assertEqual(text_type(User(data)), '1234')
Predict the next line after this snippet: <|code_start|># Yith Library Server is a password storage server. # Copyright (C) 2012-2013 Lorenzo Gil Sanchez <lorenzo.gil.sanchez@gmail.com> # # This file is part of Yith Library Server. # # Yith Library Server is free software: you can redistribute it and/or modify # it und...
self.assertEqual(text_type(User(data)), '1234')
Predict the next line for this snippet: <|code_start|># Yith Library Server is a password storage server. # Copyright (C) 2013 Lorenzo Gil Sanchez <lorenzo.gil.sanchez@gmail.com> # # This file is part of Yith Library Server. # # Yith Library Server is free software: you can redistribute it and/or modify # it under the ...
mdb = MongoDB(MONGO_URI)
Based on the snippet: <|code_start|># the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Yith Library Server is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PAR...
result = facebook_callback(self.request, '123', {
Given the code snippet: <|code_start|> class SNACallbackTests(unittest.TestCase): def setUp(self): self.config = testing.setUp() self.config.include('yithlibraryserver') self.config.include('yithlibraryserver.user') self.request = testing.DummyRequest() self.request.sessio...
result = google_callback(self.request, '123', {
Predict the next line after this snippet: <|code_start|># Yith Library Server is a password storage server. # Copyright (C) 2013 Lorenzo Gil Sanchez <lorenzo.gil.sanchez@gmail.com> # # This file is part of Yith Library Server. # # Yith Library Server is free software: you can redistribute it and/or modify # it under th...
mdb = MongoDB(MONGO_URI)
Here is a snippet: <|code_start|># # This file is part of Yith Library Server. # # Yith Library Server is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your opti...
sys.stdout = StringIO()
Continue the code snippet: <|code_start|># Yith Library Server is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Yith Library ...
result = migrate()
Given snippet: <|code_start|> res = self.testapp.post('/profile', { 'submit': 'Save changes', 'first_name': 'John', 'last_name': 'Doe', 'email': 'john@example.com', }) self.assertEqual(res.status, ...
day = get_day_to_send({'_id': user_id}, 28)
Given the code snippet: <|code_start|> class BadCollection(object): def __init__(self, user=None): self.user = user def find_one(self, *args, **kwargs): return self.user def update(self, *args, **kwargs): return {'n': 0} class BadDB(object): def __init__(self, user): ...
res.mustcontain(url_quote('param1=value1&param2=value2'))
Given the following code snippet before the placeholder: <|code_start|> class DummyValidationFailure(ValidationFailure): def render(self): return 'dummy error' class BadCollection(object): def __init__(self, user=None): self.user = user def find_one(self, *args, **kwargs): r...
class ViewTests(TestCase):
Continue the code snippet: <|code_start|> user = self.db.users.find_one({'first_name': 'John2'}) self.assertFalse(user is None) self.assertEqual(user['first_name'], 'John2') self.assertEqual(user['last_name'], 'Doe2') self.assertEqual(user['email'], '') self.assertEqual(us...
USER_ATTR: True,
Continue the code snippet: <|code_start|># the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Yith Library Server is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR ...
result = invalid_password_id()
Predict the next line for this snippet: <|code_start|># it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Yith Library Server is distributed in the hope that it will be useful, # but W...
info = get_user_info(settings, '1234', 'token')
Here is a snippet: <|code_start|># # You should have received a copy of the GNU Affero General Public License # along with Yith Library Server. If not, see <http://www.gnu.org/licenses/>. class FakeDatabase(object): def __init__(self, name): self.name = name self.is_authenticated = False ...
mdb = db.MongoDB(connection_factory=FakeConnection)
Here is a snippet: <|code_start|> res = self.testapp.post('/oauth2/endpoints/authorization', { 'cancel': 'No thanks', 'response_type': 'code', 'client_id': '123456', 'redirect_uri': 'https://example.com/callback', }) self.ass...
'scope': DEFAULT_SCOPE,
Given the following code snippet before the placeholder: <|code_start|> self.assertNotEqual(grant, None) code = grant['code'] location = 'https://example.com/callback?code=%s' % code self.assertEqual(res.location, location) # authenticate user who has already authorize the app ...
'Authorization': auth_basic_encode('123456', 'secret'),
Given the code snippet: <|code_start|># along with Yith Library Server. If not, see <http://www.gnu.org/licenses/>. def persona_login(request): if request.method != 'POST': return HTTPMethodNotAllowed('Only POST is allowed') assertion = request.POST.get('assertion', None) if assertion is Non...
return register_or_update(request, 'persona', user_id,
Next line prediction: <|code_start|># it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Yith Library Server is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANT...
'audience': get_audience(settings['public_url_root'])}
Predict the next line for this snippet: <|code_start|># Copyright (C) 2012-2013 Lorenzo Gil Sanchez <lorenzo.gil.sanchez@gmail.com> # # This file is part of Yith Library Server. # # Yith Library Server is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License ...
evc = EmailVerificationCode()
Given the code snippet: <|code_start|># Yith Library Server is a password storage server. # Copyright (C) 2012-2013 Yaco Sistemas # Copyright (C) 2012-2013 Alejandro Blanco Escudero <alejandro.b.e@gmail.com> # Copyright (C) 2012-2013 Lorenzo Gil Sanchez <lorenzo.gil.sanchez@gmail.com> # # This file is part of Yith Libr...
cm = CORSManager('')
Based on the snippet: <|code_start|> sys.stdout = StringIO() result = send_backups_via_email() self.assertEqual(result, None) stdout = sys.stdout.getvalue() expected_output = """Passwords sent to John3 Doe <john3@example.com> """ self.assertEqual(stdout, expected_output) ...
day = get_day_to_send({'_id': user_id}, 28)
Using the snippet: <|code_start|># along with Yith Library Server. If not, see <http://www.gnu.org/licenses/>. class BackupsTests(ScriptTests): clean_collections = ('users', 'passwords', ) def setUp(self): super(BackupsTests, self).setUp() # Save sys values self.old_args = sys.ar...
sys.stdout = StringIO()
Based on the snippet: <|code_start|> class BackupsTests(ScriptTests): clean_collections = ('users', 'passwords', ) def setUp(self): super(BackupsTests, self).setUp() # Save sys values self.old_args = sys.argv[:] self.old_stdout = sys.stdout os.environ['YITH_FAKE_DATE...
result = send_backups_via_email()
Predict the next line after this snippet: <|code_start|># it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Yith Library Server is distributed in the hope that it will be useful, # but...
credentials = decodebytes(credentials.encode('utf-8'))
Next line prediction: <|code_start|> Uses the Authorization header in Basic format to identify the client of this request against the set of registered applications on the server. """ authorization = request.headers.get('Authorization') if authorization is None: raise HTTPUnauthorized() ...
value = 'Basic ' + encodebytes(value.encode('utf-8')).decode('utf-8')
Given snippet: <|code_start|> Uses the Authorization header in Basic format to identify the client of this request against the set of registered applications on the server. """ authorization = request.headers.get('Authorization') if authorization is None: raise HTTPUnauthorized() met...
return encode_header(value)
Next line prediction: <|code_start|># # Yith Library Server is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a co...
response_args = dict(urlparse.parse_qsl(response.text))
Predict the next line for this snippet: <|code_start|># Copyright (C) 2012-2013 Lorenzo Gil Sanchez <lorenzo.gil.sanchez@gmail.com> # # This file is part of Yith Library Server. # # Yith Library Server is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License ...
auth = auth_header('POST', request_token_url, params, settings)
Here is a snippet: <|code_start|> return HTTPUnauthorized("OAuth tokens don't match") else: del request.session['oauth_token'] access_token_url = settings['twitter_access_token_url'] params = ( ('oauth_token', oauth_token), ) auth = auth_header('POST', access_token_url,...
twitter_info = get_user_info(settings, user_id, oauth_token)
Given snippet: <|code_start|> else: del request.session['oauth_token'] access_token_url = settings['twitter_access_token_url'] params = ( ('oauth_token', oauth_token), ) auth = auth_header('POST', access_token_url, params, settings, oauth_token) response = requests.post(ac...
first_name, last_name = split_name(twitter_info['name'])
Given snippet: <|code_start|> auth = auth_header('POST', access_token_url, params, settings, oauth_token) response = requests.post(access_token_url, data='oauth_verifier=%s' % oauth_verifier, headers={'Authorization': auth}) if response.status_code ...
return register_or_update(request, 'twitter', user_id, info,
Next line prediction: <|code_start|> saved_oauth_token = request.session['oauth_token'] except KeyError: return HTTPBadRequest('No oauth_token was found in the session') if saved_oauth_token != oauth_token: return HTTPUnauthorized("OAuth tokens don't match") else: del request...
existing_user = user_from_provider_id(request.db, 'twitter', user_id)
Based on the snippet: <|code_start|># Yith Library Server is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Yith Library Serve...
return send_email_to_admins(