Example #1
0
def test_map_returns_correct_image_ID(index_number, expected_value):
    """
    Take JSON file with test_1 map and assert correct image ID.
    index_number: tiles list instance index
    expected value: "id" stored in tiles list
    If the test_1.json map is changed or removed, the test needs to be updated.
    """
    data = get_data("maps/test_1.json")
    assert data["tilesets"][0]["tiles"][index_number]["id"] == expected_value
Example #2
0
def test_tile_size(map_name):
    """
    Take size of tiles used in JSON files and assert correct tile size.
    This test has to be removed, when width and height of tile image are
    no longer constants used for tile drawing.
    """
    data = get_data(map_name)
    assert data["tilewidth"] == 64
    assert data["tileheight"] == 64
Example #3
0
def test_dict_paths_is_correct():
    """
    Assert that the result of get_paths() is a dictionary.
    Assert that the paths structure is valid: integer is tile ID, string is path to the picture.
    """
    data = get_data("maps/test_3.json")
    paths = get_paths(data)
    for key, value in paths.items():
        assert isinstance(key, int)
        assert isinstance(value, str)
    assert isinstance(paths, dict)
Example #4
0
def test_map_returns_correct_data_list():
    """
    Take JSON file with test_1 map and assert correct data list.
    If the test_1.json map is changed or removed, the test needs to be updated.
    """
    data = get_data("maps/test_1.json")
    assert data["layers"][0]["data"] == [
        2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1,
        2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1,
        2, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1,
        2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
        2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1,
        2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
    ]