Exemplo n.º 1
0
    def test_for_message_existence(self):
        x = meeplib.get_all_threads()[0]
        y = x.get_all_posts()

        assert len(y) == 1
        assert x.title == 'the title'
        assert y[0].post == 'the content'
Exemplo n.º 2
0
    def test_for_message_existence(self):
        x = meeplib.get_all_threads()[0]
        y = x.get_all_posts()

        assert len(y) == 1
        assert x.title == "the title"
        assert y[0].post == "the content"
Exemplo n.º 3
0
    def test_for_message_existence(self):
        x = meeplib.get_all_threads()[0]
        y = x.get_all_posts()

        print "message: %s" %(x.title,)
        assert len(y) >= 1
        assert x.title == 'Test Thread'
        assert y[0].post == 'This is my message!'
Exemplo n.º 4
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.º 5
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.º 6
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.º 7
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.º 8
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.º 9
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.º 10
0
	def list_messages(self, environ, start_response):
		print "enter list messages"
		messages = meeplib.get_all_threads()
		username = check_cookie(environ)
		user = meeplib.get_user(username)
		s = []
		if messages:
			s.append(render_page("list_messages.html", messages=messages, user=user))
		else:
			s.append("no threads exist<p>")
		headers = [('Content-type', 'text/html')]
		start_response("200 OK", headers)
		print "exit list messages"
		return ["".join(s)]
Exemplo n.º 11
0
	def delete_all_messages_action(self, environ, start_response):
		print "enter delete all messages action"
		form = cgi.FieldStorage(fp=environ['wsgi.input'], environ=environ)
		username = check_cookie(environ)
		threads = meeplib.get_all_threads()
		for t in threads:
			meeplib.delete_thread(t)

		headers = [('Content-type', 'text/html')]
		headers.append(('Location', '/m/list'))
		start_response("302 Found", headers)
	
		meeplib.save_state()
		print "exit delete all messages action"
		return ["all threads deleted"]
Exemplo n.º 12
0
    def delete_all_messages_action(self, environ, start_response):
        print "enter delete all messages action"
        form = cgi.FieldStorage(fp=environ['wsgi.input'], environ=environ)
        username = check_cookie(environ)
        threads = meeplib.get_all_threads()
        for t in threads:
            meeplib.delete_thread(t)

        headers = [('Content-type', 'text/html')]
        headers.append(('Location', '/m/list'))
        start_response("302 Found", headers)

        meeplib.save_state()
        print "exit delete all messages action"
        return ["all threads deleted"]
Exemplo n.º 13
0
 def list_messages(self, environ, start_response):
     print "enter list messages"
     messages = meeplib.get_all_threads()
     username = check_cookie(environ)
     user = meeplib.get_user(username)
     s = []
     if messages:
         s.append(
             render_page("list_messages.html", messages=messages,
                         user=user))
     else:
         s.append("no threads exist<p>")
     headers = [('Content-type', 'text/html')]
     start_response("200 OK", headers)
     print "exit list messages"
     return ["".join(s)]
Exemplo n.º 14
0
    def list_messages(self, environ, start_response):
        threads = meeplib.get_all_threads()
        # get cookie if there is one
        try:
            cookie = Cookie.SimpleCookie(environ["HTTP_COOKIE"])
            username = cookie["username"].value
            #print "Username = %s" % username
        except:
            #print "session cookie not set! defaulting username"
            username = ''
        
        user = meeplib.get_user(username)
        s = []

        headers = [('Content-type', 'text/html')]
        start_response("200 OK", headers)

        return render_page("list_threads.html", threads=threads, user=user)
Exemplo n.º 15
0
    def list_messages(self, environ, start_response):
        messages = meeplib.get_all_threads()

        s = []
        if messages:
            for t in messages:
                flag = 0
                for m in t.get_all_posts():
                    s.append("<hr>")
                    if flag == 0:
                        s.append("<h2>%s</h2>" % (t.title))
                        flag = 1
                    s.append("<p>%s</p>" % (m.post))
                    s.append("<p>Posted by: %s</p>" % (m.author.username))
                    # append the delete message link
                    s.append(
                        """
                    <form action='delete_action' method='POST'>
                    <input name='thread_id' type='hidden' value='%d' />
                    <input name='post_id' type='hidden' value='%d' />
                    <input name='delete' type='submit' value='Delete Message' />
                    </form>
                    """
                        % (t.id, m.id)
                    )
                s.append(
                    """
                <form action='reply' method='POST'>
                <input name='thread_id' type='hidden' value='%d' />
                <input name='reply' type='submit' value='Reply to' />
                </form>
                """
                    % (t.id)
                )
        else:
            s.append("There are no messages to display.<p>")

        s.append("<hr>")
        s.append("<a href='../../'>Back to the Home Page</a>")

        headers = [("Content-type", "text/html")]
        start_response("200 OK", headers)

        return ["".join(s)]
Exemplo n.º 16
0
    def list_messages(self, environ, start_response):
        threads = meeplib.get_all_threads()
        
        # get cookie
        try:
            cookie = Cookie.SimpleCookie(environ["HTTP_COOKIE"])
            username = cookie["username"].value
        except:
            username = ''
        
        user = meeplib.get_user(username)
        s = []
		
        if threads:
            s.append(render_page("list_messages.html", threads=threads, user=user))
        else:
            s.append("There are no threads to display.<p>")

        headers = [('Content-type', 'text/html')]
        start_response("200 OK", headers)

        return ["".join(s)]
Exemplo n.º 17
0
    def list_messages(self, environ, start_response):
        messages = meeplib.get_all_threads()

        s = []
        if messages:
            for t in messages:
                flag = 0
                for m in t.get_all_posts():
                    s.append('<hr>')
                    if flag == 0:
                        s.append('<h2>%s</h2>' % (t.title))
                        flag = 1
                    s.append('<p>%s</p>' % (m.post))
                    s.append('<p>Posted by: %s</p>' % (m.author.username))
                    # append the delete message link
                    s.append("""
                    <form action='delete_action' method='POST'>
                    <input name='thread_id' type='hidden' value='%d' />
                    <input name='post_id' type='hidden' value='%d' />
                    <input name='delete' type='submit' value='Delete Message' />
                    </form>
                    """ % (t.id, m.id))
                s.append("""
                <form action='reply' method='POST'>
                <input name='thread_id' type='hidden' value='%d' />
                <input name='reply' type='submit' value='Reply to' />
                </form>
                """ % (t.id))
        else:
            s.append("There are no messages to display.<p>")

        s.append('<hr>')
        s.append("<a href='../../'>Back to the Home Page</a>")

        headers = [('Content-type', 'text/html')]
        start_response("200 OK", headers)

        return ["".join(s)]
Exemplo n.º 18
0
 def test_for_message_existence(self):
     x = meeplib.get_all_threads()
     e = x[0].get_all_posts()
     assert len(e) == 1
     assert x[0].title == 'What a great title!'
     assert e[0].post == 'not'