Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(376)

Side by Side Diff: infra_libs/test/experiments_test.py

Issue 2213143002: Add infra_libs as a bootstrap dependency. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Removed the ugly import hack Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698