Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 #/usr/bin/env python
2 import mozdevice
3 import mozlog
4 import unittest
5 from sut import MockAgent
8 class TestGetIP(unittest.TestCase):
9 """ class to test IP methods """
11 commands = [('exec ifconfig eth0', 'eth0: ip 192.168.0.1 '
12 'mask 255.255.255.0 flags [up broadcast running multicast]\n'
13 'return code [0]'),
14 ('exec ifconfig wlan0', 'wlan0: ip 10.1.39.126\n'
15 'mask 255.255.0.0 flags [up broadcast running multicast]\n'
16 'return code [0]'),
17 ('exec ifconfig fake0', '##AGENT-WARNING## [ifconfig] '
18 'command with arg(s) = [fake0] is currently not implemented.')
19 ]
21 def test_getIP_eth0(self):
22 m = MockAgent(self, commands=[self.commands[0]])
23 d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=mozlog.DEBUG)
24 self.assertEqual('192.168.0.1', d.getIP(interfaces=['eth0']))
26 def test_getIP_wlan0(self):
27 m = MockAgent(self, commands=[self.commands[1]])
28 d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=mozlog.DEBUG)
29 self.assertEqual('10.1.39.126', d.getIP(interfaces=['wlan0']))
31 def test_getIP_error(self):
32 m = MockAgent(self, commands=[self.commands[2]])
33 d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=mozlog.DEBUG)
34 self.assertRaises(mozdevice.DMError, d.getIP, interfaces=['fake0'])
36 if __name__ == '__main__':
37 unittest.main()