예제 #1
0
    def setUp(self):
        super(RequestTestsBase, self).setUp()
        create_test_map()

        self.account_1 = self.accounts_factory.create_account()
        self.account_2 = self.accounts_factory.create_account()

        self.client = client.Client()

        self.game_info_url_1 = game_info_url(account_id=self.account_1.id)
        self.game_info_url_2 = game_info_url(account_id=self.account_2.id)
        self.game_info_url_no_id = game_info_url()

        self.request_login(self.account_1.email)
예제 #2
0
    def setUp(self):
        super(RequestTestsBase, self).setUp()
        create_test_map()

        self.account_1 = self.accounts_factory.create_account()
        self.account_2 = self.accounts_factory.create_account()

        self.client = client.Client()

        self.game_info_url_1 = game_info_url(account_id=self.account_1.id)
        self.game_info_url_2 = game_info_url(account_id=self.account_2.id)
        self.game_info_url_no_id = game_info_url()

        self.request_login(self.account_1.email)
예제 #3
0
    def setUp(self):
        super(RequestTestsBase, self).setUp()
        create_test_map()

        result, account_id, bundle_id = register_user('test_user', '*****@*****.**', '111111')
        self.account_1_id = account_id
        self.account_1 = AccountPrototype.get_by_id(account_id)

        result, account_id, bundle_id = register_user('test_user_2', '*****@*****.**', '111111')
        self.account_2_id = account_id
        self.account_2 = AccountPrototype.get_by_id(account_id)

        self.client = client.Client()

        self.game_info_url_1 = game_info_url(account_id=self.account_1.id)
        self.game_info_url_2 = game_info_url(account_id=self.account_2.id)
        self.game_info_url_no_id = game_info_url()

        self.request_login('*****@*****.**')
예제 #4
0
    def test_client_turns_passed_to_data_receiver(self):
        with mock.patch('the_tale.game.heroes.prototypes.HeroPrototype.cached_ui_info_for_hero',
                        mock.Mock(return_value={'actual_on_turn': 666})) as cached_ui_info_for_hero:
            self.check_ajax_ok(self.request_ajax_json(game_info_url(client_turns=[1, 2, 3 ,4])))

        self.assertEqual(cached_ui_info_for_hero.call_args_list,
                         [mock.call(account_id=self.account_1.id,
                                    recache_if_required=True,
                                    patch_turns=[1, 2, 3, 4],
                                    for_last_turn=False)])
예제 #5
0
    def setUp(self):
        super(RequestTestsBase, self).setUp()
        create_test_map()

        result, account_id, bundle_id = register_user('test_user', '*****@*****.**', '111111')
        self.account_1_id = account_id
        self.account_1 = AccountPrototype.get_by_id(account_id)

        result, account_id, bundle_id = register_user('test_user_2', '*****@*****.**', '111111')
        self.account_2_id = account_id
        self.account_2 = AccountPrototype.get_by_id(account_id)

        self.client = client.Client()

        self.game_info_url_1 = game_info_url(account_id=self.account_1.id)
        self.game_info_url_2 = game_info_url(account_id=self.account_2.id)
        self.game_info_url_no_id = game_info_url()

        self.request_login('*****@*****.**')
예제 #6
0
    def test_client_turns_passed_to_data_receiver(self):
        with mock.patch('the_tale.game.heroes.objects.Hero.cached_ui_info_for_hero',
                        mock.Mock(return_value={'actual_on_turn': 666})) as cached_ui_info_for_hero:
            self.check_ajax_ok(self.request_ajax_json(game_info_url(client_turns=[1, 2, 3 ,4])))

        self.assertEqual(cached_ui_info_for_hero.call_args_list,
                         [mock.call(account_id=self.account_1.id,
                                    recache_if_required=True,
                                    patch_turns=[1, 2, 3, 4],
                                    for_last_turn=False)])
예제 #7
0
 def test_client_turns(self):
     self.check_ajax_error(self.request_ajax_json(game_info_url(client_turns=['dds'])), 'client_turns.wrong_format')
     self.check_ajax_error(self.request_ajax_json(game_info_url(client_turns=['1', ''])), 'client_turns.wrong_format')
     self.check_ajax_ok(self.request_ajax_json(game_info_url(client_turns=['1'])))
     self.check_ajax_ok(self.request_ajax_json(game_info_url(client_turns=['1, 2, 3 ,4'])))
     self.check_ajax_ok(self.request_ajax_json(game_info_url(client_turns=[1, 2, 3 ,4])))
     self.check_ajax_ok(self.request_ajax_json(game_info_url(client_turns=['1',' 2',' 3 ','4'])))
예제 #8
0
 def test_client_turns(self):
     self.check_ajax_error(self.request_ajax_json(game_info_url(client_turns=['dds'])), 'client_turns.wrong_format')
     self.check_ajax_error(self.request_ajax_json(game_info_url(client_turns=['1', ''])), 'client_turns.wrong_format')
     self.check_ajax_ok(self.request_ajax_json(game_info_url(client_turns=['1'])))
     self.check_ajax_ok(self.request_ajax_json(game_info_url(client_turns=['1, 2, 3 ,4'])))
     self.check_ajax_ok(self.request_ajax_json(game_info_url(client_turns=[1, 2, 3 ,4])))
     self.check_ajax_ok(self.request_ajax_json(game_info_url(client_turns=['1',' 2',' 3 ','4'])))
예제 #9
0
 def test_wrong_account_id(self):
     response = self.request_ajax_json(game_info_url(account_id='sdsd'))
     self.check_ajax_error(response, 'account.wrong_format')
예제 #10
0
 def test_account_not_exists(self):
     response = self.request_ajax_json(game_info_url(account_id=666))
     self.check_ajax_error(response, 'account.wrong_value')
예제 #11
0
 def test_wrong_account_id(self):
     response = self.request_ajax_json(game_info_url(account_id='sdsd'))
     self.check_ajax_error(response, 'account.wrong_format')
예제 #12
0
 def test_account_not_exists(self):
     response = self.request_ajax_json(game_info_url(account_id=666))
     self.check_ajax_error(response, 'account.wrong_value')
예제 #13
0
def game_info_url(account=None, client_turns=None):
    return jinja2.Markup(
        logic.game_info_url(
            account_id=account.id if account is not None else None,
            client_turns=client_turns))
예제 #14
0
def game_info_url(account=None, client_turns=None):
    return jinja2.Markup(logic.game_info_url(account_id=account.id if account is not None else None,
                                             client_turns=client_turns))