示例#1
0
    def test_clear_app_data(self, s_or_e):
        mock_adb = Mock()
        mock_adb.shell_command.return_value = 'succes'
        Adb.adb = mock_adb
        device_id = 123
        name = 'app_name'

        manager = Mock()
        manager.attach_mock(s_or_e, "s_or_e_mock")
        manager.mock_adb = mock_adb

        Adb.clear_app_data(device_id, name)

        expected_calls = [
            call.mock_adb.set_target_by_name(123),
            call.mock_adb.shell_command('pm clear app_name'),
            call.s_or_e_mock(
                'succes', '{}: Data of "{}" cleared'.format(device_id, name),
                '{}: Failed to clear data for "{}"'.format(device_id, name))
        ]
        assert manager.mock_calls == expected_calls
示例#2
0
    def test_uninstall_keep_data(self, s_or_e):
        mock_adb = Mock()
        mock_adb.uninstall.return_value = 'succes'
        Adb.adb = mock_adb
        device_id = 123
        name = 'app_name'

        manager = Mock()
        manager.attach_mock(s_or_e, "s_or_e_mock")
        manager.mock_adb = mock_adb

        Adb.uninstall(device_id, name, True)

        expected_calls = [
            call.mock_adb.set_target_by_name(123),
            call.mock_adb.uninstall(package=name, keepdata=False),
            call.s_or_e_mock(
                'succes', '{}: "{}" uninstalled'.format(device_id, name),
                '{}: Failed to uninstall "{}"'.format(device_id, name))
        ]
        assert manager.mock_calls == expected_calls