コード例 #1
0
ファイル: test_challenge.py プロジェクト: sarutobi/children
class TestCreateChallenge(WebTest):
    extra_environ = {
        'HTTP_ACCEPT_LANGUAGE': 'ru',
    }

    def setUp(self):
        self.user = UserFactory()
        activate('ru')

    def tearDown(self):
        self.user.delete()
        deactivate()

    def test_without_logo(self):
        before = Challenge.objects.count()
        form = self.app.get('/challenge/create', user=self.user.email).form
        form['title'] = 'Test challenge'
        form['summary'] = 'This is example challenge'
        form['description'] = 'Example challenge that must be deleted'
        form['cause'] = 0
        form['slug'] = 'test_challenge'
        form['start_at'] = '1.9.2012'
        form['end_at'] = '31.5.2013'
        resp = form.submit(user=self.user.email)
        self.assertEqual(302, resp.status_code)
        self.assertEqual(Challenge.objects.count(), before + 1)
コード例 #2
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())
コード例 #3
0
ファイル: test_users_security.py プロジェクト: sarutobi/ChAos
class test_login(WebTest):
    def setUp(self):
        self.user = UserFactory()

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

    def test_login(self):
        form = self.app.get('/accounts/login/').form
        form['username'] = self.user.email
        form['password'] = '******'
        res = form.submit().follow()
        self.assertEqual(200, res.status_code)
コード例 #4
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())
コード例 #5
0
ファイル: test_users_security.py プロジェクト: sarutobi/ChAos
 def setUp(self):
     self.new_user = UserFactory.build()
コード例 #6
0
ファイル: test_users_security.py プロジェクト: sarutobi/ChAos
 def setUp(self):
     self.user = UserFactory()
コード例 #7
0
ファイル: test_challenge.py プロジェクト: sarutobi/children
 def setUp(self):
     self.user = UserFactory()
     activate('ru')
コード例 #8
0
ファイル: test_challenge.py プロジェクト: sarutobi/ChAos
 def setUp(self):
     self.user = UserFactory()
     self.first_challenge = ChallengeFactory()
     self.second_challenge = ChallengeFactory()
コード例 #9
0
ファイル: test_activity.py プロジェクト: sarutobi/ChAos
 def setUp(self):
     self.challenge = ChallengeFactory()
     self.user = UserFactory()
     self.activity = ActivityFactory.build()