Example #1
0
    def test_set_policy(self):
        policy = random.choice(ConfigPolicy.INSTANCES.keys())

        club = Club(1, 1)
        club.set_policy(policy)
        assert club.policy == policy

        doc = MongoDB.get(1).character.find_one({'_id': 1}, {'club.policy': 1})
        assert doc['club']['policy'] == policy
Example #2
0
    def test_set_policy(self):
        policy = random.choice(ConfigPolicy.INSTANCES.keys())

        club = Club(1, 1)
        club.set_policy(policy)
        assert club.policy == policy

        doc = MongoDB.get(1).character.find_one({'_id': 1}, {'club.policy': 1})
        assert doc['club']['policy'] == policy
Example #3
0
    def test_set_policy_not_exists(self):
        def _get_policy():
            while True:
                policy = random.randint(1, 1000)
                if policy not in ConfigPolicy.INSTANCES.keys():
                    return policy

        policy = _get_policy()

        club = Club(1, 1)
        try:
            club.set_policy(policy)
        except GameException as e:
            assert e.error_id == ConfigErrorMessage.get_error_id("POLICY_NOT_EXIST")
            doc = MongoDB.get(1).character.find_one({'_id': 1}, {'club.policy': 1})
            assert doc['club']['policy'] != policy
        else:
            raise Exception("can not be here")
Example #4
0
    def test_set_policy_not_exists(self):
        def _get_policy():
            while True:
                policy = random.randint(1, 1000)
                if policy not in ConfigPolicy.INSTANCES.keys():
                    return policy

        policy = _get_policy()

        club = Club(1, 1)
        try:
            club.set_policy(policy)
        except GameException as e:
            assert e.error_id == ConfigErrorMessage.get_error_id(
                "POLICY_NOT_EXIST")
            doc = MongoDB.get(1).character.find_one({'_id': 1},
                                                    {'club.policy': 1})
            assert doc['club']['policy'] != policy
        else:
            raise Exception("can not be here")