docker-android/service/tests/test_get_command.py

37 lines
1.6 KiB
Python
Raw Normal View History

2016-12-22 13:29:57 +00:00
"""Unit test for start.py."""
from unittest import TestCase
import mock
from service import start
@mock.patch('service.start.get_available_sdk_packages')
class TestRunService(TestCase):
2017-01-08 16:24:14 +00:00
"""Unit test class to test method get_android_bash_commands."""
2016-12-22 13:29:57 +00:00
2017-01-23 16:25:21 +00:00
def setUp(self):
self.android_version = '4.2.2'
self.emulator_type = start.TYPE_ARMEABI
2016-12-22 13:29:57 +00:00
def test_create_emulator(self, mocked_packages):
mocked_packages.return_value = ['9- SDK Platform Android 4.4.2, API 19, revision 4',
'10- SDK Platform Android 4.3.1, API 18, revision 3',
'11- SDK Platform Android 4.2.2, API 17, revision 3']
2017-01-23 16:25:21 +00:00
cmd = start.get_android_bash_commands(self.android_version, self.emulator_type)
2017-01-08 16:24:14 +00:00
self.assertIsNotNone(cmd)
self.assertTrue('android update sdk' in cmd)
self.assertTrue('android create avd' in cmd)
2016-12-22 13:29:57 +00:00
def test_empty_packages(self, mocked_packages):
mocked_packages.return_value = None
with self.assertRaises(RuntimeError):
2017-01-23 16:25:21 +00:00
start.get_android_bash_commands(self.android_version, self.emulator_type)
2016-12-22 13:29:57 +00:00
def test_index_error(self, mocked_packages):
mocked_packages.return_value = ['9 SDK Platform Android 4.4.2, API 19, revision 4',
'10 SDK Platform Android 4.3.1, API 18, revision 3',
'11 SDK Platform Android 4.2.2, API 17, revision 3']
2017-01-23 16:25:21 +00:00
start.get_android_bash_commands(self.android_version, self.emulator_type)
2016-12-22 13:29:57 +00:00
self.assertRaises(IndexError)