def test_insert_device(self):
        mytest = RateItUser()
        result = mytest.put()
        self.assertEqual(None, ndb.get(result).user_device)

        mytest1 = RateItUser(user_device='iPhone')
        result1 = mytest1.put()
        self.assertEqual('iPhone', ndb.get(result1).user_device)
 def test_empty_input(self):
     mytest = RateItUser()
     result = mytest.put()
     self.assertEqual(None, ndb.get(result).user)
     self.assertEqual(None, ndb.get(result).user_type)
     self.assertEqual(None, ndb.get(result).user_sex)
     self.assertEqual(None, ndb.get(result).user_born_year)
     self.assertEqual(None, ndb.get(result).user_household_type)
     self.assertEqual(None, ndb.get(result).user_postcode)
     self.assertEqual(None, ndb.get(result).user_education)
     self.assertEqual(None, ndb.get(result).user_occupation)
     self.assertEqual(None, ndb.get(result).user_monthly_income)
     self.assertEqual(None, ndb.get(result).user_mobility_impairment)
     self.assertEqual(None, ndb.get(result).user_device)
     self.assertEqual(None, ndb.get(result).user_driver_licence)
     self.assertEqual(None, ndb.get(result).user_often_use)
     self.assertEqual(None, ndb.get(result).user_purpose_use)
 def test_insert_user_sex(self):
     mytest = RateItUser(user_sex='Male')
     result = mytest.put()
     self.assertEqual('male', ndb.get(result).user_sex)
     mytest1 = RateItUser(user_sex = 'female')
     result1 = mytest1.put()
     self.assertEqual('female', ndb.get(result1).user_sex)
     # entered text neither 'male'('Male') or 'female'('Female')
     mytest2 = RateItUser(user_sex='other')
     result2 = mytest2.put()
     self.assertEqual(None, ndb.get(result2).user_sex)
Exemplo n.º 4
0
 def get(self):
     self.setup_jinja()
     self.response.out.write(main.logging_link())
     self.response.out.write(main.get_pre_page())
 #     print out registered user info
     find_user = RateItUser.query(RateItUser.user==users.get_current_user())
     for item in find_user:
         self.response.out.write(item.user.email())
         self.response.out.write(item.user_type)
         self.response.out.write(item.user_sex)
         self.response.out.write(item.user_born_year)
         self.response.out.write(item.user_household_type)
         self.response.out.write(item.user_postcode)
         self.response.out.write(item.user_education)
         self.response.out.write(item.user_occupation)
         self.response.out.write(item.user_monthly_income)
         self.response.out.write(item.user_mobility_impairment)
         self.response.out.write(item.user_device)
         self.response.out.write(item.user_driver_licence)
         self.response.out.write(item.user_often_use)
         self.response.out.write(item.user_purpose_use)
         self.response.out.write(item.time_registered)
 def test_insert_user_household_type(self):
     mytest = RateItUser(user_household_type='household')
     result = mytest.put()
     self.assertEqual('household', ndb.get(result).user_household_type)
 def test_insert_born_year(self):
     mytest = RateItUser(user_born_year='1990')
     result = mytest.put()
     self.assertEqual('1990', ndb.get(result).user_born_year)
 def test_insert_user_type(self):
     mytest = RateItUser(user_type='passenger')
     result = mytest.put()
     self.assertEqual('passenger', ndb.get(result).user_type)
 def test_insert_user(self):
     mytest = RateItUser(user=users.get_current_user())
     result = mytest.put()
     self.assertEqual(users.get_current_user(), ndb.get(result).user)
 def test_insert_user_occupation(self):
     mytest = RateItUser(user_occupation='occupation')
     result = mytest.put()
     self.assertEqual('occupation', ndb.get(result).user_occupation)
 def test_insert_user_purpose_use(self):
     mytest = RateItUser(user_purpose_use='purpose use')
     result = mytest.put()
     self.assertEqual('purpose use', ndb.get(result).user_purpose_use)
 def test_insert_user_often_use(self):
     mytest = RateItUser(user_often_use='often use')
     result = mytest.put()
     self.assertEqual('often use', ndb.get(result).user_often_use)
 def test_insert_user_driver_licence(self):
     mytest = RateItUser(user_driver_licence='drivers licence')
     result = mytest.put()
     self.assertEqual('drivers licence', ndb.get(result).user_driver_licence)
 def test_insert_user_mobility_impairment(self):
     mytest = RateItUser(user_mobility_impairment='mobility impairment')
     result = mytest.put()
     self.assertEqual('mobility impairment', ndb.get(result).user_mobility_impairment)
 def test_insert_user_monthly_income(self):
     mytest = RateItUser(user_monthly_income='monthly income')
     result = mytest.put()
     self.assertEqual('monthly income', ndb.get(result).user_monthly_income)
 def testInsertEntity(self):
     RateItUser().put()
     self.assertEqual(1, len(RateItUser.all().fetch(2)))
Exemplo n.º 16
0
    def post(self):
        new_user = RateItUser()
        new_user.user = main.current_user()
        new_user.user_type = "passenger"
        new_user.user_sex = self.request.get('sex').lower()
        new_user.user_born_year = self.request.get('inputYear')
        new_user.user_household_type = self.request.get('householdType')
        new_user.user_postcode = self.request.get('postcode')
        new_user.user_education = self.request.get('education')
        new_user.user_occupation = self.request.get('occupation')
        new_user.user_monthly_income = self.request.get('monthly_income')
        new_user.user_mobility_impairment = self.request.get('mobility_impairment')
        new_user.user_often_use = self.request.get('often_to_use')
        new_user.user_device = self.request.get('devices_type')
        new_user.user_driver_licence = self.request.get('drivers_licence')
        new_user.user_purpose_use = self.request.get('purpose_to_use')
        new_user.time_registered = datetime.today()


        if not main.is_registered():
            new_user.put()

        self.setup_jinja()
        self.redirect(main.get_pre_page())
 def test_insert_user_postcode(self):
     mytest = RateItUser(user_postcode='2000')
     result = mytest.put()
     self.assertEqual('2000', ndb.get(result).user_postcode)