testing/mozbase/mozdevice/tests/sut_ip.py

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 #/usr/bin/env python
michael@0 2 import mozdevice
michael@0 3 import mozlog
michael@0 4 import unittest
michael@0 5 from sut import MockAgent
michael@0 6
michael@0 7
michael@0 8 class TestGetIP(unittest.TestCase):
michael@0 9 """ class to test IP methods """
michael@0 10
michael@0 11 commands = [('exec ifconfig eth0', 'eth0: ip 192.168.0.1 '
michael@0 12 'mask 255.255.255.0 flags [up broadcast running multicast]\n'
michael@0 13 'return code [0]'),
michael@0 14 ('exec ifconfig wlan0', 'wlan0: ip 10.1.39.126\n'
michael@0 15 'mask 255.255.0.0 flags [up broadcast running multicast]\n'
michael@0 16 'return code [0]'),
michael@0 17 ('exec ifconfig fake0', '##AGENT-WARNING## [ifconfig] '
michael@0 18 'command with arg(s) = [fake0] is currently not implemented.')
michael@0 19 ]
michael@0 20
michael@0 21 def test_getIP_eth0(self):
michael@0 22 m = MockAgent(self, commands=[self.commands[0]])
michael@0 23 d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=mozlog.DEBUG)
michael@0 24 self.assertEqual('192.168.0.1', d.getIP(interfaces=['eth0']))
michael@0 25
michael@0 26 def test_getIP_wlan0(self):
michael@0 27 m = MockAgent(self, commands=[self.commands[1]])
michael@0 28 d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=mozlog.DEBUG)
michael@0 29 self.assertEqual('10.1.39.126', d.getIP(interfaces=['wlan0']))
michael@0 30
michael@0 31 def test_getIP_error(self):
michael@0 32 m = MockAgent(self, commands=[self.commands[2]])
michael@0 33 d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=mozlog.DEBUG)
michael@0 34 self.assertRaises(mozdevice.DMError, d.getIP, interfaces=['fake0'])
michael@0 35
michael@0 36 if __name__ == '__main__':
michael@0 37 unittest.main()

mercurial