Ejemplo n.º 1
0
 def test_no_device(self):
     '''
     Test no device.
     '''
     str_ret = 'List of devices attached\n\r'
     expected_ret = {}
     self.mock_obj.communicate.return_value = [str_ret, None]
     self.mock_popen.return_value = self.mock_obj
     devices = AdbWrapper.adb_devices()
     self.assertEqual(devices, expected_ret,
                      'The result should be {}, not {}.'.format(expected_ret, devices))
Ejemplo n.º 2
0
 def test_no_device(self):
     """
     Test no device.
     """
     str_ret = 'List of devices attached\n\r'
     expected_ret = {}
     self.mock_obj.communicate.return_value = [str_ret, None]
     self.mock_popen.return_value = self.mock_obj
     devices = AdbWrapper.adb_devices()
     self.assertEqual(
         devices, expected_ret,
         'The result should be {}, not {}.'.format(expected_ret, devices))
Ejemplo n.º 3
0
 def test_one_device(self):
     '''
     Test one device.
     '''
     str_ret = textwrap.dedent('''\
                               List of devices attached
                               foo\tbar''')
     expected_ret = {'foo': 'bar'}
     self.mock_obj.communicate.return_value = [str_ret, None]
     self.mock_popen.return_value = self.mock_obj
     devices = AdbWrapper.adb_devices()
     self.assertEqual(devices, expected_ret,
                      'The result should be {}, not {}.'.format(expected_ret, devices))
Ejemplo n.º 4
0
 def test_one_device(self):
     """
     Test one device.
     """
     str_ret = textwrap.dedent("""\
                               List of devices attached
                               foo\tbar""")
     expected_ret = {'foo': 'bar'}
     self.mock_obj.communicate.return_value = [str_ret, None]
     self.mock_popen.return_value = self.mock_obj
     devices = AdbWrapper.adb_devices()
     self.assertEqual(
         devices, expected_ret,
         'The result should be {}, not {}.'.format(expected_ret, devices))
Ejemplo n.º 5
0
 def test_two_device(self):
     """
     Test two device.
     """
     str_ret = textwrap.dedent("""\
                               List of devices attached
                               foo\tbar
                               askeing\tcool""")
     expected_ret = {'foo': 'bar', 'askeing': 'cool'}
     self.mock_obj.communicate.return_value = [str_ret, None]
     self.mock_popen.return_value = self.mock_obj
     devices = AdbWrapper.adb_devices()
     self.assertEqual(devices, expected_ret,
                      'The result should be {}, not {}.'.format(expected_ret, devices))
Ejemplo n.º 6
0
 def test_two_device(self):
     '''
     Test two device.
     '''
     str_ret = textwrap.dedent('''\
                               List of devices attached
                               foo\tbar
                               askeing\tcool''')
     expected_ret = {'foo': 'bar', 'askeing': 'cool'}
     self.mock_obj.communicate.return_value = [str_ret, None]
     self.mock_popen.return_value = self.mock_obj
     devices = AdbWrapper.adb_devices()
     self.assertEqual(
         devices, expected_ret,
         'The result should be {}, not {}.'.format(expected_ret, devices))
Ejemplo n.º 7
0
    'serial': "",
    'job_info': {
        'jobname': 'flamekk.vmaster.moztwlab01.512',
        'seriesname': 'mtbf',
        'pid': 18845,
        'program': "chrome",
        'host_name': "mtbf-10",
        'port_no': 8086,
        'user_name': "xxxxxx",
        'pwd': "xxxxxx",
        'database_name': "raptor"
    }
}

# FIXME: with following workaround we still need at least one device connected
devices = AdbWrapper.adb_devices().keys()
testdata['serial'] = devices[0]
mini = MtbfToRaptorMinion(**testdata)


def test_generate_raptor_mtbf_data():
    data = mini.output_data['mtbf']['data'] = mini.generate_raptor_mtbf_data()
    assert (data['mtbf'][0]['deviceId'] == testdata['serial'])


def test_generate_raptor_event_data():
    mini.output_data['events']['data'] = mini.generate_raptor_event_data(
        mini.output_data['mtbf']['data'])
    data = mini.output_data['events']['data']
    assert (data['events'][0]['device'] == testdata['job_info']
            ['jobname'].split(".")[0])
Ejemplo n.º 8
0
                       'file': "unittest"},
            'serial': "",
            'job_info': {
                'jobname': 'flamekk.vmaster.moztwlab01.512',
                'seriesname': 'mtbf',
                'pid': 18845,
                'program': "chrome",
                'host_name': "mtbf-10",
                'port_no': 8086,
                'user_name': "xxxxxx",
                'pwd': "xxxxxx",
                'database_name': "raptor"
            }}

# FIXME: with following workaround we still need at least one device connected
devices = AdbWrapper.adb_devices().keys()
testdata['serial'] = devices[0]
mini = MtbfToRaptorMinion(**testdata)


def test_generate_raptor_mtbf_data():
    data = mini.output_data['mtbf']['data'] = mini.generate_raptor_mtbf_data()
    assert(data['mtbf'][0]['deviceId'] == testdata['serial'])


def test_generate_raptor_event_data():
    mini.output_data['events']['data'] = mini.generate_raptor_event_data(
        mini.output_data['mtbf']['data'])
    data = mini.output_data['events']['data']
    assert(data['events'][0]['device']
           == testdata['job_info']['jobname'].split(".")[0])