| OLD | NEW |
| (Empty) |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 # Use of this source code is governed by a BSD-style license that can be | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 import unittest | |
| 6 | |
| 7 import mock | |
| 8 | |
| 9 from infra_libs import experiments | |
| 10 | |
| 11 | |
| 12 class ExperimentsTest(unittest.TestCase): | |
| 13 def setUp(self): | |
| 14 self.mock_getfqdn = mock.patch('socket.getfqdn').start() | |
| 15 | |
| 16 def tearDown(self): | |
| 17 mock.patch.stopall() | |
| 18 | |
| 19 def test_is_active_for_host(self): | |
| 20 self.mock_getfqdn.return_value = 'vm122-m1' | |
| 21 | |
| 22 self.assertFalse(experiments.is_active_for_host('f1', 0)) | |
| 23 self.assertFalse(experiments.is_active_for_host('f2', 0)) | |
| 24 self.assertFalse(experiments.is_active_for_host('f3', 0)) | |
| 25 | |
| 26 self.assertTrue(experiments.is_active_for_host('f1', 50)) | |
| 27 self.assertFalse(experiments.is_active_for_host('f2', 50)) | |
| 28 self.assertTrue(experiments.is_active_for_host('f3', 50)) | |
| 29 | |
| 30 self.assertTrue(experiments.is_active_for_host('f1', 100)) | |
| 31 self.assertTrue(experiments.is_active_for_host('f2', 100)) | |
| 32 self.assertTrue(experiments.is_active_for_host('f3', 100)) | |
| 33 | |
| 34 self.mock_getfqdn.return_value = 'vm124-m1' | |
| 35 | |
| 36 self.assertFalse(experiments.is_active_for_host('f1', 0)) | |
| 37 self.assertFalse(experiments.is_active_for_host('f2', 0)) | |
| 38 self.assertFalse(experiments.is_active_for_host('f3', 0)) | |
| 39 | |
| 40 self.assertTrue(experiments.is_active_for_host('f1', 50)) | |
| 41 self.assertTrue(experiments.is_active_for_host('f2', 50)) | |
| 42 self.assertFalse(experiments.is_active_for_host('f3', 50)) | |
| 43 | |
| 44 self.assertTrue(experiments.is_active_for_host('f1', 100)) | |
| 45 self.assertTrue(experiments.is_active_for_host('f2', 100)) | |
| 46 self.assertTrue(experiments.is_active_for_host('f3', 100)) | |
| OLD | NEW |