| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Tests for scripts/tools/mastermap.py""" | 6 """Tests for scripts/tools/mastermap.py""" |
| 7 | 7 |
| 8 | 8 |
| 9 import json | 9 import json |
| 10 import unittest | 10 import unittest |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 self.assertEquals(output.data[0]['master_base_class'], 'Master1') | 98 self.assertEquals(output.data[0]['master_base_class'], 'Master1') |
| 99 | 99 |
| 100 def test_skip_used_ports(self): | 100 def test_skip_used_ports(self): |
| 101 masters = self._gen_masters(5) | 101 masters = self._gen_masters(5) |
| 102 master_class_name = 'Master1' | 102 master_class_name = 'Master1' |
| 103 output = FakeOutput() | 103 output = FakeOutput() |
| 104 mastermap.find_port(master_class_name, masters, output, FakeOpts()) | 104 mastermap.find_port(master_class_name, masters, output, FakeOpts()) |
| 105 self.assertEquals(output.data, [ { | 105 self.assertEquals(output.data, [ { |
| 106 u'master_base_class': u'Master1', | 106 u'master_base_class': u'Master1', |
| 107 u'master_port': u'20105', | 107 u'master_port': u'20105', |
| 108 u'master_port_alt': u'40105', | 108 u'master_port_alt': u'25105', |
| 109 u'slave_port': u'30105', | 109 u'slave_port': u'30105', |
| 110 } ]) | 110 } ]) |
| 111 | 111 |
| 112 def test_skip_blacklisted_ports(self): | 112 def test_skip_blacklisted_ports(self): |
| 113 masters = [{'name': 'Master1', 'fullhost': 'master1.golo.chromium.org'}] | 113 masters = [{'name': 'Master1', 'fullhost': 'master1.golo.chromium.org'}] |
| 114 master_class_name = 'Master1' | 114 master_class_name = 'Master1' |
| 115 output = FakeOutput() | 115 output = FakeOutput() |
| 116 _real_blacklist = mastermap.PORT_BLACKLIST | 116 _real_blacklist = mastermap.PORT_BLACKLIST |
| 117 try: | 117 try: |
| 118 mastermap.PORT_BLACKLIST = set(xrange(40000, 50000)) # All alt_ports | 118 mastermap.PORT_BLACKLIST = set(xrange(25000, 30000)) # All alt_ports |
| 119 self.assertRaises(RuntimeError, mastermap.find_port, | 119 self.assertRaises(RuntimeError, mastermap.find_port, |
| 120 master_class_name, masters, output, FakeOpts()) | 120 master_class_name, masters, output, FakeOpts()) |
| 121 finally: | 121 finally: |
| 122 mastermap.PORT_BLACKLIST = _real_blacklist | 122 mastermap.PORT_BLACKLIST = _real_blacklist |
| 123 | 123 |
| 124 | 124 |
| 125 class AuditTest(unittest.TestCase): | 125 class AuditTest(unittest.TestCase): |
| 126 # TODO(agable): Actually test this. | 126 # TODO(agable): Actually test this. |
| 127 pass | 127 pass |
| 128 | 128 |
| 129 | 129 |
| 130 if __name__ == '__main__': | 130 if __name__ == '__main__': |
| 131 unittest.TestCase.maxDiff = None | 131 unittest.TestCase.maxDiff = None |
| 132 unittest.main() | 132 unittest.main() |
| OLD | NEW |