Using new usage process of new SDK

This commit is contained in:
butomo1989
2017-11-09 11:25:21 +01:00
parent d28c4dc5e0
commit 567a494ccb
3 changed files with 50 additions and 53 deletions
+14 -12
View File
@@ -10,22 +10,24 @@ from src import app
class TestApp(TestCase):
"""Unit test class to test other methods in the app."""
#create symlink
@classmethod
def test_symlink_correct(self):
os.mknod(os.path.join("./","testFile1.txt"))
app.symlink_force(os.path.join("./","testFile1.txt"),os.path.join("./","link_testFile1.txt"))
os.remove(os.path.join("./","testFile1.txt"))
os.remove(os.path.join("./","link_testFile1.txt"))
def test_symlink(self):
res = os.path.join('testFile1.txt')
dest = os.path.join('link_testFile1.txt')
open(res, 'a').close()
app.symlink_force(res, dest)
os.remove(res)
os.remove(dest)
#link already exist
@classmethod
def test_symlink_already_exist(self):
os.mknod(os.path.join("./","testFile2.txt"))
os.mknod(os.path.join("./","link_testFile2.txt"))
app.symlink_force(os.path.join("./","testFile2.txt"),os.path.join("./","link_testFile2.txt"))
os.remove(os.path.join("./","testFile2.txt"))
os.remove(os.path.join("./","link_testFile2.txt"))
res = os.path.join('testFile1.txt')
dest = os.path.join('link_testFile1.txt')
open(res, 'a').close()
open(dest, 'a').close()
app.symlink_force(res, dest)
os.remove(res)
os.remove(dest)
def test_valid_env(self):
key = 'ENV_1'
+17 -21
View File
@@ -8,34 +8,30 @@ from src import app
@mock.patch('subprocess.check_call')
@mock.patch('os.symlink')
class TestAvd(TestCase):
"""Unit test class to test method create_avd."""
def setUp(self):
self.avd_name = 'test_avd'
def test_nexus_avd_as_default(self, mocked_suprocess, mocked_sys_link):
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)
app.prepare_avd('Nexus 5', self.avd_name)
self.assertTrue(mocked_list_dir.called)
self.assertTrue(mocked_sys_link.called)
self.assertTrue(mocked_suprocess.called)
@mock.patch("builtins.open", create=True)
def test_nexus_avd_as_default(self, mocked_suprocess, mocked_open):
self.assertFalse(mocked_suprocess.called)
self.assertFalse(mocked_open.called)
app.prepare_avd('Nexus 5', self.avd_name)
self.assertTrue(mocked_suprocess.called)
self.assertTrue(mocked_open.called)
def test_samsung_avd(self, mocked_suprocess, mocked_sys_link):
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)
app.prepare_avd('Samsung Galaxy S6', self.avd_name)
self.assertTrue(mocked_list_dir.called)
self.assertTrue(mocked_sys_link.called)
self.assertTrue(mocked_suprocess.called)
@mock.patch('os.symlink')
@mock.patch("builtins.open", create=True)
def test_samsung_avd(self, mocked_suprocess, mocked_sys_link, mocked_open):
self.assertFalse(mocked_sys_link.called)
self.assertFalse(mocked_suprocess.called)
self.assertFalse(mocked_open.called)
app.prepare_avd('Samsung Galaxy S6', self.avd_name)
self.assertTrue(mocked_sys_link.called)
self.assertTrue(mocked_suprocess.called)
self.assertTrue(mocked_open.called)
def tearDown(self):
if os.getenv('DEVICE'):