def test_add_rep(self): Representative.add_rep(single_rep2) testrep = Representative.query.get(2) self.assertIsNotNone(testrep) self.assertEqual(testrep.full_name, 'George Borrello') self.assertEqual(testrep.first_name, 'George') self.assertEqual(testrep.last_name, 'Borrello') self.assertEqual(testrep.photo_url, '') self.assertEqual(testrep.email, '*****@*****.**') self.assertEqual(testrep.serving, True) self.assertEqual(testrep.party, 'Republican') # district info self.assertEqual(testrep.district.state, 'ny') self.assertEqual(testrep.district.district_num, '57') self.assertEqual(testrep.district.house, 'upper') # website info self.assertEqual(testrep.websites[0]['url'], "https://www.nysenate.gov/senators/george-m-borrello") # office info self.assertEqual(testrep.offices[0].location, 'Capitol Office') self.assertEqual(testrep.offices[0].phone, '518-455-3563') self.assertEqual(testrep.offices[0].address, '188 State Street, Legislative Office Building; Room 706; Albany, NY 12247') self.assertEqual(testrep.offices[1].location, 'District Office') self.assertEqual(testrep.offices[1].phone, '716-664-4603') self.assertEqual(testrep.offices[1].address, '2-6 E. Second Street; Fenton Building, Suite 302; Jamestown, NY 14701')
def setUp(self): """start with a clean slate""" db.drop_all() db.create_all() rep1 = Representative.add_rep(single_rep1) db.session.commit() rep1 = Representative.query.get(rep1.id) self.rep1 = rep1
def signup(): form = RegistrationForm() if form.validate_on_submit(): username = form.username.data password = form.password.data email = form.email.data first_name = form.first_name.data last_name = form.last_name.data address = form.address.data user = User.register( username=username, password=password, email=email, first_name=first_name, last_name=last_name, address=address, ) # latLng = Representative.find_latlng(address) # lat = latLng['lat'] # lng = latLng['lng'] reps = Representative.find_reps(address) for rep in reps: r = Representative.add_rep(rep) user.representatives.append(r) db.session.commit() login_user(user) flash("Signup successful") flash("Welcome") return redirect("/") if request.args: address = request.args["address"] form.address.data = address form.address.id = "search-input" form.address.type = "search" return render_template("signup.html", form=form, address=address) form.address.id = "search-input" form.address.type = "search" return render_template("signup.html", form=form)
def setUp(self): """ starts with a clean slate""" db.drop_all() db.create_all() user1 = User.register('user1', '11111', 'fname1', 'lname1', '*****@*****.**', 'test address') rep1 = Representative.add_rep(single_rep1) db.session.commit() user1 = User.query.get(user1.id) rep1 = Representative.query.get(rep1.id) self.user1 = user1 self.rep1 = rep1
def test_office_add(self): rep = Representative.add_rep(single_rep1) db.session.commit() o = Office.add_office(single_office) rep.offices.append(o) db.session.commit() testoffice = Office.query.get(1) # import pdb # pdb.set_trace() self.assertIsNotNone(testoffice) self.assertEqual(testoffice.phone, '716-664-4603') self.assertEqual( testoffice.address, '2-6 E. Second Street; Fenton Building, Suite 302; Jamestown, NY 14701' ) self.assertEqual(testoffice.location, 'District Office')