Ejemplo n.º 1
0
class TestUserJoinChallenge(WebTest):
    def setUp(self):
        self.user = UserFactory()
        self.first_challenge = ChallengeFactory()
        self.second_challenge = ChallengeFactory()

    def tearDown(self):
        self.first_challenge.delete()
        self.second_challenge.delete()
        self.user.delete()
        self.first_challenge = None
        self.second_challenge = None
        self.user = None

    def test_join_possibility(self):
        page = self.app.get('/challenge/view/%s' % self.first_challenge.slug)
        expect = "/challenge/join/%s" % self.first_challenge.slug
        assert expect in page.text

    def test_join_unregistered(self):
        before = self.first_challenge.users.count()
        page = self.app.get('/challenge/join/%s' % self.first_challenge.slug)
        self.assertEqual(302, page.status_code)
        self.assertEqual(before, self.first_challenge.users.count())

    def test_join_registered(self):
        before = self.first_challenge.users.count()
        page = self.app.get(
            '/challenge/join/%s' % self.first_challenge.slug, user=self.user)
        self.assertEqual(302, page.status_code)
        self.assertEqual(before + 1, self.first_challenge.users.count())
Ejemplo n.º 2
0
class TestChallengeDetails(WebTest):

    def setUp(self):
        self.challenge = ChallengeFactory()
        self.resp = self.app.get('/challenge/view/%s' % self.challenge.slug)

    def tearDown(self):
        self.challenge.delete()
        self.challenge = None
        self.resp = None

    def test_response(self):
        self.assertEqual(200, self.resp.status_code)
Ejemplo n.º 3
0
class TestCreateActivity(WebTest):
    def setUp(self):
        self.challenge = ChallengeFactory()
        self.user = UserFactory()
        self.activity = ActivityFactory.build()

    def tearDown(self):
        self.activity = None
        self.challenge.delete()
        self.challenge = None
        self.user.delete()
        self.user = None

    def test_createActivity(self):
        before = self.challenge.activity_set.count()
        form = self.app.get('/challenge/appendactivity/%s' % self.challenge.slug, user=self.user).form
        form['title'] = self.activity.title
        form['description'] = self.activity.description
        form['reward'] = self.activity.reward
        form['reward_cost'] = self.activity.reward_cost
        form['reward_cost_type'] = self.activity.reward_cost_type
        res = form.submit(user=self.user).follow()
        self.assertEqual(200, res.status_code)
        self.assertEqual(before + 1, self.challenge.activity_set.count())
Ejemplo n.º 4
0
 def setUp(self):
     self.challenge = ChallengeFactory()
     self.resp = self.app.get('/challenge/view/%s' % self.challenge.slug)
Ejemplo n.º 5
0
 def setUp(self):
     self.user = UserFactory()
     self.first_challenge = ChallengeFactory()
     self.second_challenge = ChallengeFactory()
Ejemplo n.º 6
0
 def setUp(self):
     self.challenge = ChallengeFactory()
     self.user = UserFactory()
     self.activity = ActivityFactory.build()