コード例 #1
0
ファイル: test_challenge.py プロジェクト: sarutobi/ChAos
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())
コード例 #2
0
ファイル: test_challenge.py プロジェクト: sarutobi/children
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)
コード例 #3
0
ファイル: test_activity.py プロジェクト: sarutobi/ChAos
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())
コード例 #4
0
ファイル: test_challenge.py プロジェクト: sarutobi/children
 def setUp(self):
     self.challenge = ChallengeFactory()
     self.resp = self.app.get('/challenge/view/%s' % self.challenge.slug)
コード例 #5
0
ファイル: test_challenge.py プロジェクト: sarutobi/ChAos
 def setUp(self):
     self.user = UserFactory()
     self.first_challenge = ChallengeFactory()
     self.second_challenge = ChallengeFactory()
コード例 #6
0
ファイル: test_activity.py プロジェクト: sarutobi/ChAos
 def setUp(self):
     self.challenge = ChallengeFactory()
     self.user = UserFactory()
     self.activity = ActivityFactory.build()