def test_fail_register(self): r = YayClient.register(self.opts, ' ', '*****@*****.**', 'a', 'a') j = simplejson.loads(r.content) self.assertEqual(r.status_code, 401) r = YayClient.register(self.opts, 'my\'name', '*****@*****.**', 'a', 'a') j = simplejson.loads(r.content) self.assertEqual(r.status_code, 401)
def test_fail_register(self): r = YayClient.register(self.opts, ' ', '*****@*****.**', 'a', 'a') self.assertFalse(YayClient.is_logged_in(self.opts, r.cookies)) r = YayClient.register(self.opts, 'my\'name', '*****@*****.**', 'a', 'a') self.assertFalse(YayClient.is_logged_in(self.opts, r.cookies)) r = YayClient.register(self.opts, 'a b', '*****@*****.**', 'a', 'a') self.assertFalse(YayClient.is_logged_in(self.opts, r.cookies)) r = YayClient.register(self.opts, 'a_b', '*****@*****.**', 'a', 'a') self.assertFalse(YayClient.is_logged_in(self.opts, r.cookies)) r = YayClient.register(self.opts, 'a-b', '*****@*****.**', 'a', 'a') self.assertFalse(YayClient.is_logged_in(self.opts, r.cookies))
def setUpClass(cls): cls.opts = dict( url = 'http://yayhooray.dev/' ) user = YayClient.register(cls.opts, 'yay2tester', '*****@*****.**', 'a', 'a') thread = YayClient.post_thread(cls.opts, user.cookies, 2, "Test", "Test") cls.cookies = user.cookies cls.thread = urlparse(thread.url).path[1:]
def setUpClass(cls): cfg = SafeConfigParser() cfg.read(['../yay.ini', 'tests/yay.ini']) cls.opts = dict( url = cfg.get('site', 'url') ) DbClient.reset_database(cfg.get('db', 'host'), cfg.get('db', 'database'), cfg.get('db', 'username'), cfg.get('db', 'password')) user = YayClient.register(cls.opts, 'yay2tester', '*****@*****.**', 'a', 'a') thread = YayClient.post_thread(cls.opts, user.cookies, 2, "Test", "Test") cls.cookies = user.cookies cls.thread = urlparse(thread.url).path[1:]
def test_yay_register(self): # register existing yay username r = YayClient.register(self.opts, 'dh', '*****@*****.**', 'a', 'a') j = simplejson.loads(r.content) self.assertEqual(j['method'], 'yaypm') self.assertEqual(r.status_code, 201) self.assertFalse(YayClient.is_logged_in(self.opts, r.cookies)) # attempt to login, should fail because not activated failed_login = YayClient.login(self.opts, 'dh', 'a') self.assertEqual(failed_login.status_code, 401) self.assertFalse(YayClient.is_logged_in(self.opts, failed_login.cookies)) # perform activation activate_url = OldYayClient.read_last_pm_link('yayname', 'yaypass') activate = requests.get(activate_url) self.assertEqual(activate.status_code, 200) # Yay, should now be able to login login = YayClient.login(self.opts, 'dh', 'a') self.assertEqual(login.status_code, 200) self.assertTrue(YayClient.is_logged_in(self.opts, login.cookies))
def create_users(opts, num): return [ YayClient.register(opts, user['name'], user['email'], user['password'], user['password']) for user in users_generator(num) ]
def test_forgot_password(self): YayClient.register(self.opts, 'emailtest', '*****@*****.**', 'a', 'a') r = YayClient.forgot_password(self.opts, '*****@*****.**') j = simplejson.loads(r.content) self.assertTrue(j['ok']) self.assertEqual(r.status_code, 200)
def test_new_register(self): r = YayClient.register(self.opts, 'neudjcshfo', '*****@*****.**', 'a', 'a') j = simplejson.loads(r.content) self.assertEqual(j['method'], 'plain') self.assertEqual(r.status_code, 201) self.assertTrue(YayClient.is_logged_in(self.opts, r.cookies))
def test_new_register(self): r = YayClient.register(self.opts, 'neudjcshfo', '*****@*****.**', 'a', 'a') self.assertTrue(YayClient.is_logged_in(self.opts, r.cookies)) r = YayClient.register(self.opts, 'a b', '*****@*****.**', 'a', 'a') self.assertTrue(YayClient.is_logged_in(self.opts, r.cookies))