Skip to content

Commit f729df2

Browse files
committed
[test] Add test for openal
1 parent 529dad3 commit f729df2

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

tests/recipes/test_openal.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import unittest
2+
from unittest import mock
3+
from tests.recipes.recipe_lib_test import BaseTestForCmakeRecipe
4+
5+
6+
class TestOpenalRecipe(BaseTestForCmakeRecipe, unittest.TestCase):
7+
"""
8+
An unittest for recipe :mod:`~pythonforandroid.recipes.openal`
9+
"""
10+
recipe_name = "openal"
11+
12+
@mock.patch("pythonforandroid.recipes.openal.sh.cmake")
13+
@mock.patch("pythonforandroid.recipes.openal.sh.make")
14+
@mock.patch("pythonforandroid.recipes.openal.sh.cp")
15+
@mock.patch("pythonforandroid.util.chdir")
16+
@mock.patch("pythonforandroid.build.ensure_dir")
17+
@mock.patch("pythonforandroid.archs.glob")
18+
@mock.patch("pythonforandroid.archs.find_executable")
19+
def test_prebuild_arch(
20+
self,
21+
mock_find_executable,
22+
mock_glob,
23+
mock_ensure_dir,
24+
mock_current_directory,
25+
mock_sh_cp,
26+
mock_sh_make,
27+
mock_sh_cmake,
28+
):
29+
mock_find_executable.return_value = (
30+
"/opt/android/android-ndk/toolchains/"
31+
"llvm/prebuilt/linux-x86_64/bin/clang"
32+
)
33+
mock_glob.return_value = ["llvm"]
34+
self.recipe.build_arch(self.arch)
35+
36+
# make sure that the mocked methods are actually called
37+
mock_glob.assert_called()
38+
mock_ensure_dir.assert_called()
39+
mock_current_directory.assert_called()
40+
mock_find_executable.assert_called()
41+
mock_sh_cp.assert_called()
42+
mock_sh_make.assert_called()
43+
mock_sh_cmake.assert_called()
44+
45+
@mock.patch("pythonforandroid.recipes.openal.sh.cp")
46+
@mock.patch("pythonforandroid.util.chdir")
47+
@mock.patch("pythonforandroid.build.ensure_dir")
48+
@mock.patch("pythonforandroid.archs.glob")
49+
@mock.patch("pythonforandroid.archs.find_executable")
50+
def test_build_arch(
51+
self,
52+
mock_find_executable,
53+
mock_glob,
54+
mock_ensure_dir,
55+
mock_current_directory,
56+
mock_sh_cp,
57+
):
58+
# We overwrite the base test method because we need to mock a little
59+
# more with this recipe (`sh.cp` and `sh.rm`)
60+
super(TestOpenalRecipe, self).test_build_arch()
61+
# make sure that the mocked methods are actually called
62+
mock_sh_cp.assert_called()

0 commit comments

Comments
 (0)