blob: 1a526318da9c13c1360f7ec59717addcb5a010f9 [file] [log] [blame]
Tan Gao4e7d14b2013-06-13 11:54:44 -07001#!/usr/bin/python
2#
3# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7"""Unit tests for server/site_attenuator.py."""
8
9import unittest
10
11from autotest_lib.server import site_attenuator
12
13
14class ApproximateFrequencyTest(unittest.TestCase):
15 """Unit tests for site_attenuator._approximate_frequency()."""
16
17 def _run(self, test_freq, expected):
18 actual = site_attenuator.Attenuator._approximate_frequency(test_freq)
19 self.assertEquals(actual, expected)
20
21
22 def testApproximateFrequency_2GhzReturnsHigherValue(self):
23 """Tests a higher frequency is returned as an approximate in 2GHz."""
24 self._run(2412, 2437) # Channel 1. Expect return of channel 6
25
26
27 def testApproximateFrequency_2GhzReturnsLowerValue(self):
28 """Tests a lower frequency is returned as an approximate in 2GHz."""
29 self._run(2462, 2437) # Channel 11. Expect return of channel 6
30
31
32 def testApproximateFrequency_5GhzReturnsHigherValue(self):
33 """Tests a higher frequency is returned as an approximate in 5GHz."""
34 self._run(5200, 5220) # Channel 40. Expect return of channel 44
35
36 def testApproximateFrequency_5GhzReturnsLowerValue(self):
37 """Tests a lower frequency is returned as an approximate in 5GHz."""
38 self._run(5785, 5765) # Channel 157. Expect return of channel 153