testing/mozbase/mozdevice/tests/sut_ip.py

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

     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()

mercurial