Example #1
0
    def test_join_dojo_2_with_a_simple_post(self):
        ParticipantApiHandler.get_current_user().AndReturn(self.logged_user)
        ParticipantApiHandler.get_current_user().AndReturn(self.logged_user)
        self.mox.ReplayAll()
        expected = dict(
            dojo_id = 2
        )

        body = urlencode(expected)
        headers = {'Accept': 'application/x-www-form-urlencoded'}

        db = database.Connection("localhost", "dojo_to")
        join = db.get("SELECT * FROM participants WHERE user_id=1 AND dojo_id=2")
        self.assertIsNone(join)

        response = self.fetch('/dojo/2/join', method='POST', body=body,
            follow_redirects=False, headers=headers
        )
        self.assertEquals(302, response.code)
        participants = db.execute_rowcount("SELECT * FROM participants")
        self.assertEquals(4, participants)
        join = db.get("SELECT * FROM participants WHERE user_id=1 AND dojo_id=2")
        self.assertIsNotNone(join)
        self.assertEquals(1, join.user_id)
        self.assertEquals(2, join.dojo_id)
        self.assertFalse(join.confirmed) #TODO

        db.close()
        self.mox.VerifyAll()
Example #2
0
    def test_join_dojo_2_witch_i_m_already_in(self):
        ParticipantApiHandler.get_current_user().AndReturn(self.logged_user)
        ParticipantApiHandler.get_current_user().AndReturn(self.logged_user)
        self.mox.ReplayAll()

        db = database.Connection("localhost", "dojo_to")

        #query = "INSERT INTO participants (user_id, dojo_id) VALUES (1,2)"
        #db.query(query)

        expected = dict(
            dojo_id = 2
        )

        body = urlencode(expected)
        headers = {'Accept': 'application/x-www-form-urlencoded'}

        #TODO
        #response = self.fetch('/dojo/2/join', method='POST', body=body,
        #    follow_redirects=False, headers=headers
        #)
        #self.assertEquals(302, response.code)
        db.close()