def tearDown(self): m = meeplib.get_message(self.msgId) if m != None: meeplib.delete_message(m) l = len(meeplib.get_all_users()) meeplib.delete_user(meeplib.get_user(self.ux)) lafter = len(meeplib.get_all_users()) assert l > lafter
def test_delete_user(self): #check that there is 1 user assert len(meeplib.get_all_users()) == 1 assert len(meeplib._user_ids) == 1 for msg in meeplib._messages.values(): meeplib.delete_message(msg) meeplib.delete_user(meeplib.get_user('foo')) #check that there are no users assert len(meeplib.get_all_users()) == 0 assert len(meeplib._user_ids) == 0
def tearDown(self): m = meeplib.get_all_messages()[0] meeplib.delete_message(m) u = meeplib.get_all_users()[0] v = meeplib.get_all_users()[1] meeplib.delete_user(u) meeplib.delete_user(v) assert len(meeplib._messages) == 0 assert len(meeplib._users) == 0 assert len(meeplib._user_ids) == 0
def tearDown(self): t = meeplib.get_all_threads()[0] m = t.get_all_posts()[0] t.delete_post(m) u = meeplib.get_all_users()[0] v = meeplib.get_all_users()[1] meeplib.delete_user(u) meeplib.delete_user(v) assert len(meeplib._threads) == 0 assert len(meeplib._users) == 0 assert len(meeplib._user_ids) == 0
def test_create_user_action(self): print "test create user action" g = meeplib.get_all_users() for u in g: print u.username environ = {} # make a fake dict environ['PATH_INFO'] = '/create_user' environ['wsgi.input'] = '' form_dict = {} form_dict['username'] = "******" form_dict['password'] = "******" environ['QUERY_STRING'] = urllib.urlencode(form_dict) def fake_start_response(status, headers): assert status == '302 Found' assert ('Content-type', 'text/html') in headers environ = {} # make a fake dict environ['PATH_INFO'] = '/' environ['wsgi.input'] = '' environ['HTTP_COOKIE'] = "username=bob" print "environ" print environ def fake_start_response(status, headers): assert status == '200 OK' assert ('Content-type', 'text/html') in headers data = self.app(environ, fake_start_response) print "data: %s" % (data[0], ) assert "test" in data[0]
def test_create_user_action(self): print "test create user action" g = meeplib.get_all_users() for u in g: print u.username environ = {} # make a fake dict environ["PATH_INFO"] = "/create_user" environ["wsgi.input"] = "" form_dict = {} form_dict["username"] = "******" form_dict["password"] = "******" environ["QUERY_STRING"] = urllib.urlencode(form_dict) def fake_start_response(status, headers): assert status == "302 Found" assert ("Content-type", "text/html") in headers environ = {} # make a fake dict environ["PATH_INFO"] = "/" environ["wsgi.input"] = "" environ["HTTP_COOKIE"] = "username=bob" print "environ" print environ def fake_start_response(status, headers): assert status == "200 OK" assert ("Content-type", "text/html") in headers data = self.app(environ, fake_start_response) print "data: %s" % (data[0],) assert "test" in data[0]
def testAddUser_newportt(self): print "test add user" meeplib.User("cait", "test") meeplib.User('new', 'test') for user in meeplib.get_all_users(): print user.username assert len(meeplib._users) == 3 meeplib._reset()
def testAddUser_newportt(self): print "test add user" meeplib.User("cait", "test") meeplib.User("new", "test") for user in meeplib.get_all_users(): print user.username assert len(meeplib._users) == 3 meeplib._reset()
def test_message_ownership(self): x = meeplib.get_all_users() assert len(x) == 1 u = x[0] x = meeplib.get_all_messages() assert len(x) == 1 m = x[0] assert m.author == u
def test_message_ownership(self): x = meeplib.get_all_users() assert len(x) == 1 u = x t = meeplib.get_all_threads()[0] x = t.get_all_posts() assert len(x) >= 1 m = x print "mauthor: %s" %(m[0],)
def test_message_ownership(self): x = meeplib.get_all_users() assert len(x) != 0 u = meeplib.get_user('foo') x = meeplib.get_all_messages() assert len(x) != 0 m = x[len(x) - 1] assert m.author == u
def test_message_ownership(self): x = meeplib.get_all_users() assert len(x) == 1 u = x[0] x = meeplib.get_all_messages() assert len(x) == 1 m = x[0] assert m.author == u.id
def test_message_ownership(self): users = meeplib.get_all_users() for u in users: print u.username assert len(users) == 1 # two hardcoded and one added above u = users[0] messages = meeplib.get_all_messages() assert len(messages) == 1 m = messages[0] assert m.author == u meeplib._reset()
def list_users(self, environ, start_response): users = meeplib.get_all_users() cookie = environ.get('HTTP_COOKIE', '') username = meepcookie.load_username(cookie) headers = [('Content-type', 'text/html')] start_response("200 OK", headers) return [render_page('list_users.html', users=users, username=username)]
def tearDown(self): m = meeplib.get_all_threads() z = m[0].get_all_posts('id') m[0].delete_post(z[0]) u = meeplib.get_all_users()[0] meeplib.delete_user(u) assert len(meeplib._messages) == 0 assert len(meeplib._users) == 0 assert len(meeplib._user_ids) == 0
def list_users(self, environ, start_response): users = meeplib.get_all_users() cookie = environ.get('HTTP_COOKIE', '') username = meepcookie.load_username(cookie) headers = [('Content-type', 'text/html')] start_response("200 OK", headers) return [ render_page('list_users.html', users=users, username=username) ]
def test_message_ownership(self): users = meeplib.get_all_users() for u in users: print u.username assert len(users) == 1 #two hardcoded and one added above u = users[0] messages = meeplib.get_all_messages() assert len(messages) == 1 m = messages[0] assert m.author == u meeplib._reset()
def test_message_ownership(self): x = meeplib.get_all_users() assert len(x) == 2 u = x[0] t = meeplib.get_all_threads()[0] x = t.get_all_posts() assert len(x) == 1 m = x[0] assert m.author == u
def test_message_ownership(self): x = meeplib.get_all_users() assert len(x) == 1 u = x[0] t = meeplib.get_all_threads()[0] x = t.get_all_posts() assert len(x) == 1 m = x[0] assert m.author == u
def SaveUsers(): # #Save Users # filename = 'users.pickle' fp = open(filename, 'w') u = meeplib.get_all_users() for d in u: f = [d.username, d.password] #print f pickle.dump(f, fp) fp.close() return
def test_tearDown(self): print "test teardown" users = meeplib.get_all_users() for user in users: meeplib.delete_user(user) print meeplib._user_ids messages = meeplib.get_all_messages() for m in messages: meeplib.delete_message(m) print len(meeplib._user_ids) assert len(meeplib._messages) == 0 assert len(meeplib._users) == 0 assert len(meeplib._user_ids) == 0 meeplib._reset()
def test_get_all_users(self): #create one more user, so there are 2 users in total user = meeplib.User('foo2', 'bar2') user.insertIntoDB() assert len(meeplib.get_all_users()) == 2
def tearDown(self): u = meeplib.get_all_users()[0] meeplib.delete_user(u) assert len(meeplib._users) == 0 assert len(meeplib._user_ids) == 0