Ejemplo n.º 1
0
def FakeUsers(cap=None):
    uid = 0
    now = datetime.datetime.today()
    for age_offset in (0, -10, -5, 5, 10):
        for long_offset in (0, -5, 5):
            for lat_offset in (0, -5, 5):
                for sexuality in (0, 1, 2, 3):
                    for gender in (0, 1, 2):
                        uid += 1
                        if cap and uid > cap:
                            break
                        name = "User_{uid}".format(uid=uid)
                        latitude = DEFAULT_LATITUDE + lat_offset
                        longitude = DEFAULT_LONGITUDE + long_offset
                        age = DEFAULT_AGE + age_offset
                        ams, afs, aos = SEX_MATH[(gender, sexuality)]

                        # Create the user
                        interface.CreateAccount(name, latitude, longitude)
                        interface.UpdateAccount(
                            uid,
                            gender_string="genderqueer"
                            if gender == 2 else None,
                            sexuality_string="queer"
                            if sexuality == 3 else None,
                            gender=gender,
                            sexuality=sexuality,
                            birthday=now - datetime.timedelta(days=age * 365),
                            radius=DEFAULT_RADIUS,
                            min_age=int((age / 2) + 7),
                            max_age=int(2 * (age - 7)),
                            accept_male_sexualities=ams,
                            accept_female_sexualities=afs,
                            accept_other_sexualities=aos)
Ejemplo n.º 2
0
 def testUpdateAccount(self):
     user, _, _ = interface.CreateAccount("Foo", 0, 0,
                                          datetime.datetime.today())
     uid = user.key.id()
     with self.assertRaises(ValueError):
         interface.UpdateAccount(uid, joined=datetime.datetime.today())
     with self.assertRaises(ValueError):
         interface.UpdateAccount(uid,
                                 last_activity=datetime.datetime.today())
     with self.assertRaises(ValueError):
         interface.UpdateAccount(uid, latitud=10)
     with self.assertRaises(ValueError):
         interface.UpdateAccount(uid, longitude=10)
     with self.assertRaises(ValueError):
         interface.UpdateAccount(uid, foobarbaz=123)
     user, match, search = interface.UpdateAccount(
         uid, gender_string="genderqueer", gender=2, radius=100)
     self.assertEqual(user.gender_string, "genderqueer")
     self.assertEqual(match.gender, 2)
     self.assertEqual(search.radius, 100)
     user2, match2, search2 = interface.LoadAccount(uid)
     self.assertEqual(user2.gender_string, "genderqueer")
     self.assertEqual(match2.gender, 2)
     self.assertEqual(search2.radius, 100)
Ejemplo n.º 3
0
 def Handle(self):
     interface.UpdateAccount(self.GetEnv("uid"), active=True)
Ejemplo n.º 4
0
 def Handle(self):
     interface.UpdateAccount(self.GetEnv("uid"), **self.args)