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