コード例 #1
0
    def test_district_add(self):
        District.add_district('ny', '01', 'lower')

        db.session.commit()

        testdistrict = District.query.get(1)
        self.assertIsNotNone(testdistrict)
        self.assertEqual(testdistrict.state, "ny")
        self.assertEqual(testdistrict.district_num, "01")
        self.assertEqual(testdistrict.house, "lower")
コード例 #2
0
    def test_check_district(self):
        District.add_district('ny', '01', 'lower')

        db.session.commit()

        testdistrict = District.query.get(1)
        checkeddistrict = District.check_district('ny', '01', 'lower')
        self.assertEqual(testdistrict.state, checkeddistrict.state)
        self.assertEqual(testdistrict.district_num,
                         checkeddistrict.district_num)
        self.assertEqual(testdistrict.house, checkeddistrict.house)
コード例 #3
0
 def test_district_add_house_error(self):
     with self.assertRaises(exc.IntegrityError):
         District.add_district('ny', '01', None)
コード例 #4
0
 def test_district_add_dist_num_error(self):
     # This shouldn't work
     # with self.assertRaises(TypeError):
     #     District.add_district('ny', 1, 'lower')
     with self.assertRaises(exc.IntegrityError):
         District.add_district('ny', None, 'lower')
コード例 #5
0
 def test_district_add_state_error(self):
     with self.assertRaises(exc.IntegrityError):
         District.add_district(None, '01', 'lower')