Exemple #1
0
    def test_redirect_admin_fail(self):

        self.request.POST['submit_login'] = '******'
        self.request.POST['login'] = self.bad_user['login']
        self.request.POST['password'] = self.bad_user['password']
        res = index_view(self.request)

        self.request.POST['submit_admin'] = 'submitting'
        res = index_view(self.request)

        self.assertFalse(u'Panel administracyjny' in unicode(
            res.body, 'utf-8'))
Exemple #2
0
    def test_game_redirect_succ(self):
        from pyramid.httpexceptions import HTTPFound
        self.request.POST['submit_login'] = '******'
        self.request.POST['login'] = self.good_user['login']
        self.request.POST['password'] = '******'
        res = index_view(self.request)

        self.request.POST['submit_login'] = ''
        self.request.POST['submit_game'] = 'submitting'
        self.request.session['number_games'] = 15
        res = index_view(self.request)

        self.assertEqual(HTTPFound, type(res))
        self.assertEqual(res.location, self.request.route_path('game'))
Exemple #3
0
    def test_logout(self):
        self.request.POST['submit_login'] = '******'
        self.request.POST['login'] = self.good_user['login']
        self.request.POST['password'] = '******'

        res = index_view(self.request)
        self.request.POST['submit_login'] = ''
        self.request.POST['submit_logout'] = 'submitting'

        res = index_view(self.request)

        self.assertEqual(0, res.data['logged'])
        self.assertTrue('login_status' in res.data)
        self.assertEqual(u"Wylogowano", res.data['login_status'])
Exemple #4
0
    def test_redirect_admim_succ(self):
        from pyramid.httpexceptions import HTTPFound
        User(**self.good_user).save()
   
        self.request.POST['submit_login'] = '******'
        self.request.POST['login'] = self.good_user['login']
        self.request.POST['password'] = '******'
        res = index_view(self.request)

        self.request.POST['submit_login'] = ''
        self.request.POST['submit_admin'] = 'submitting'
        res = index_view(self.request)

        self.assertEqual(HTTPFound, type(res))
        self.assertEqual(res.location, self.request.route_path('admin'))
Exemple #5
0
    def test_when_login(self):
        self.request.POST['submit_login'] = '******'
        self.request.POST['login'] = self.good_user['login']
        self.request.POST['password'] = '******'

        res = index_view(self.request)
        self.assertTrue('submit_logout' in res.body)
Exemple #6
0
    def test_success(self):
        self.request.POST['submit_login'] = '******'
        self.request.POST['login'] = self.good_user['login']
        self.request.POST['password'] = '******'

        res = index_view(self.request)
        self.assertEqual(1, res.data['logged'])
Exemple #7
0
    def test_bad_data_3(self):
        self.request.POST['submit_login'] = '******'
        self.request.POST['login'] = self.bad_user['login']
        self.request.POST['password'] = self.bad_user['password']

        res = index_view(self.request)
        self.assertEqual(0, res.data['logged'])
Exemple #8
0
    def test_player_count(self):
        User(**self.good_user).save()

        res = index_view(self.request)
        self.assertTrue('players_count' in res.data)

        players = res.data['players_count']
        self.assertEqual(1, players)
Exemple #9
0
    def test_count_matches(self):
        Match().save()

        res = index_view(self.request)
        self.assertTrue('matches_count' in res.data)

        matches = res.data['matches_count']
        self.assertEqual(1, matches)
Exemple #10
0
    def test_bad_data_2(self):
        self.request.POST['submit_login'] = '******'
        self.request.POST['login'] = self.bad_user['login']
        self.request.POST['password'] = '******'

        res = index_view(self.request)
        self.assertTrue('login_status' in res.data)
        self.assertEqual(
            u"Nie ma takiego użytkownika", res.data['login_status'])
Exemple #11
0
    def test_index(self):
        User(name='s', surname='d', login='******', password='******').save()
        res = index_view(self.request)

        self.assertTrue('players' in res.data)
        players = res.data['players']
        self.assertEqual(1, len(players))
        self.assertEqual('s d', players[0]['name'])


        User(name='s2', surname='d2', login='******', password='******').save()

        res = index_view(self.request)

        self.assertTrue('players' in res.data)
        players = res.data['players']
        self.assertEqual(2, len(players))
        self.assertEqual('s d', players[0]['name'])
        self.assertEqual('s2 d2', players[1]['name'])
Exemple #12
0
 def test_no_inputed_data(self):
     self.request.POST['submit_login'] = '******'
     res = index_view(self.request)
     self.assertTrue('login_status' in res.data)
     self.assertEqual(
         u"Nie ma takiego użytkownika", res.data['login_status'])
Exemple #13
0
 def test_redirect(self):
     from pyramid.httpexceptions import HTTPFound
     self.request.POST['submit_register'] = 'submitting'
     res = index_view(self.request)
     self.assertEqual(HTTPFound, type(res))
Exemple #14
0
 def test_not_login(self):
     res = index_view(self.request)
     self.assertFalse('submit_logout' in res.body)
Exemple #15
0
 def test_no_submit(self):
     res = index_view(self.request)
     self.assertEqual(u"Niezalogowany.", res.data['login_status'])