• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2#
3#   Copyright 2020 - The Android Open Source Project
4#
5#   Licensed under the Apache License, Version 2.0 (the "License");
6#   you may not use this file except in compliance with the License.
7#   You may obtain a copy of the License at
8#
9#       http://www.apache.org/licenses/LICENSE-2.0
10#
11#   Unless required by applicable law or agreed to in writing, software
12#   distributed under the License is distributed on an "AS IS" BASIS,
13#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14#   See the License for the specific language governing permissions and
15#   limitations under the License.
16
17import unittest
18
19import mock
20
21from acts.controllers import monsoon
22from acts.controllers.monsoon_lib.api.hvpm.monsoon import Monsoon as HvpmMonsoon
23from acts.controllers.monsoon_lib.api.lvpm_stock.monsoon import Monsoon as LvpmStockMonsoon
24
25
26@mock.patch('acts.controllers.monsoon_lib.api.lvpm_stock.monsoon.MonsoonProxy')
27@mock.patch('acts.controllers.monsoon_lib.api.hvpm.monsoon.HVPM')
28class MonsoonTest(unittest.TestCase):
29    """Tests the acts.controllers.iperf_client module functions."""
30    def test_create_can_create_lvpm_from_id_only(self, *_):
31        monsoons = monsoon.create([12345])
32        self.assertIsInstance(monsoons[0], LvpmStockMonsoon)
33
34    def test_create_can_create_lvpm_from_dict(self, *_):
35        monsoons = monsoon.create([{'type': 'LvpmStockMonsoon', 'serial': 10}])
36        self.assertIsInstance(monsoons[0], LvpmStockMonsoon)
37        self.assertEqual(monsoons[0].serial, 10)
38
39    def test_create_can_create_hvpm_from_id_only(self, *_):
40        monsoons = monsoon.create([23456])
41        self.assertIsInstance(monsoons[0], HvpmMonsoon)
42
43    def test_create_can_create_hvpm_from_dict(self, *_):
44        monsoons = monsoon.create([{'type': 'HvpmMonsoon', 'serial': 10}])
45        self.assertIsInstance(monsoons[0], HvpmMonsoon)
46        self.assertEqual(monsoons[0].serial, 10)
47
48    def test_raises_error_if_monsoon_type_is_unknown(self, *_):
49        with self.assertRaises(ValueError):
50            monsoon.create([{'type': 'UNKNOWN', 'serial': 10}])
51
52    def test_raises_error_if_monsoon_serial_not_provided(self, *_):
53        with self.assertRaises(ValueError):
54            monsoon.create([{'type': 'LvpmStockMonsoon'}])
55
56
57if __name__ == '__main__':
58    unittest.main()
59