Пример #1
0
    def test_eso_query_post_dungeon_run(self):
        db_cursor = QueryEsoDungeonTable()

        # check current highest run id:
        last_added_run_id = db_cursor.eso_get_id_of_last_added_record()

        payload = {
            c.ESO_FORM_KEY_SUBMIT_DUNGEON_RUN_DATA: {
                c.ESO_FORM_KEY_CLASS_FOUR: c.CLASS_DRAGONKNIGHT,
                c.ESO_FORM_KEY_CLASS_ONE: c.CLASS_NECRO,
                c.ESO_FORM_KEY_CLASS_THREE: c.CLASS_WARDEN,
                c.ESO_FORM_KEY_CLASS_TWO: c.CLASS_SORCERER,
                c.ESO_FORM_KEY_DUNGEON_NAME: c.DUNGEON_ARX_CORINIUM,
                c.ESO_FORM_KEY_FLAWLESS: c.ESO_NO,
                c.ESO_FORM_KEY_HARDMODE: c.ESO_NO,
                c.ESO_FORM_KEY_PLAYER_COUNT: 4,
                c.ESO_FORM_KEY_TIME_NEEDED: 20,
                c.ESO_FORM_KEY_WIPES: 0
            }
        }
        response = h.api_post_request(
            constants.FLASK_BACKEND_URL + constants.API_ESO_POST_DUNGEON_RUN,
            payload)

        assert response is not None
        assert response.status_code == 200

        # now a new id must have been created (autoincrement of DB)
        new_last_added_run_id = db_cursor.eso_get_id_of_last_added_record()

        assert new_last_added_run_id != last_added_run_id

        # delete added run
        status = db_cursor.eso_delete_last_added_record_query()
        assert status == 200
Пример #2
0
    def test_api_get_request(self):
        resp = h.api_get_request(c.FLASK_BACKEND_URL + c.API_HEALTH_CHECK)
        assert resp is not None
        assert resp.status_code == c.RESP_OK

        msg = resp.json()[c.KEY_HEALTH_CHECK_RESPONSE]
        assert msg[c.KEY_STATUS] == c.RESP_OK
        assert msg[c.KEY_MESSAGE] == c.MSG_HEALTH_CHECK_SUCCESS
Пример #3
0
    def test_get_ai_battle_data_with_ai_count(self):
        for ai_count in range(2, 9):
            payload = {shc_c.SHC_KEY_AI_BATTLE_PLAYER_COUNT: ai_count}
            response = h.api_post_request(
                c.FLASK_BACKEND_URL + c.API_STRONGHOLD_GET_AI_BATTLE, payload)

            assert response is not None
            assert response.status_code == 200
Пример #4
0
    def test_misc_get_constants(self):
        response = h.api_get_request(constants.FLASK_BACKEND_URL +
                                     constants.API_MISC_GET_CONSTANTS)

        assert response is not None
        assert response.status_code == 200

        data = response.json()[c.MISC_KEY_MISC_CONSTANTS][0]
        assert data[c.MISC_KEY_LIST_MATH_SYMBOLS] == c.LIST_MATH_SYMBOLS
        assert data[c.MISC_KEY_LIST_DIFFICULTIES] == c.LIST_DIFFICULTIES
Пример #5
0
    def test_eso_get_constants(self):
        response = h.api_get_request(constants.FLASK_BACKEND_URL +
                                     constants.API_ESO_GET_CONSTANTS)

        assert response is not None
        assert response.status_code == 200

        data = response.json()[c.ESO_KEY_ESO_CONSTANTS][0]
        assert data[c.ESO_KEY_LIST_ESO_CLASSES] == c.LIST_ESO_CLASSES
        assert data[c.ESO_KEY_LIST_ESO_DUNGEONS] == c.LIST_ESO_DUNGEONS
        assert data[c.ESO_KEY_LIST_ESO_RAIDS] == c.LIST_ESO_RAIDS
Пример #6
0
    def test_eso_query_post_raid_run(self):
        db_cursor = QueryEsoRaidTable()

        # check current highest run id:
        last_added_run_id = db_cursor.eso_get_id_of_last_added_record()

        payload = {
            c.ESO_FORM_KEY_RAID_RUN_FORM_DATA: {
                c.ESO_FORM_KEY_RAID_NAME: c.RAID_SUNSPIRE,
                c.ESO_FORM_KEY_PLAYER_COUNT: 12,
                c.ESO_FORM_KEY_TIME_NEEDED: 60,
                c.ESO_FORM_KEY_HARDMODE: c.ESO_YES,
                c.ESO_FORM_KEY_FLAWLESS: c.ESO_NO,
                c.ESO_FORM_KEY_WIPES: 0,
                c.ESO_FORM_KEY_CLASS_ONE: c.CLASS_DRAGONKNIGHT,
                c.ESO_FORM_KEY_CLASS_TWO: c.CLASS_DRAGONKNIGHT,
                c.ESO_FORM_KEY_CLASS_THREE: c.CLASS_DRAGONKNIGHT,
                c.ESO_FORM_KEY_CLASS_FOUR: c.CLASS_SORCERER,
                c.ESO_FORM_KEY_CLASS_FIVE: c.CLASS_SORCERER,
                c.ESO_FORM_KEY_CLASS_SIX: c.CLASS_SORCERER,
                c.ESO_FORM_KEY_CLASS_SEVEN: c.CLASS_NIGHTBLADE,
                c.ESO_FORM_KEY_CLASS_EIGHT: c.CLASS_NIGHTBLADE,
                c.ESO_FORM_KEY_CLASS_NINE: c.CLASS_NIGHTBLADE,
                c.ESO_FORM_KEY_CLASS_TEN: c.CLASS_TEMPLAR,
                c.ESO_FORM_KEY_CLASS_ELEVEN: c.CLASS_TEMPLAR,
                c.ESO_FORM_KEY_CLASS_TWELVE: c.CLASS_TEMPLAR,
                c.ESO_FORM_KEY_NUM_TANKS: 2,
                c.ESO_FORM_KEY_NUM_DPS: 7,
                c.ESO_FORM_KEY_NUM_HEALS: 3,
                c.ESO_FORM_KEY_TOTAL_PARTY_DPS: 750000,
                c.ESO_FORM_KEY_TOTAL_PARTY_HPS: 120000
            }
        }
        response = h.api_post_request(
            constants.FLASK_BACKEND_URL + constants.API_ESO_POST_RAID_RUN,
            payload)

        assert response is not None
        assert response.status_code == 200

        # now a new id must have been created (autoincrement of DB)
        new_last_added_run_id = db_cursor.eso_get_id_of_last_added_record()

        assert new_last_added_run_id != last_added_run_id

        # delete added run
        status = db_cursor.eso_delete_last_added_record_query()
        assert status == 200
Пример #7
0
    def test_api_post_request(self):
        test_json_payload = {
            c.KEY_HEALTH_CHECK_PAYLOAD: {
                'test1': 123,
                'test2': "abc"
            }
        }
        resp = h.api_post_request(c.FLASK_BACKEND_URL + c.API_HEALTH_CHECK,
                                  test_json_payload)
        assert resp is not None
        assert resp.status_code == c.RESP_OK

        msg = resp.json()[c.KEY_HEALTH_CHECK_RESPONSE]
        assert msg[c.KEY_STATUS] == c.RESP_OK
        assert msg[c.KEY_MESSAGE] == c.MSG_HEALTH_CHECK_SUCCESS
        assert msg[c.KEY_RECEIVED_PAYLOAD] == test_json_payload
Пример #8
0
    def test_misc_brainstorm_get_exercise_list(self):
        payload = {
            c.MISC_KEY_DATA: {
                c.MISC_KEY_FORM_BRAINSTROM_DIFFICULTY: c.LIST_DIFFICULTIES[0]
            }
        }
        response = h.api_post_request(
            constants.FLASK_BACKEND_URL +
            constants.API_MISC_BRAINSTORM_GET_EXERCISE_LIST, payload)

        assert response is not None
        assert response.status_code == 200

        data = response.json()[c.MISC_KEY_EXERCISES][0]
        assert len(data[c.MISC_KEY_EXERCISE]) == 3
        assert data[c.MISC_KEY_SOLUTION] is not None
Пример #9
0
    def test_survrun_query_get_runs(self):
        """
        Test survrun get all data query. This tests fails if the survrun_runs table is empty.
        """
        response = h.api_get_request(constants.FLASK_BACKEND_URL + constants.API_SURVRUN_GET_ALL_DB_RUN_DATA)
        data = json.loads(response.content)["queryResult"][0]

        assert response is not None
        assert response.status_code == 200
        assert type(data[c.SR_KEY_ID]) == int
        assert data[c.SR_KEY_PLAYER_CLASS] in c.LIST_SURVRIM_CLASSES
        assert data[c.SR_KEY_TARGET_A] in c.LIST_SURVRUN_TARGET_LOCATIONS
        assert data[c.SR_KEY_TARGET_B] in c.LIST_SURVRUN_TARGET_LOCATIONS
        assert type(data[c.SR_KEY_TIMEBOX]) == int
        assert data[c.SR_KEY_COMPLETED] == c.SURVRIM_YES or data[c.SR_KEY_COMPLETED] == c.SURVRIM_NO
        assert type(data[c.SR_KEY_TIME_NEEDED]) == int
        assert type(data[c.SR_KEY_R_COUNT]) == int
Пример #10
0
    def test_get_target_location_data(self):
        response = h.api_get_request(constants.FLASK_BACKEND_URL + constants.API_SURVRUN_GET_TARGET_LOCATION)

        assert response is not None
        assert response.status_code == 200

        unique_locations_in_response = 0
        for location in c.LIST_SURVRUN_TARGET_LOCATIONS:
            if unique_locations_in_response == 2:
                break
            if location in response.text:
                unique_locations_in_response += 1
        assert unique_locations_in_response == 2

        data = json.loads(response.text)
        assert type(data[c.SR_KEY_SURVRUN_DATA][0][c.SR_KEY_TARGET_LOCATION_ONE]) == str
        assert type(data[c.SR_KEY_SURVRUN_DATA][0][c.SR_KEY_TARGET_LOCATION_TWO]) == str
        assert data[c.SR_KEY_SURVRUN_DATA][0][c.SR_KEY_TIMEBOX] is not None
        assert type(data[c.SR_KEY_SURVRUN_DATA][0][c.SR_KEY_TIMEBOX]) == int
Пример #11
0
    def test_eso_query_get_dungeon_runs(self):
        """
        Test eso get dungeon runs endpoint
        Note that this test will always fail if the database is empty!
        """
        response = h.api_get_request(constants.FLASK_BACKEND_URL +
                                     constants.API_ESO_GET_DUNGEON_RUNS)

        assert response is not None
        assert response.status_code == 200

        data = response.json()[c.ESO_KEY_QUERY_RESULT][0]
        assert type(data[c.ESO_KEY_ID]) == int
        assert data[c.ESO_KEY_DUNGEON_NAME] in c.LIST_ESO_DUNGEONS
        assert type(data[c.ESO_KEY_PLAYER_COUNT]) == int
        assert type(data[c.ESO_KEY_TIME_NEEDED]) == int
        assert type(data[c.ESO_KEY_HARDMODE]) == bool
        assert type(data[c.ESO_KEY_FLAWLESS]) == bool
        assert type(data[c.ESO_KEY_WIPES]) == int
        assert data[c.ESO_KEY_CLASS_ONE] in c.LIST_ESO_CLASSES
        assert data[c.ESO_KEY_CLASS_TWO] in c.LIST_ESO_CLASSES
        assert data[c.ESO_KEY_CLASS_THREE] in c.LIST_ESO_CLASSES
        assert data[c.ESO_KEY_CLASS_FOUR] in c.LIST_ESO_CLASSES
Пример #12
0
    def test_eso_query_get_raid_runs(self):
        """
        Test eso get raid runs endpoint
        Note that this test will always fail if the database is empty!
        """
        response = h.api_get_request(constants.FLASK_BACKEND_URL +
                                     constants.API_ESO_GET_RAID_RUNS)

        assert response is not None
        assert response.status_code == 200

        data = response.json()[c.ESO_KEY_QUERY_RESULT][0]
        assert type(data[c.ESO_KEY_ID]) == int
        assert data[c.ESO_KEY_RAID_NAME] in c.LIST_ESO_RAIDS
        assert type(data[c.ESO_KEY_PLAYER_COUNT]) == int
        assert type(data[c.ESO_KEY_TIME_NEEDED]) == int
        assert type(data[c.ESO_KEY_HARDMODE]) == bool
        assert type(data[c.ESO_KEY_FLAWLESS]) == bool
        assert type(data[c.ESO_KEY_WIPES]) == int
        assert data[c.ESO_KEY_CLASS_ONE] in c.LIST_ESO_CLASSES
        assert data[c.ESO_KEY_CLASS_TWO] in c.LIST_ESO_CLASSES
        assert data[c.ESO_KEY_CLASS_THREE] in c.LIST_ESO_CLASSES
        assert data[c.ESO_KEY_CLASS_FOUR] in c.LIST_ESO_CLASSES
        assert data[c.ESO_KEY_CLASS_FIVE] in c.LIST_ESO_CLASSES
        assert data[c.ESO_KEY_CLASS_SIX] in c.LIST_ESO_CLASSES
        assert data[c.ESO_KEY_CLASS_SEVEN] in c.LIST_ESO_CLASSES
        assert data[c.ESO_KEY_CLASS_EIGHT] in c.LIST_ESO_CLASSES
        assert data[c.ESO_KEY_CLASS_NINE] in c.LIST_ESO_CLASSES
        assert data[c.ESO_KEY_CLASS_TEN] in c.LIST_ESO_CLASSES
        assert data[c.ESO_KEY_CLASS_ELEVEN] in c.LIST_ESO_CLASSES
        assert data[c.ESO_KEY_CLASS_TWELVE] in c.LIST_ESO_CLASSES
        assert type(data[c.ESO_KEY_NUM_TANKS]) == int
        assert type(data[c.ESO_KEY_NUM_DPS]) == int
        assert type(data[c.ESO_KEY_NUM_HEALS]) == int
        assert type(data[c.ESO_KEY_TOTAL_PARTY_DPS]) == int
        assert type(data[c.ESO_KEY_TOTAL_PARTY_HPS]) == int
Пример #13
0
    def test_survrun_get_constants(self):
        response = h.api_get_request(constants.FLASK_BACKEND_URL + constants.API_SURVRUN_GET_CONSTANTS)
        data = json.loads(response.content)[c.SR_KEY_SURVRIM_CONSTANTS][0]

        assert response.status_code == 200
        assert data is not None