rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
st = SubmissionType('Paper')
# def test_create(self):
u = url_for(controller='/cfp', action='new') params = {'person.handle': 'testguy', 'person.firstname': 'Testguy', 'person.lastname': 'McTest', 'person.email_address': 'testguy@example.org', 'submission.submission_type': 'Paper', 'submission.title': 'My Awesome Paper', 'submission.abstract': 'Some abstract'} res = self....
# def test_create(self):
ps = Person.select_by(handle='testguy') self.failIf(len(ps) == 0, "person object not in database") self.failUnless(len(ps) == 1, "too many person objects in database")
# def test_create(self):
ss = Submission.select_by(title='My Awesome Paper') self.failIf(len(ss) == 0, "submission object not in database") self.failUnless(len(ss) == 1, "too many submission objects in database") self.failUnless(ss[0] in ps[0].submissions, "submission not attributed to person")
# def test_create(self):
ps[0].delete() st.delete() objectstore.commit() ss = Submission.select() self.failUnless(len(ss) == 0, "submission database not empty") ps = Person.select() self.failUnless(len(ps) == 0, "person database not empty") sts = SubmissionType.select() self.failUnless(len(sts) == 0, "submissino type database not empty")
# def test_create(self):
print v.submissions[0].submission_type
def test_new(self): # set up some subtypes bof = SubmissionType(name='BOF')
for k in result['person']: setattr(c.person, k, result['person'][k]) for k in result['registration']: setattr(c.registration, k, result['registration'][k])
for k in results['person']: setattr(c.person, k, results['person'][k]) for k in results['registration']: setattr(c.registration, k, results['registration'][k])
def new(self):
to_match = re.match(t'^.*To:.*testguy@example.org', Dummy_smtplib.existing.message, re.DOTALL)
to_match = re.match(r'^.*To:.*testguy@example.org', Dummy_smtplib.existing.message, re.DOTALL)
def test_forgotten_password(self): p = model.Person(email_address='testguy@example.org') self.objectstore.save(c) self.objectstore.flush()
mangles = dict(password=lambda p: return md5.new(p).hexdigest())
mangles = dict(password=lambda p: md5.new(p).hexdigest())
def __init__(cls, name, bases, classdict): if 'model' in classdict: monkeypatch(cls, 'test_create', 'create')
mangles = dict(password=lambda p: return md5.new(p).hexdigest())
mangles = dict(password=lambda p: md5.new(p).hexdigest())
def create(self): """Create an object of the data model, check that it was inserted into the database, and then delete it. Set the attributes for this model object in the ``samples`` class variable.
)
),
def setup_config(command, filename, section, vars): """ Place any commands to setup zookeepr here. """ from paste.deploy import appconfig config = appconfig('config:' + filename)
model.registartion.tables.accommodation_location.insert().execute(
model.registration.tables.accommodation_location.insert().execute(
def setup_config(command, filename, section, vars): """ Place any commands to setup zookeepr here. """ from paste.deploy import appconfig config = appconfig('config:' + filename)
model.registration.tables.acommodation_location.insert().execute(
model.registration.tables.accommodation_location.insert().execute(
def setup_config(command, filename, section, vars): """ Place any commands to setup zookeepr here. """ from paste.deploy import appconfig config = appconfig('config:' + filename)
warnings.warn("edit: form validation failed: %s" % errors)
if asbool(request.environ['paste.config']['global_conf'].get('debug')): warnings.warn("edit: form validation failed: %s" % errors)
def edit(self, id): """Allow editing of an object.
person = c.registration.person
def _build_invoice(self): person = c.registration.person r = c.registration
person.invoices.append(invoice)
r.person.invoices.append(invoice)
def _build_invoice(self): person = c.registration.person r = c.registration
iid = model.InvoiceItem(description='Penguin Dinner ticket (included in registraion)',
iid = model.InvoiceItem(description='Penguin Dinner ticket (included in registration)',
def _build_invoice(self): person = c.registration.person r = c.registration
iidt = model.InvoiceItem(description = 'Penguin dinner ticket',
iidt = model.InvoiceItem(description = 'Additional Penguin dinner tickets',
def _build_invoice(self): person = c.registration.person r = c.registration
setattr(c, model_name + '_collection', self.model.select())
setattr(c, model_name + '_collection', g.objectstore.query(self.model).select())
def index(self): """Show a list of all objects currently in the system.""" # GET, POST -> return list of objects
self.assertEqual(3, f.fields['submission.submission_type_id'][0].value)
self.assertEqual('3', f.fields['submission.submission_type_id'][0].value)
def test_selected_radio_button_in_edit(self): # Test that a radio button is checked when editing a submission s = model.Submission(id=1, submission_type_id=3, title='foo', abstract='bar', experience='', url='') self.session.save(s) self.session.flush()
monkeypatch(cls, 'test_create', 'create')
monkeypatch(cls, 'test_crud', 'crud')
def __init__(cls, name, bases, classdict): if 'model' in classdict: monkeypatch(cls, 'test_create', 'create')
self.objectstore.save(c)
self.objectstore.save(p)
def test_forgotten_password(self): p = model.Person(email_address='testguy@example.org') self.objectstore.save(c) self.objectstore.flush()
sqlalchemy.objectstore.clear()
def __call__(self, action, **params): # Insert any code to be run per request here
self.failUnless(p.password_hash == md5.new('p4ssw0rd').hexdigest().
self.failUnless(p.password_hash == md5.new('p4ssw0rd').hexdigest(),
def test_password_set(self): """Test person password setting works after object creation""" p = Person(handle='testguy', email_address='testguy@example.org') objectstore.flush() d = {'password': 'p4ssw0rd'} p.update(**d) objectstore.flush()
except IndexError;
except IndexError:
def start_response(status, headers, exc_info=None): pass
resp.mustcontain("confirm")
resp.mustcontain("follow the instructions in that message")
def test_create_account(self): """Test the process of creating new accounts. """ Dummy_smtplib.install() # get the home page resp = self.app.get('/') # click on the 'create new account' link resp = resp.click('new user?') # fill out the form f = resp.form f['registration.email_address'] = 'testguy@example.org' f['regi...
if asbool(request.environ['paste.config']['app_conf'].get('debug', 'false')): warnings.warn("edit: form validation failed: %s" % errors)
warnings.warn("edit: form validation failed: %s" % errors)
def edit(self, id): """Allow editing of an object.
sqlalchemy.global_connect('sqlite', dict(filename='somedb.db'))
sqlalchemy.global_connect(app_conf['dburi'])
def __init__(self, global_conf, app_conf, **extra): """ You can put any objects which need to be initialised only once here as class attributes and they will be available as globals everywhere in your application and will be intialised only once, not on every request. ``global_conf`` The same as variable used througho...
print p3.submissions print s.people
print "p3 subs:", p3.submissions print "s.peopl", s.people
def test_multiple_persons_per_submission(self): session = create_session()
o.delete() o.flush()
self.objectstore.delete(o) self.objectstore.flush()
def edit(self): #"""Test edit action on controller"""
o.save() o.flush()
o = self.additional(o) self.objectstore.save(o) self.objectstore.flush()
def invalid_get_on_edit(self): #"""Test that GET requests on edit action don't modify"""
objectstore.clear()
self.objectstore.clear()
def invalid_get_on_edit(self): #"""Test that GET requests on edit action don't modify"""
o = self.model.get(oid)
o = self.objectstore.get(self.model, oid)
def invalid_get_on_edit(self): #"""Test that GET requests on edit action don't modify"""
o.delete() o.flush()
self.objectstore.delete(o) self.objectstore.flush()
def invalid_get_on_edit(self): #"""Test that GET requests on edit action don't modify"""
o.save() o.flush()
o = self.additional(o) self.objectstore.save(o) self.objectstore.flush()
def invalid_get_on_delete(self): #"""Test that GET requests on delete action don't modify""" # create some data o = self.model(**self.make_model_data()) o.save() o.flush()
objectstore.clear()
self.objectstore.clear()
def invalid_get_on_delete(self): #"""Test that GET requests on delete action don't modify""" # create some data o = self.model(**self.make_model_data()) o.save() o.flush()
o = self.model.get(oid)
o = self.objectstore.get(self.model, oid)
def invalid_get_on_delete(self): #"""Test that GET requests on delete action don't modify""" # create some data o = self.model(**self.make_model_data()) o.save() o.flush()
o.delete() o.flush()
self.objectstore.delete(o) self.objectstore.flush()
def invalid_get_on_delete(self): #"""Test that GET requests on delete action don't modify""" # create some data o = self.model(**self.make_model_data()) o.save() o.flush()
def __init__(cls, name, bases, classdict):
def __init__(mcs, name, bases, classdict): type.__init__(mcs, name, bases, classdict)
def __init__(cls, name, bases, classdict): if 'table' in classdict: monkeypatch(cls, 'test_insert', 'insert') for k in ['not_nullable', 'unique']: if k + 's' in classdict: monkeypatch(cls, 'test_' + k, k)
monkeypatch(cls, 'test_insert', 'insert')
monkeypatch(mcs, 'test_insert', 'insert')
def __init__(cls, name, bases, classdict): if 'table' in classdict: monkeypatch(cls, 'test_insert', 'insert') for k in ['not_nullable', 'unique']: if k + 's' in classdict: monkeypatch(cls, 'test_' + k, k)
monkeypatch(cls, 'test_' + k, k)
monkeypatch(mcs, 'test_' + k, k)
def __init__(cls, name, bases, classdict): if 'table' in classdict: monkeypatch(cls, 'test_insert', 'insert') for k in ['not_nullable', 'unique']: if k + 's' in classdict: monkeypatch(cls, 'test_' + k, k)
``sample`` is a list of dictionaries of columns and their values to use
``samples`` is a list of dictionaries of columns and their values to use
def __init__(cls, name, bases, classdict): if 'table' in classdict: monkeypatch(cls, 'test_insert', 'insert') for k in ['not_nullable', 'unique']: if k + 's' in classdict: monkeypatch(cls, 'test_' + k, k)
sample = [dict(name='testguy', email_address='test@example.org')]
samples = [dict(name='testguy', email_address='test@example.org')]
def __init__(cls, name, bases, classdict): if 'table' in classdict: monkeypatch(cls, 'test_insert', 'insert') for k in ['not_nullable', 'unique']: if k + 's' in classdict: monkeypatch(cls, 'test_' + k, k)
for m in self.table.split('.'): module = getattr(module, m)
for submodule in self.table.split('.'): module = getattr(module, submodule)
def get_table(self): """Return the table, coping with scoping.
r = select([func.count(self.get_table().c.id)]).execute() self.assertEqual(0, r.fetchone()[0])
result = select([func.count(self.get_table().c.id)]).execute() self.assertEqual(0, result.fetchone()[0])
def check_empty_table(self): """Check that the database was left empty after the test""" r = select([func.count(self.get_table().c.id)]).execute() self.assertEqual(0, r.fetchone()[0])
t = self.get_table()
for sample in self.samples: print "testing insert of s %s" % sample query = self.get_table().insert() print query query.execute(sample)
def insert(self): """Test insertion of sample data
for s in self.sample: print "testing insert of s %s" % s q = t.insert() print q q.execute(s)
for key in sample.keys(): query = select([getattr(self.get_table().c, key)]) print "query", query result = query.execute() print result row = result.fetchone() print "row", row self.assertEqual(sample[key], row[0])
def insert(self): """Test insertion of sample data
for k in s.keys(): q = select([getattr(t.column, k)]) print "query", q r = q.execute() print r row = r.fetchone() print "row", row self.assertEqual(s[k], row[0]) t.delete().execute()
self.get_table().delete().execute()
def insert(self): """Test insertion of sample data
for s in self.sample: q = t.insert() q.execute(s)
for sample in self.samples: query = self.get_table().insert() query.execute(sample)
def insert(self): """Test insertion of sample data
r = select([func.count(t.c.id)]).execute()
result = select([func.count(self.get_table().c.id)]).execute()
def insert(self): """Test insertion of sample data
self.assertEqual(len(self.sample), r.fetchone()[0])
self.assertEqual(len(self.samples), result.fetchone()[0])
def insert(self): """Test insertion of sample data
t.delete().execute()
self.get_table().delete().execute()
def insert(self): """Test insertion of sample data
self.failIf(len(self.sample) < 1, "not enough data to test not-nullable columns")
self.failIf(len(self.samples) < 1, "not enough sample data")
def not_nullable(self): """Check that certain columns of a table are not nullable. Specify the ``not_nullables`` class variable with a list of column names that must not be null, and this method will insert into the table rows with each set to null and test for an exception from the database layer. """
coldata.update(self.sample[0])
coldata.update(self.samples[0])
def not_nullable(self): """Check that certain columns of a table are not nullable. Specify the ``not_nullables`` class variable with a list of column names that must not be null, and this method will insert into the table rows with each set to null and test for an exception from the database layer. """
q = self.get_table().insert() self.assertRaisesAny(q.execute, coldata)
query = self.get_table().insert() self.assertRaisesAny(query.execute, coldata)
def not_nullable(self): """Check that certain columns of a table are not nullable. Specify the ``not_nullables`` class variable with a list of column names that must not be null, and this method will insert into the table rows with each set to null and test for an exception from the database layer. """
self.failIf(len(self.sample) < 2, "not enough sample data in the self.sample list to test uniqueness")
self.failIf(len(self.samples) < 2, "not enough sample data")
def unique(self): """Check that certain attributes of a model object are unique.
self.get_table().insert().execute(self.sample[0])
self.get_table().insert().execute(self.samples[0])
def unique(self): """Check that certain attributes of a model object are unique.
attr.update(self.sample[1])
attr.update(self.samples[1])
def unique(self): """Check that certain attributes of a model object are unique.
attr[col] = self.sample[0][col]
attr[col] = self.samples[0][col]
def unique(self): """Check that certain attributes of a model object are unique.
q = self.get_table().insert() self.assertRaisesAny(q.execute, attr)
query = self.get_table().insert() self.assertRaisesAny(query.execute, attr)
def unique(self): """Check that certain attributes of a model object are unique.
print result
def edit(self, id): """Allow editing of an object.
print "pre edit:", self.obj
def edit(self, id): """Allow editing of an object.
print "post edit:", self.obj
def edit(self, id): """Allow editing of an object.
print "view:", self.obj
def view(self): """View a specific object""" c.can_edit = self._can_edit()
crecs = self.session.query(PasswordResetConfirmation).select_by(email_address='nonexistent@example.org')
crecs = self.objectstore.query(PasswordResetConfirmation).select_by(email_address='nonexistent@example.org')
def test_forgotten_password_no_account(self): """Test that an invalid email address doesn't start a password change. """ Dummy_smtplib.install()
self.session.save(c) self.session.flush()
self.objectstore.save(c) self.objectstore.flush()
def test_confirm_old_url_hash(self): """Test that old url_hashes are caught""" email = 'testguy@example.org' stamp = datetime.datetime.now() - datetime.timedelta(24, 0, 1) c = PasswordResetConfirmation(email_address=email) c.timestamp = stamp self.session.save(c) self.session.flush() cid = c.id
self.session.clear() c = self.session.get(PasswordResetConfirmation, cid)
self.objectstore.clear() c = self.objectstore.get(PasswordResetConfirmation, cid)
def test_confirm_old_url_hash(self): """Test that old url_hashes are caught""" email = 'testguy@example.org' stamp = datetime.datetime.now() - datetime.timedelta(24, 0, 1) c = PasswordResetConfirmation(email_address=email) c.timestamp = stamp self.session.save(c) self.session.flush() cid = c.id
self.session.save(c) self.session.flush()
self.objectstore.save(c) self.objectstore.flush()
def test_confirm(self): """Test confirmation of a password reset that should succeed"""
entry = ('uid=testguy,dc=example,dc=org', {'mail': [email]}) Dummy_ldap.existing.results[0] = entry print "pre-results:", Dummy_ldap.existing.results
def test_confirm(self): """Test confirmation of a password reset that should succeed"""
print "results", Dummy_ldap.existing.results entry = Dummy_ldap.existing.results[0] self.failUnless('userPassword' in entry[1].keys(), "password not set, entry currently %r" % (entry,))
def test_confirm(self): """Test confirmation of a password reset that should succeed"""
self.session.clear() c = self.session.get(PasswordResetConfirmation, cid)
self.objectstore.clear() c = self.objectstore.get(PasswordResetConfirmation, cid)
def test_confirm(self): """Test confirmation of a password reset that should succeed"""
self.fail("not testing password has been set") self.objectstore.delete(p) self.objectstore.flush()
def test_confirm(self): """Test confirmation of a password reset that should succeed"""
self.session.save(c) self.session.flush()
self.objectstore.save(c) self.objectstore.flush()
def test_duplicate_password_reset(self): """Try to reset a password twice.
crecs = self.session.query(PasswordResetConfirmation).select_by(email_address=email)
crecs = self.objectstore.query(PasswordResetConfirmation).select_by(email_address=email)
def test_duplicate_password_reset(self): """Try to reset a password twice.
self.session.delete(crecs[0]) self.session.delete(c) self.session.flush()
self.objectstore.delete(crecs[0]) self.objectstore.delete(c) self.objectstore.flush()
def test_duplicate_password_reset(self): """Try to reset a password twice.
params=dict(name='Asterisk Talk'))
params={'submissiontype.name': 'Asterisk Talk'})
def test_create(self): """Test create action on /submissiontype"""
params=dict(name='lightning talk'))
params={'submissiontype.name': 'lightning talk'})
def test_edit(self): """Test edit operation on /submissiontype"""
res = self.app.post(u, params=dict(submit='submit'))
res = self.app.post(u)
def test_delete(self): """Test delete operation on /submissiontype"""
res = self.app.post(u, params=dict(submit='submit'), status=302)
res = self.app.post(u, status=302)
def test_invalid_delete(self): """Test that deletes of nonexistent subtypes are handled gracefully"""
def _get_password(self, value):
def _get_password(self):
def _get_password(self, value): return self.password_hash
self.failUnlessEqual(None, error_match, "Errors in message: %s" % error_match.group(0))
if error_match is not None: self.fail("Errors in message: %s" % error_match.group(0))
def create(self): #"""Test create action on controller"""
redirect_to(controller='home', action='index', id=None)
default_redirect = dict(action='index', id=None) self.redirect_to('delete', default_redirect)
def delete(self): """Delete the proposal type
def delete(self): print "session", session return super(AttachmentController, self).delete()
def view(self, id): att = g.objectstore.get(Attachment, id)
raise Invalid("Thanks for your keenness, but you've already registered!")
raise Invalid("Thanks for your keenness, but you've already registered!", value, state)
def validate_python(self, value, state): rego = None if 'signed_in_person_id' in session: rego = Query(model.Registration).get_by(person_id=session['signed_in_person_id']) if rego is not None: raise Invalid("Thanks for your keenness, but you've already registered!")
print request.environ['PATH_INFO']
def start_response(status, headers, exc_info=None): pass
f.submit()
resp = f.submit() print resp
def test_edit_review(self): """test that a reviewer can edit their review""" s = model.Person(email_address='submitter@example.org', fullname='submitter') objectstore.save(s) p = model.Proposal(title='prop', abstract='abs', experience='exp', type=Query(model.ProposalType).get(1)) objectstore.save(p) s.proposals.append(...
print "r is:", r
def confirm(self, id): """Confirm a registration with the given ID.
beds=100
beds=125,
def setup_config(command, filename, section, vars): """ Place any commands to setup zookeepr here. """ from paste.deploy import appconfig config = appconfig('config:' + filename)
beds=100,
beds=90,
def setup_config(command, filename, section, vars): """ Place any commands to setup zookeepr here. """ from paste.deploy import appconfig config = appconfig('config:' + filename)
beds=100,
beds=50,
def setup_config(command, filename, section, vars): """ Place any commands to setup zookeepr here. """ from paste.deploy import appconfig config = appconfig('config:' + filename)
print 'yarr', os
print 'objects of type %s in the db: %r' % (self.model.__name__, os)
def create(self): #"""Test create action on controller"""
reg = model.Registration(email_address='testguy@example.org',
reg = model.core.domain.Registration(email_address='testguy@example.org',
def test_create(self): session = create_session()
sub = model.Submission(title="title",
sub = model.submission.domain.Submission(title="title",
def test_create(self): session = create_session()
if p.is_earlybird(registration.last_modification_timestamp):
if p.is_earlybird(registration.creation_timestamp):
def pay(self, id): registration = self.obj if registration.person.invoices: if registration.person.invoices[0].good_payments or registration.person.invoices[0].bad_payments: redirect_to("/Errors/InvoiceAlreadyPaid") invoice = registration.person.invoices[0] for ii in invoice.items: self.dbsession.delete(ii) else: invoi...
ii = model.InvoiceItem(description=description, qty=1, cost=p.getTypeAmount(registration.type, registration.last_modification_timestamp))
ii = model.InvoiceItem(description=description, qty=1, cost=p.getTypeAmount(registration.type, registration.creation_timestamp))
def pay(self, id): registration = self.obj if registration.person.invoices: if registration.person.invoices[0].good_payments or registration.person.invoices[0].bad_payments: redirect_to("/Errors/InvoiceAlreadyPaid") invoice = registration.person.invoices[0] for ii in invoice.items: self.dbsession.delete(ii) else: invoi...
self.ebdate = datetime.datetime(22, 11, 06, 0, 0, 0)
self.ebdate = datetime.datetime(2006, 11, 22)
def __init__(self): self.types = { "Professional": [51750, 69000], "Hobbyist": [30000, 22500], "Concession": [9900, 9900] } self.dinner = { "1": 6000, "2": 12000, "3": 18000 } self.accommodation = { "0": 0, "1": 4950, "2": 5500, "3": 6000, "5": 3500, "6": 5850 } self.ebdate = datetime.datetime(22, 11, 06, 0, 0, 0) #ind...
return date <= self.ebdate
result = date <= self.ebdate return result
def is_earlybird(self, date): return date <= self.ebdate
mapper(Person, join(account, person))
class NToOneMapperExtension(MapperExtension): def after_insert(self, mapper, connection, instance): for table in mapper.tables: if table.name == 'account': for col in mapper.pks_by_table[table]: account_id = mapper._getattrbycolumn(instance, col) break instance.account_id = account_id mapper(Person, join(account, pers...
def _get_password(self, value): return self.password_hash
self.objectstore.flush()
def test_proposal_with_attachment(self): p = Proposal(title='prop 1') self.objectstore.save(p)
if not self.registryValue('bugSnarfer', msg.args[0]):
if msg.args[0][0] == '
def bugSnarfer(self, irc, msg, match): r"""\b(?P<bt>(([a-z]+)?\s+bugs?|[a-z]+))\s+#?(?P<bug>\d+(?!\d*\.\d+)((,|\s*(and|en|et|und|ir))\s*#?\d+(?!\d*\.\d+))*)""" if not self.registryValue('bugSnarfer', msg.args[0]): return # Don't double on commands s = str(msg).split(':')[2] if s[0] in str(conf.supybot.reply.whenAddress...