Exemplo n.º 1
0
    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
Exemplo n.º 2
0
    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
Exemplo n.º 3
0
    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
Exemplo n.º 4
0
    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
Exemplo n.º 5
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
Exemplo n.º 6
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
Exemplo n.º 7
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
Exemplo n.º 8
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]
Exemplo n.º 9
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]
Exemplo n.º 10
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()
Exemplo n.º 11
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()
Exemplo n.º 12
0
    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
Exemplo n.º 13
0
    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],)
Exemplo n.º 14
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
Exemplo n.º 15
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
Exemplo n.º 16
0
    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
Exemplo n.º 17
0
 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()
Exemplo n.º 18
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)]
Exemplo n.º 19
0
    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
Exemplo n.º 20
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) ]
Exemplo n.º 21
0
 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()
Exemplo n.º 22
0
    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
Exemplo n.º 23
0
    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
Exemplo n.º 24
0
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
Exemplo n.º 25
0
 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()
Exemplo n.º 26
0
 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()
Exemplo n.º 27
0
 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
Exemplo n.º 28
0
    def tearDown(self):
        u = meeplib.get_all_users()[0]
        meeplib.delete_user(u)

        assert len(meeplib._users) == 0
        assert len(meeplib._user_ids) == 0
Exemplo n.º 29
0
    def tearDown(self):
        u = meeplib.get_all_users()[0]
        meeplib.delete_user(u)

        assert len(meeplib._users) == 0
        assert len(meeplib._user_ids) == 0
Exemplo n.º 30
0
 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