Fixed issue with device / skin for android version < 5.0

This commit is contained in:
butomo1989
2017-03-07 16:24:14 +01:00
parent 032552a5e9
commit fdf936a3f3
4 changed files with 60 additions and 27 deletions
+15 -4
View File
@@ -6,6 +6,8 @@ import mock
from src import android
@mock.patch('os.symlink')
@mock.patch('subprocess.check_call')
class TestAvd(TestCase):
"""Unit test class to test method create_avd."""
@@ -16,15 +18,24 @@ class TestAvd(TestCase):
self.avd_name = 'nexus_5_5.0'
self.api_level = 21
@mock.patch('os.symlink')
@mock.patch('subprocess.check_call')
def test_avd_creation(self, mocked_sys_link, mocked_suprocess):
def test_avd_creation_x86_64(self, mocked_sys_link, mocked_suprocess):
with mock.patch('os.listdir') as mocked_list_dir:
mocked_list_dir.return_value = ['file1', 'file2']
self.assertFalse(mocked_list_dir.called)
self.assertFalse(mocked_sys_link.called)
self.assertFalse(mocked_suprocess.called)
android.create_avd(self.android_path, self.device, self.skin, self.avd_name, self.api_level)
android.create_avd(self.android_path, self.device, self.skin, self.avd_name, android.TYPE_X86_64,
self.api_level)
self.assertTrue(mocked_list_dir.called)
self.assertTrue(mocked_sys_link.called)
self.assertTrue(mocked_suprocess.called)
def test_avd_creation_x86(self, mocked_sys_link, mocked_suprocess):
with mock.patch('os.listdir') as mocked_list_dir:
mocked_list_dir.return_value = ['file1', 'file2']
self.assertFalse(mocked_list_dir.called)
self.assertFalse(mocked_sys_link.called)
self.assertFalse(mocked_suprocess.called)
android.create_avd(self.android_path, self.device, self.skin, self.avd_name, android.TYPE_X86,
self.api_level)
self.assertFalse(mocked_list_dir.called)