docker-android/service/tests/__init__.py

31 lines
1.1 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
class TestService(TestCase):
"""Unit test class to test method run."""
2017-01-08 16:24:14 +00:00
@mock.patch('service.start.get_android_bash_commands')
2016-12-22 13:29:57 +00:00
@mock.patch('subprocess.check_call')
2017-01-08 16:24:14 +00:00
def test_service(self, mocked_bash_cmd, mocked_subprocess):
self.assertFalse(mocked_bash_cmd.called)
2016-12-22 13:29:57 +00:00
self.assertFalse(mocked_subprocess.called)
start.run()
2017-01-08 16:24:14 +00:00
self.assertTrue(mocked_bash_cmd.called)
2016-12-22 13:29:57 +00:00
self.assertTrue(mocked_subprocess.called)
2017-01-08 16:24:14 +00:00
@mock.patch('service.start.get_android_bash_commands')
@mock.patch('subprocess.check_call')
@mock.patch('service.start.logger.warning')
def test_empty_android_cmd(self, mocked_bash_cmd, mocked_subprocess, mocked_logger_warning):
mocked_bash_cmd.return_value = None
self.assertFalse(mocked_subprocess.called)
self.assertFalse(mocked_logger_warning.called)
start.run()
self.assertTrue(mocked_subprocess.called)
self.assertTrue(mocked_logger_warning.called)