Ejemplo n.º 1
0
 def test_reset(self):
     #there should be 1 user and 1 message initially
     assert meeplib._get_next_message_id() == 1
     assert meeplib._get_next_user_id() == 1
     meeplib._reset()
     assert meeplib._get_next_message_id() == 0
     assert meeplib._get_next_user_id() == 0
Ejemplo n.º 2
0
 def test_reset(self):
     #there should be 1 user and 1 message initially
     assert meeplib._get_next_message_id() == 1
     assert meeplib._get_next_user_id() == 1
     meeplib._reset()
     assert meeplib._get_next_message_id() == 0
     assert meeplib._get_next_user_id() == 0
Ejemplo n.º 3
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()
Ejemplo n.º 4
0
 def tearDown(self):
     cur.execute("DELETE FROM MESSAGE")
     cur.execute("DELETE FROM USER")
     meeplib._reset()
     con.commit()
     assert len(meeplib._messages) == 0
     assert len(meeplib._users) == 0
     assert len(meeplib._user_ids) == 0
Ejemplo n.º 5
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()
Ejemplo n.º 6
0
 def tearDown(self):
     cur.execute("DELETE FROM MESSAGE")
     cur.execute("DELETE FROM USER")
     meeplib._reset()
     con.commit() 
     assert len(meeplib._messages) == 0
     assert len(meeplib._users) == 0
     assert len(meeplib._user_ids) == 0
Ejemplo n.º 7
0
 def test_for_message_existence(self):
     print "test for message existence"
     messages = meeplib.get_all_messages()
     for m in messages:
         print m.post
     print len(messages)
     assert len(messages) == 1
     assert messages[0].title == 'the title'
     assert messages[0].post == 'the content'
     meeplib._reset()
Ejemplo n.º 8
0
 def test_for_message_existence(self):
     print "test for message existence"
     messages = meeplib.get_all_messages()
     for m in messages:
         print m.post
     print len(messages)
     assert len(messages) == 1
     assert messages[0].title == "the title"
     assert messages[0].post == "the content"
     meeplib._reset()
Ejemplo n.º 9
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()
Ejemplo n.º 10
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()
Ejemplo n.º 11
0
    def tearDown(self):
##        if len(meeplib.get_all_messages()) > 0:
##            m = meeplib.get_all_messages()[0]
##            meeplib.delete_message(m)
##
##        u = meeplib.get_all_users()[0]
##        meeplib.delete_user(u)
        meeplib._reset()

        assert len(meeplib._messages) == 0
        assert len(meeplib._users) == 0
        assert len(meeplib._user_ids) == 0
Ejemplo n.º 12
0
    def setUp(self):
        #the backup data causes some of the tests to fail - not sure why
        #remove the backup data before every test
        cur.execute("DELETE FROM MESSAGE")
        cur.execute("DELETE FROM SESSION")
        cur.execute("DELETE FROM USER")
        meeplib._reset()
        con.commit()

        u = meeplib.User('foo', 'bar')
        u.insertIntoDB()
        m = meeplib.Message('the title', 'the content', u.id, -1)
        m.insertIntoDB()
Ejemplo n.º 13
0
 def setUp(self):
     #the backup data causes some of the tests to fail - not sure why
     #remove the backup data before every test
     cur.execute("DELETE FROM MESSAGE")
     cur.execute("DELETE FROM SESSION")
     cur.execute("DELETE FROM USER")
     meeplib._reset()
     con.commit()  
         
     u = meeplib.User('foo', 'bar')
     u.insertIntoDB()
     m = meeplib.Message('the title', 'the content', u.id, -1)
     m.insertIntoDB()
Ejemplo n.º 14
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()
Ejemplo n.º 15
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()
Ejemplo n.º 16
0
    def test_backup_and_load_meep(self):
        #create a user, and message, then backup, reset data in app
        meeplib.User('admin', 'admin')
        author = meeplib.get_user('admin')
        author.insertIntoDB()
        message = meeplib.Message('title', 'message', author.id, -1)
        message.insertIntoDB()

        meeplib._reset()

        #check that the file exists and contains information about the message and user
        try:
            meeplib._load_backup()
            assert author in meeplib._users.values()
            assert message in meeplib._messages.values()
        except:
            assert False  #the test failed
Ejemplo n.º 17
0
    def list_messages(self, environ, start_response):
        user = meeplib.get_curr_user();
        meeplib._reset()
        meeplib.set_curr_user(user)
        conn = sqlite3.connect('meep.db')
        c = conn.cursor()
        for row in c.execute("SELECT * FROM Message"):
            print row
            meeplib.Message(row[0], row[1], row[2], row[3])
        

        messages = meeplib.get_all_messages()
           
        headers = [('Content-type', 'text/html')]
        start_response("200 OK", headers)
        
        return [render_page('list_messages.html', messages=messages)]
Ejemplo n.º 18
0
 def test_backup_and_load_meep(self):        
     #create a user, and message, then backup, reset data in app
     meeplib.User('admin', 'admin')
     author = meeplib.get_user('admin')
     author.insertIntoDB()
     message = meeplib.Message('title', 'message', author.id, -1)
     message.insertIntoDB()
     
     
     meeplib._reset()
     
     #check that the file exists and contains information about the message and user
     try:
         meeplib._load_backup()
         assert author in meeplib._users.values()
         assert message in meeplib._messages.values()
     except:
         assert False    #the test failed
Ejemplo n.º 19
0
 def test_create_user(self):
     run_twill_tests('01test_create_user.twill')
     meeplib._reset()
Ejemplo n.º 20
0
 def setUp(self):
     meeplib._reset()
     u = meeplib.User("foo", "bar")
     t = meeplib.Thread("the title")
     m = meeplib.Message("the content", u)
     t.add_post(m)
Ejemplo n.º 21
0
 def setUp(self):
     meeplib._reset()
     u = meeplib.User('foo', 'bar')
     t = meeplib.Thread('the title')
     m = meeplib.Message('the content', u)
     t.add_post(m)
Ejemplo n.º 22
0
 def test_get_next_user(self):
     id = meeplib._get_next_user_id()
     assert id != None
     meeplib._reset()
Ejemplo n.º 23
0
    def tearDown(self):
        meeplib._reset()

        assert len(meeplib._threads) == 0
        assert len(meeplib._users) == 0
        assert len(meeplib._user_ids) == 0
Ejemplo n.º 24
0
 def setUp(self):
     meep_example_app.initialize()
     app = meep_example_app.MeepExampleApp()
     self.app = app
     meeplib._reset()
Ejemplo n.º 25
0
 def setUp(self):
     meeplib._reset()
     u = meeplib.User('foo', 'bar')
     m = meeplib.Message('the title', 'the content', u, -1)
Ejemplo n.º 26
0
 def setUp(self):
     meep_example_app.initialize()
     app = meep_example_app.MeepExampleApp()
     self.app = app
     meeplib._reset()
Ejemplo n.º 27
0
 def setUp(self):
     meeplib._reset()
     u = meeplib.User('foo', 'bar')
     m = meeplib.Message('the title', 'the content', u, -1)
Ejemplo n.º 28
0
def run_twill_tests(filename):
    fp = open(filename)
    twill.execute_string(fp.read(), initial_url='http://localhost:8000/')
    meeplib._reset()
Ejemplo n.º 29
0
 def test_create_user(self):
     run_twill_tests('01test_create_user.twill')
     meeplib._reset()
Ejemplo n.º 30
0
    def tearDown(self):
        meeplib._reset()

        assert len(meeplib._messages) == 0
        assert len(meeplib._users) == 0
        assert len(meeplib._user_ids) == 0
Ejemplo n.º 31
0
def run_twill_tests(filename):
    fp = open(filename)
    twill.execute_string(fp.read(), initial_url='http://localhost:8000/')
    meeplib._reset()
Ejemplo n.º 32
0
    def tearDown(self):
        meeplib._reset()

        assert len(meeplib._threads) == 0
        assert len(meeplib._users) == 0
        assert len(meeplib._user_ids) == 0
Ejemplo n.º 33
0
 def test_get_next_user(self):
     id = meeplib._get_next_user_id()
     assert id != None
     meeplib._reset()