示例#1
0
    def test_check_history_table(self):
        with app.test_request_context():
            tester=app.test_client(self)
            db.drop_all()
            db.create_all()
            tester.post('/registration',data=dict(username='******', email='*****@*****.**', password='******', confirm_password='******'))
            tester.post('/home',data=dict(username="******",password='******'), follow_redirects=True)
            login_user(User.query.first())
            tester.post('/profile',data=dict(name="bob",address1='123456123456',address2="789456789456",city="Denver",state="CO",zipcode='80228'), follow_redirects=True)

            gallons = 975
            day = 1
            rates = []
            totals = []

            for quote in range(31):
                suggestRate, total = calculateRateAndTotal(gallons)
                rates.append(bytes(str(suggestRate),"ascii"))
                totals.append(bytes(str(total),"ascii"))
                tester.post('/quote',data=dict(gallonsRequested=str(gallons),deliveryDate='2020-07-'+str(day),deliveryAddress="123456123456 789456789456",rate=str(suggestRate),total=str(total),submit="True"), follow_redirects=True)
                gallons += 1
                day += 1

            response = tester.get('/history',content_type='html/text')

            for quote in range(31):
                self.assertIn(rates[quote],response.data)
                self.assertIn(totals[quote],response.data)
示例#2
0
 def test_rate_for_new_non_texans_with_more_than_1000_gallons(self):
     with app.test_request_context():
         tester=app.test_client(self)
         db.drop_all()
         db.create_all()
         tester.post('/registration',data=dict(username='******', email='*****@*****.**', password='******', confirm_password='******'))
         tester.post('/home',data=dict(username="******",password='******'), follow_redirects=True)
         login_user(User.query.first())
         tester.post('/profile',data=dict(name="bob",address1='123456123456',address2="789456789456",city="Denver",state="CO",zipcode='80228'), follow_redirects=True)
         suggestRate, total = calculateRateAndTotal(1234)
         self.assertEqual(suggestRate,Decimal('1.74'))
         self.assertEqual(total,Decimal('2147.16'))
示例#3
0
 def test_rate_for_old_non_texans_with_more_than_1000_gallons(self):
     with app.test_request_context():
         tester=app.test_client(self)
         db.drop_all()
         db.create_all()
         tester.post('/registration',data=dict(username='******', email='*****@*****.**', password='******', confirm_password='******'))
         tester.post('/home',data=dict(username="******",password='******'), follow_redirects=True)
         login_user(User.query.first())
         tester.post('/profile',data=dict(name="bob",address1='123456123456',address2="789456789456",city="Denver",state="CO",zipcode='80228'), follow_redirects=True)
         tester.post('/quote',data=dict(gallonsRequested="899",deliveryDate='2020-07-20',deliveryAddress="123456123456 789456789456",rate="1.73",total="1555.27",submit="True"), follow_redirects=True)
         suggestRate, total = calculateRateAndTotal(2255)
         self.assertEqual(suggestRate,Decimal('1.72'))
         self.assertEqual(total,Decimal('3878.6'))
示例#4
0
 def test_rate_for_old_texans_with_more_than_1000_gallons(self):
     with app.test_request_context():
         tester=app.test_client(self)
         db.drop_all()
         db.create_all()
         tester.post('/registration',data=dict(username='******', email='*****@*****.**', password='******', confirm_password='******'))
         tester.post('/home',data=dict(username="******",password='******'), follow_redirects=True)
         login_user(User.query.first())
         tester.post('/profile',data=dict(name="bob",address1='123456123456',address2="789456789456",city="Houston",state="TX",zipcode='77777'), follow_redirects=True)
         tester.post('/quote',data=dict(gallonsRequested="546",deliveryDate='2020-07-20',deliveryAddress="123456123456 Sample Drive",rate="2.00",total="1092",submit="True"), follow_redirects=True)
         suggestRate, total = calculateRateAndTotal(2002)
         self.assertEqual(suggestRate,Decimal('1.7'))
         self.assertEqual(total,Decimal('3403.4'))