summaryrefslogtreecommitdiffstats
path: root/testing/mozbase/mozdevice/tests/sut_ip.py
diff options
context:
space:
mode:
Diffstat (limited to 'testing/mozbase/mozdevice/tests/sut_ip.py')
-rw-r--r--testing/mozbase/mozdevice/tests/sut_ip.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/testing/mozbase/mozdevice/tests/sut_ip.py b/testing/mozbase/mozdevice/tests/sut_ip.py
new file mode 100644
index 000000000..31428a624
--- /dev/null
+++ b/testing/mozbase/mozdevice/tests/sut_ip.py
@@ -0,0 +1,37 @@
+#!/usr/bin/env python
+import mozdevice
+import logging
+import unittest
+from sut import MockAgent
+
+
+class TestGetIP(unittest.TestCase):
+ """ class to test IP methods """
+
+ commands = [('exec ifconfig eth0', 'eth0: ip 192.168.0.1 '
+ 'mask 255.255.255.0 flags [up broadcast running multicast]\n'
+ 'return code [0]'),
+ ('exec ifconfig wlan0', 'wlan0: ip 10.1.39.126\n'
+ 'mask 255.255.0.0 flags [up broadcast running multicast]\n'
+ 'return code [0]'),
+ ('exec ifconfig fake0', '##AGENT-WARNING## [ifconfig] '
+ 'command with arg(s) = [fake0] is currently not implemented.')
+ ]
+
+ def test_getIP_eth0(self):
+ m = MockAgent(self, commands=[self.commands[0]])
+ d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=logging.DEBUG)
+ self.assertEqual('192.168.0.1', d.getIP(interfaces=['eth0']))
+
+ def test_getIP_wlan0(self):
+ m = MockAgent(self, commands=[self.commands[1]])
+ d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=logging.DEBUG)
+ self.assertEqual('10.1.39.126', d.getIP(interfaces=['wlan0']))
+
+ def test_getIP_error(self):
+ m = MockAgent(self, commands=[self.commands[2]])
+ d = mozdevice.DroidSUT("127.0.0.1", port=m.port, logLevel=logging.DEBUG)
+ self.assertRaises(mozdevice.DMError, d.getIP, interfaces=['fake0'])
+
+if __name__ == '__main__':
+ unittest.main()