-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
270 additions
and
30 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
function RECTANGLE(a1,a2,a3,a4) | ||
return {a1,a2,a3,a4}; | ||
end | ||
|
||
function VECTOR3(a1,a2,a3) | ||
return {a1,a2,a3}; | ||
end | ||
|
||
function BOOLEAN(bool) | ||
return bool; | ||
end | ||
|
||
function FLOAT(fl) | ||
return fl; | ||
end | ||
|
||
function STRING(str) | ||
return str; | ||
end | ||
|
||
function GROUP(arg) | ||
return arg; | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module type="PYTHON_MODULE" version="4"> | ||
<component name="NewModuleRootManager" inherit-compiler-output="true"> | ||
<exclude-output /> | ||
<content url="file://$MODULE_DIR$" /> | ||
<orderEntry type="inheritedJdk" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
</component> | ||
<component name="TestRunnerService"> | ||
<option name="projectConfiguration" value="py.test" /> | ||
<option name="PROJECT_TEST_RUNNER" value="py.test" /> | ||
</component> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
-f https://content.faforever.com/wheel/ | ||
Wand | ||
pillow | ||
docopt | ||
lupa | ||
marshmallow | ||
marshmallow-jsonapi | ||
pathlib | ||
requests | ||
pytest-cov | ||
pytest-mock | ||
-e . |
Empty file.
Empty file.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
from zipfile import ZipFile | ||
|
||
from pathlib import Path | ||
|
||
import pytest | ||
from PIL import Image | ||
|
||
from faf.tools.fa.maps import generate_map_previews | ||
import os | ||
|
||
HYDRO_ICON = os.path.join(os.path.dirname(os.path.realpath(__file__)), '../../../faf/tools/fa/map_icons/hydro.png') | ||
MASS_ICON = os.path.join(os.path.dirname(os.path.realpath(__file__)), '../../../faf/tools/fa/map_icons/mass.png') | ||
ARMY_ICON = os.path.join(os.path.dirname(os.path.realpath(__file__)), '../../../faf/tools/fa/map_icons/army.png') | ||
MAP_ZIP = os.path.join(os.path.dirname(os.path.realpath(__file__)), '../../data/maps/theta_passage_5.v0001.zip') | ||
|
||
|
||
@pytest.mark.parametrize("hydro_icon", [HYDRO_ICON, None]) | ||
@pytest.mark.parametrize("mass_icon", [MASS_ICON, None]) | ||
@pytest.mark.parametrize("army_icon", [ARMY_ICON, None]) | ||
def test_generate_map_previews(tmpdir, mass_icon, hydro_icon, army_icon): | ||
small_previews_dir = tmpdir.mkdir("small_previews") | ||
large_previews_dir = tmpdir.mkdir("large_previews") | ||
|
||
generate_map_previews(MAP_ZIP, {128: small_previews_dir, 1024: large_previews_dir}, mass_icon, hydro_icon, | ||
army_icon) | ||
|
||
small_files = small_previews_dir.listdir() | ||
large_files = large_previews_dir.listdir() | ||
|
||
assert len(small_files) == 1 | ||
assert len(large_files) == 1 | ||
|
||
with Image.open(small_files[0].strpath) as im: | ||
assert im.size == (128, 128) | ||
with Image.open(large_files[0].strpath) as im: | ||
assert im.size == (1024, 1024) | ||
|
||
|
||
@pytest.mark.parametrize("hydro_icon", [HYDRO_ICON, None]) | ||
@pytest.mark.parametrize("mass_icon", [MASS_ICON, None]) | ||
@pytest.mark.parametrize("army_icon", [ARMY_ICON, None]) | ||
def test_generate_map_previews_from_folder(tmpdir, mass_icon, hydro_icon, army_icon): | ||
small_previews_dir = tmpdir.mkdir("small_previews") | ||
large_previews_dir = tmpdir.mkdir("large_previews") | ||
unpack_dir = tmpdir.mkdir("unpacked_map") | ||
|
||
with ZipFile(MAP_ZIP) as zip: | ||
zip.extractall(unpack_dir.strpath) | ||
|
||
map_folder = os.path.join(unpack_dir.strpath, unpack_dir.listdir()[0].strpath) | ||
|
||
generate_map_previews(map_folder, {128: small_previews_dir, 1024: large_previews_dir}, mass_icon, hydro_icon, | ||
army_icon) | ||
|
||
small_files = small_previews_dir.listdir() | ||
large_files = large_previews_dir.listdir() | ||
|
||
assert len(small_files) == 1 | ||
assert len(large_files) == 1 | ||
|
||
with Image.open(small_files[0].strpath) as im: | ||
assert im.size == (128, 128) | ||
with Image.open(large_files[0].strpath) as im: | ||
assert im.size == (1024, 1024) |