def setup_test_data(settings): from c2cgeoform.models import DBSession import transaction if DBSession.query(District).get(0) is None: DBSession.add(District(id=0, name="Pully")) DBSession.add(District(id=1, name="Paudex")) DBSession.add(District(id=2, name="Belmont-sur-Lausanne")) DBSession.add(District(id=3, name="Trois-Chasseurs")) DBSession.add(District(id=4, name="La Claie-aux-Moines")) DBSession.add(District(id=5, name="Savigny")) DBSession.add(District(id=6, name="Mollie-Margot")) if DBSession.query(Situation).get(0) is None: DBSession.add(Situation(id=0, name="Road", name_fr="Route")) DBSession.add(Situation(id=1, name="Sidewalk", name_fr="Trottoir")) DBSession.add(Situation(id=2, name="Berm", name_fr="Berme")) DBSession.add( Situation(id=3, name="Vegetated berm", name_fr="Berme végétalisée")) DBSession.add(Situation(id=4, name="Green zone", name_fr="Zone verte")) DBSession.add(Situation(id=5, name="Cobblestone", name_fr="Pavés")) if DBSession.query(BusStop).count() == 0: _add_bus_stops(DBSession, settings['bus_stops_file']) if DBSession.query(Address).get(0) is None: DBSession.add(Address(id=0, label="Bern")) DBSession.add(Address(id=1, label="Lausanne")) DBSession.add(Address(id=2, label="Genève")) DBSession.add(Address(id=3, label="Zurich")) DBSession.add(Address(id=4, label="Lugano")) transaction.commit()
def setup_test_data(settings): from c2cgeoform.models import DBSession import transaction if DBSession.query(District).get(0) is None: DBSession.add(District(id=0, name="Pully")) DBSession.add(District(id=1, name="Paudex")) DBSession.add(District(id=2, name="Belmont-sur-Lausanne")) DBSession.add(District(id=3, name="Trois-Chasseurs")) DBSession.add(District(id=4, name="La Claie-aux-Moines")) DBSession.add(District(id=5, name="Savigny")) DBSession.add(District(id=6, name="Mollie-Margot")) if DBSession.query(Situation).get(0) is None: DBSession.add(Situation(id=0, name="Road", name_fr="Route")) DBSession.add(Situation(id=1, name="Sidewalk", name_fr="Trottoir")) DBSession.add(Situation(id=2, name="Berm", name_fr="Berme")) DBSession.add(Situation( id=3, name="Vegetated berm", name_fr="Berme végétalisée")) DBSession.add(Situation(id=4, name="Green zone", name_fr="Zone verte")) DBSession.add(Situation(id=5, name="Cobblestone", name_fr="Pavés")) if DBSession.query(BusStop).count() == 0: _add_bus_stops(DBSession, settings['bus_stops_file']) if DBSession.query(Address).get(0) is None: DBSession.add(Address(id=0, label="Bern")) DBSession.add(Address(id=1, label="Lausanne")) DBSession.add(Address(id=2, label="Genève")) DBSession.add(Address(id=3, label="Zurich")) DBSession.add(Address(id=4, label="Lugano")) transaction.commit()
def cleanup(self): from models_test import Person, EmploymentStatus, Phone,\ Tag, TagsForPerson DBSession.query(TagsForPerson).delete() DBSession.query(Tag).delete() DBSession.query(Phone).delete() DBSession.query(Person).delete() DBSession.query(EmploymentStatus).delete()
def test_form_submit_successful(self): from c2cgeoform.views import form from models_test import Person request = testing.DummyRequest(post=MultiDict()) request.matchdict['schema'] = 'tests_persons' request.POST.add('submit', 'submit') request.POST.add('name', 'Peter') request.POST.add('first_name', 'Smith') request.POST.add('__start__', 'phones:sequence') request.POST.add('__start__', 'phones:mapping') request.POST.add('id', '') request.POST.add('number', '123456789') request.POST.add('personId', '') request.POST.add('__end__', 'phones:mapping') request.POST.add('__end__', 'phones:sequence') request.POST.add('__start__', 'tags:sequence') request.POST.add('tags', u'0') request.POST.add('tags', u'1') request.POST.add('__end__', 'tags:sequence') response = form(request) person = DBSession.query(Person).one() self.assertEquals('Peter', person.name) self.assertEquals('Smith', person.first_name) self.assertEquals(1, len(person.phones)) phone = person.phones[0] self.assertEquals('123456789', phone.number) self.assertIsNotNone(phone.id) self.assertEquals(2, len(person.tags)) tag_for_person1 = person.tags[0] self.assertEquals(0, tag_for_person1.tag_id) self.assertEquals(person.id, tag_for_person1.person_id) self.assertIsNotNone(tag_for_person1.id) tag_for_person2 = person.tags[1] self.assertEquals(1, tag_for_person2.tag_id) self.assertEquals(person.id, tag_for_person2.person_id) self.assertIsNotNone(tag_for_person2.id) id = person.id phone_id = phone.id self.assertTrue('form' in response) form_html = response['form'] self.assertTrue('name="id" value="' + str(id) + '"' in form_html) self.assertTrue('name="id" value="' + str(phone_id) + '"' in form_html) self.assertTrue( 'name="person_id" value="' + str(id) + '"' in form_html) self.assertTrue('Tag A' in form_html) self.assertTrue('Tag B' in form_html) self.assertTrue('name="submit"' not in form_html)
def bus_stops(request): stops = DBSession.query(BusStop).all() return { 'type': 'FeatureCollection', 'features': [{ 'type': 'Feature', 'id': stop.id, 'properties': { 'name': stop.name}, 'geometry': mapping(to_shape(stop.geom)) } for stop in stops] }
def bus_stops(request): stops = DBSession.query(BusStop).all() return { 'type': 'FeatureCollection', 'features': [{ 'type': 'Feature', 'id': stop.id, 'properties': { 'name': stop.name }, 'geometry': mapping(to_shape(stop.geom)) } for stop in stops] }
def setup_test_data(): from c2cgeoform.models import DBSession import transaction if DBSession.query(District).get(0) is None: DBSession.add(District(id=0, name="Pully")) DBSession.add(District(id=1, name="Paudex")) DBSession.add(District(id=2, name="Belmont-sur-Lausanne")) DBSession.add(District(id=3, name="Trois-Chasseurs")) DBSession.add(District(id=4, name="La Claie-aux-Moines")) DBSession.add(District(id=5, name="Savigny")) DBSession.add(District(id=6, name="Mollie-Margot")) if DBSession.query(Situation).get(0) is None: DBSession.add(Situation(id=0, name="Road", name_fr="Route")) DBSession.add(Situation(id=1, name="Sidewalk", name_fr="Trottoir")) DBSession.add(Situation(id=2, name="Berm", name_fr="Berme")) DBSession.add(Situation( id=3, name="Vegetated berm", name_fr="Berme végétalisée")) DBSession.add(Situation(id=4, name="Green zone", name_fr="Zone verte")) DBSession.add(Situation(id=5, name="Cobblestone", name_fr="Pavés")) transaction.commit()
def test_form_submit_only_validate(self): from c2cgeoform.views import form from models_test import Person request = testing.DummyRequest(post=MultiDict()) request.matchdict['schema'] = 'tests_persons' request.POST.add('submit', 'submit') request.POST.add('name', 'Peter') request.POST.add('first_name', 'Smith') request.POST.add('__only_validate__', '1') form(request) count = DBSession.query(Person).count() # form was valid, but no row was created self.assertEquals(0, count)
def test_form_submit_only_validate(self): from c2cgeoform.views import form from models_test import Person request = self._get_request() request.matchdict['schema'] = 'tests_persons' request.POST.add('submit', 'submit') request.POST.add('name', 'Peter') request.POST.add('first_name', 'Smith') request.POST.add('__only_validate__', '1') form(request) count = DBSession.query(Person).count() # form was valid, but no row was created self.assertEquals(0, count)
def test_form_submit_confirmation_back(self): from c2cgeoform.views import form from models_test import Person request = self._get_request() request.matchdict['schema'] = 'tests_persons' request.POST.add('submit', 'submit') request.POST.add('name', 'Peter') request.POST.add('first_name', 'Smith') response = form(request) # valid submission, confirmation page should be shown self.assertTrue(isinstance(response, HTTPFound)) url = TestView.BASE_URL + '/form/confirm?__submission_id__=' self.assertTrue(response.location.startswith(url)) # get submission_id matcher = re.search('__submission_id__=(.*)', response.location) submission_id = matcher.group(1) # now simulate going back to the form request2 = self._get_request() request2.session = request.session request2.matchdict['schema'] = 'tests_persons' request2.params['__submission_id__'] = submission_id response = form(request2) form_html = response['form'] # form is shown again with values restored from the session self.assertTrue( '<input type="text" name="name" value="Peter"' in form_html) # and no row was created count = DBSession.query(Person).count() self.assertEquals(0, count)
def test_form_submit_successful_without_confirmation(self): from c2cgeoform.views import form, confirmation from c2cgeoform.schema import register_schema from models_test import Person register_schema('tests_persons_no_confirmation', Person, show_confirmation=False) request = self._get_request() request.matchdict['schema'] = 'tests_persons_no_confirmation' request.POST.add('submit', 'submit') request.POST.add('name', 'Peter') request.POST.add('first_name', 'Smith') request.POST.add('__start__', 'phones:sequence') request.POST.add('__start__', 'phones:mapping') request.POST.add('id', '') request.POST.add('number', '123456789') request.POST.add('personId', '') request.POST.add('__end__', 'phones:mapping') request.POST.add('__end__', 'phones:sequence') request.POST.add('__start__', 'tags:sequence') request.POST.add('tags', u'0') request.POST.add('tags', u'1') request.POST.add('__end__', 'tags:sequence') response = form(request) # valid submission, redirect to confirmation view self.assertTrue(isinstance(response, HTTPFound)) url = TestView.BASE_URL + '_no_confirmation' + \ '/form/confirm?__submission_id__=' self.assertTrue(response.location.startswith(url)) # get submission_id matcher = re.search('__submission_id__=(.*)', response.location) submission_id = matcher.group(1) # simulate that the confirmation view is called, # which directly persists the object request2 = self._get_request() request2.session = request.session request2.matchdict['schema'] = 'tests_persons_no_confirmation' request2.params['__submission_id__'] = submission_id response = confirmation(request2) person = DBSession.query(Person).one() self.assertIsNotNone(person.hash) self.assertEquals('Peter', person.name) self.assertEquals('Smith', person.first_name) self.assertEquals(1, len(person.phones)) phone = person.phones[0] self.assertEquals('123456789', phone.number) self.assertIsNotNone(phone.id) self.assertEquals(2, len(person.tags)) tag_for_person1 = person.tags[0] self.assertEquals(0, tag_for_person1.tag_id) self.assertEquals(person.id, tag_for_person1.person_id) self.assertIsNotNone(tag_for_person1.id) tag_for_person2 = person.tags[1] self.assertEquals(1, tag_for_person2.tag_id) self.assertEquals(person.id, tag_for_person2.person_id) self.assertIsNotNone(tag_for_person2.id) self.assertTrue(isinstance(response, HTTPFound)) self.assertEquals( TestView.BASE_URL + '_no_confirmation' + '/form/' + person.hash, response.location)
def test_edit_submit_successful(self): from c2cgeoform.views import edit from models_test import Person, Phone, TagsForPerson person = Person(name="Peter", first_name="Smith") phone = Phone(number="123456789") person.phones.append(phone) tag_for_person = TagsForPerson(tag_id=0) person.tags.append(tag_for_person) DBSession.add(person) DBSession.flush() old_tag_for_person_id = tag_for_person.id request = testing.DummyRequest(post=MultiDict()) request.matchdict['schema'] = 'tests_persons' request.matchdict['id'] = str(person.id) request.POST.add('id', str(person.id)) request.POST.add('submit', 'submit') request.POST.add('name', 'Peter') request.POST.add('first_name', 'Smith') request.POST.add('age', '43') request.POST.add('__start__', 'phones:sequence') request.POST.add('__start__', 'phones:mapping') request.POST.add('id', str(phone.id)) request.POST.add('number', '23456789') request.POST.add('person_id', str(person.id)) request.POST.add('__end__', 'phones:mapping') request.POST.add('__start__', 'phones:mapping') request.POST.add('number', '123456') request.POST.add('__end__', 'phones:mapping') request.POST.add('__end__', 'phones:sequence') request.POST.add('__start__', 'tags:sequence') request.POST.add('tags', u'0') request.POST.add('tags', u'1') request.POST.add('__end__', 'tags:sequence') response = edit(request) person = DBSession.query(Person).get(person.id) self.assertEquals('Peter', person.name) self.assertEquals('Smith', person.first_name) self.assertEquals(43, person.age) self.assertEquals(2, len(person.phones)) updated_phone = person.phones[0] self.assertEquals('23456789', updated_phone.number) self.assertEquals(phone.id, updated_phone.id) new_phone = person.phones[1] self.assertEquals('123456', new_phone.number) self.assertIsNotNone(new_phone.id) self.assertEquals(2, len(person.tags)) tag_for_person1 = person.tags[0] self.assertEquals(0, tag_for_person1.tag_id) self.assertEquals(person.id, tag_for_person1.person_id) self.assertIsNotNone(tag_for_person1.id) # a new row is created, also for the old entry self.assertNotEquals(old_tag_for_person_id, tag_for_person1.id) tag_for_person2 = person.tags[1] self.assertEquals(1, tag_for_person2.tag_id) self.assertEquals(person.id, tag_for_person2.person_id) self.assertIsNotNone(tag_for_person2.id) tags_for_persons = DBSession.query(TagsForPerson).all() # check that the old entry was deleted, so that there are only 2 self.assertEquals(2, len(tags_for_persons)) self.assertTrue('schema' in response) self.assertTrue('form' in response) form_html = response['form'] self.assertTrue('name="id"' in form_html) self.assertTrue('value="' + str(person.id) + '"' in form_html) self.assertTrue( 'name="id" value="' + str(person.id) + '"' in form_html) self.assertTrue('name="id" value="' + str(phone.id) + '"' in form_html) self.assertTrue( 'name="id" value="' + str(new_phone.id) + '"' in form_html) self.assertTrue( 'name="person_id" value="' + str(person.id) + '"' in form_html) self.assertTrue('name="submit"' in form_html) self.assertTrue('Tag A' in form_html) self.assertTrue('Tag B' in form_html)
def test_form_submit_successful_without_confirmation(self): from c2cgeoform.views import form, confirmation from c2cgeoform.schema import register_schema from models_test import Person register_schema( 'tests_persons_no_confirmation', Person, show_confirmation=False) request = self._get_request() request.matchdict['schema'] = 'tests_persons_no_confirmation' request.POST.add('submit', 'submit') request.POST.add('name', 'Peter') request.POST.add('first_name', 'Smith') request.POST.add('__start__', 'phones:sequence') request.POST.add('__start__', 'phones:mapping') request.POST.add('id', '') request.POST.add('number', '123456789') request.POST.add('personId', '') request.POST.add('__end__', 'phones:mapping') request.POST.add('__end__', 'phones:sequence') request.POST.add('__start__', 'tags:sequence') request.POST.add('tags', u'0') request.POST.add('tags', u'1') request.POST.add('__end__', 'tags:sequence') response = form(request) # valid submission, redirect to confirmation view self.assertTrue(isinstance(response, HTTPFound)) url = TestView.BASE_URL + '_no_confirmation' + \ '/form/confirm?__submission_id__=' self.assertTrue(response.location.startswith(url)) # get submission_id matcher = re.search('__submission_id__=(.*)', response.location) submission_id = matcher.group(1) # simulate that the confirmation view is called, # which directly persists the object request2 = self._get_request() request2.session = request.session request2.matchdict['schema'] = 'tests_persons_no_confirmation' request2.params['__submission_id__'] = submission_id response = confirmation(request2) person = DBSession.query(Person).one() self.assertIsNotNone(person.hash) self.assertEquals('Peter', person.name) self.assertEquals('Smith', person.first_name) self.assertEquals(1, len(person.phones)) phone = person.phones[0] self.assertEquals('123456789', phone.number) self.assertIsNotNone(phone.id) self.assertEquals(2, len(person.tags)) tag_for_person1 = person.tags[0] self.assertEquals(0, tag_for_person1.tag_id) self.assertEquals(person.id, tag_for_person1.person_id) self.assertIsNotNone(tag_for_person1.id) tag_for_person2 = person.tags[1] self.assertEquals(1, tag_for_person2.tag_id) self.assertEquals(person.id, tag_for_person2.person_id) self.assertIsNotNone(tag_for_person2.id) self.assertTrue(isinstance(response, HTTPFound)) self.assertEquals( TestView.BASE_URL + '_no_confirmation' + '/form/' + person.hash, response.location)
def addresses(request): if 'term' not in request.params: return HTTPBadRequest() term = '%%%s%%' % request.params['term'] query = DBSession.query(Address).filter(Address.label.ilike(term)) return [{'id': addr.id, 'label': addr.label} for addr in query]
def test_form_submit_successful(self): from c2cgeoform.views import form, confirmation from models_test import Person request = self._get_request() request.matchdict['schema'] = 'tests_persons' request.POST.add('submit', 'submit') request.POST.add('name', 'Peter') request.POST.add('first_name', 'Smith') request.POST.add('__start__', 'phones:sequence') request.POST.add('__start__', 'phones:mapping') request.POST.add('id', '') request.POST.add('number', '123456789') request.POST.add('personId', '') request.POST.add('__end__', 'phones:mapping') request.POST.add('__end__', 'phones:sequence') request.POST.add('__start__', 'tags:sequence') request.POST.add('tags', u'0') request.POST.add('tags', u'1') request.POST.add('__end__', 'tags:sequence') response = form(request) # valid submission, confirmation page should be shown self.assertTrue(isinstance(response, HTTPFound)) url = TestView.BASE_URL + '/form/confirm?__submission_id__=' self.assertTrue(response.location.startswith(url)) # get submission_id matcher = re.search('__submission_id__=(.*)', response.location) submission_id = matcher.group(1) # simulate that the confirmation page is shown request2 = self._get_request() request2.session = request.session request2.matchdict['schema'] = 'tests_persons' request2.params['__submission_id__'] = submission_id response = confirmation(request2) self.assertTrue('form' in response) form_html = response['form'] self.assertTrue( '<input type="hidden" name="__submission_id__"' in form_html) self.assertTrue( '<input type="hidden" name="__store_form__"' in form_html) # now simulate that the confirmation page is submitted request3 = self._get_request() request3.session = request.session request3.matchdict['schema'] = 'tests_persons' request3.params['__submission_id__'] = submission_id request3.params['__store_form__'] = '1' response = confirmation(request3) person = DBSession.query(Person).one() self.assertIsNotNone(person.hash) self.assertEquals('Peter', person.name) self.assertEquals('Smith', person.first_name) self.assertEquals(1, len(person.phones)) phone = person.phones[0] self.assertEquals('123456789', phone.number) self.assertIsNotNone(phone.id) self.assertEquals(2, len(person.tags)) tag_for_person1 = person.tags[0] self.assertEquals(0, tag_for_person1.tag_id) self.assertEquals(person.id, tag_for_person1.person_id) self.assertIsNotNone(tag_for_person1.id) tag_for_person2 = person.tags[1] self.assertEquals(1, tag_for_person2.tag_id) self.assertEquals(person.id, tag_for_person2.person_id) self.assertIsNotNone(tag_for_person2.id) self.assertTrue(isinstance(response, HTTPFound)) self.assertEquals(TestView.BASE_URL + '/form/' + person.hash, response.location)
def test_edit_submit_successful(self): from c2cgeoform.views import edit from models_test import Person, Phone, TagsForPerson person = Person(name="Peter", first_name="Smith") phone = Phone(number="123456789") person.phones.append(phone) tag_for_person = TagsForPerson(tag_id=0) person.tags.append(tag_for_person) DBSession.add(person) DBSession.flush() old_tag_for_person_id = tag_for_person.id request = self._get_request() request.matchdict['schema'] = 'tests_persons' request.matchdict['id'] = str(person.id) request.POST.add('id', str(person.id)) request.POST.add('submit', 'submit') request.POST.add('name', 'Peter') request.POST.add('first_name', 'Smith') request.POST.add('age', '43') request.POST.add('__start__', 'phones:sequence') request.POST.add('__start__', 'phones:mapping') request.POST.add('id', str(phone.id)) request.POST.add('number', '23456789') request.POST.add('person_id', str(person.id)) request.POST.add('__end__', 'phones:mapping') request.POST.add('__start__', 'phones:mapping') request.POST.add('number', '123456') request.POST.add('__end__', 'phones:mapping') request.POST.add('__end__', 'phones:sequence') request.POST.add('__start__', 'tags:sequence') request.POST.add('tags', u'0') request.POST.add('tags', u'1') request.POST.add('__end__', 'tags:sequence') response = edit(request) person = DBSession.query(Person).get(person.id) self.assertEquals('Peter', person.name) self.assertEquals('Smith', person.first_name) self.assertEquals(43, person.age) self.assertEquals(2, len(person.phones)) updated_phone = person.phones[0] self.assertEquals('23456789', updated_phone.number) self.assertEquals(phone.id, updated_phone.id) new_phone = person.phones[1] self.assertEquals('123456', new_phone.number) self.assertIsNotNone(new_phone.id) self.assertEquals(2, len(person.tags)) tag_for_person1 = person.tags[0] self.assertEquals(0, tag_for_person1.tag_id) self.assertEquals(person.id, tag_for_person1.person_id) self.assertIsNotNone(tag_for_person1.id) # a new row is created, also for the old entry self.assertNotEquals(old_tag_for_person_id, tag_for_person1.id) tag_for_person2 = person.tags[1] self.assertEquals(1, tag_for_person2.tag_id) self.assertEquals(person.id, tag_for_person2.person_id) self.assertIsNotNone(tag_for_person2.id) tags_for_persons = DBSession.query(TagsForPerson).all() # check that the old entry was deleted, so that there are only 2 self.assertEquals(2, len(tags_for_persons)) self.assertTrue('schema' in response) self.assertTrue('form' in response) form_html = response['form'] self.assertTrue('name="id"' in form_html) self.assertTrue('value="' + str(person.id) + '"' in form_html) self.assertTrue('name="id" value="' + str(person.id) + '"' in form_html) self.assertTrue('name="id" value="' + str(phone.id) + '"' in form_html) self.assertTrue('name="id" value="' + str(new_phone.id) + '"' in form_html) self.assertTrue('name="person_id" value="' + str(person.id) + '"' in form_html) self.assertTrue('name="submit"' in form_html) self.assertTrue('Tag A' in form_html) self.assertTrue('Tag B' in form_html)
def test_form_submit_successful(self): from c2cgeoform.views import form, confirmation from models_test import Person request = self._get_request() request.matchdict['schema'] = 'tests_persons' request.POST.add('submit', 'submit') request.POST.add('name', 'Peter') request.POST.add('first_name', 'Smith') request.POST.add('__start__', 'phones:sequence') request.POST.add('__start__', 'phones:mapping') request.POST.add('id', '') request.POST.add('number', '123456789') request.POST.add('personId', '') request.POST.add('__end__', 'phones:mapping') request.POST.add('__end__', 'phones:sequence') request.POST.add('__start__', 'tags:sequence') request.POST.add('tags', u'0') request.POST.add('tags', u'1') request.POST.add('__end__', 'tags:sequence') response = form(request) # valid submission, confirmation page should be shown self.assertTrue(isinstance(response, HTTPFound)) url = TestView.BASE_URL + '/form/confirm?__submission_id__=' self.assertTrue(response.location.startswith(url)) # get submission_id matcher = re.search('__submission_id__=(.*)', response.location) submission_id = matcher.group(1) # simulate that the confirmation page is shown request2 = self._get_request() request2.session = request.session request2.matchdict['schema'] = 'tests_persons' request2.params['__submission_id__'] = submission_id response = confirmation(request2) self.assertTrue('form' in response) form_html = response['form'] self.assertTrue( '<input type="hidden" name="__submission_id__"' in form_html) self.assertTrue( '<input type="hidden" name="__store_form__"' in form_html) # now simulate that the confirmation page is submitted request3 = self._get_request() request3.session = request.session request3.matchdict['schema'] = 'tests_persons' request3.params['__submission_id__'] = submission_id request3.params['__store_form__'] = '1' response = confirmation(request3) person = DBSession.query(Person).one() self.assertIsNotNone(person.hash) self.assertEquals('Peter', person.name) self.assertEquals('Smith', person.first_name) self.assertEquals(1, len(person.phones)) phone = person.phones[0] self.assertEquals('123456789', phone.number) self.assertIsNotNone(phone.id) self.assertEquals(2, len(person.tags)) tag_for_person1 = person.tags[0] self.assertEquals(0, tag_for_person1.tag_id) self.assertEquals(person.id, tag_for_person1.person_id) self.assertIsNotNone(tag_for_person1.id) tag_for_person2 = person.tags[1] self.assertEquals(1, tag_for_person2.tag_id) self.assertEquals(person.id, tag_for_person2.person_id) self.assertIsNotNone(tag_for_person2.id) self.assertTrue(isinstance(response, HTTPFound)) self.assertEquals( TestView.BASE_URL + '/form/' + person.hash, response.location)