blob: 647059ee3c769a6ec4e0d1bbe65b3aa64e202731 [file] [log] [blame]
Wei-Yu Chenad55cb82022-02-15 20:07:01 +08001# SPDX-FileCopyrightText: 2020 The Magma Authors.
2# SPDX-FileCopyrightText: 2022 Open Networking Foundation <support@opennetworking.org>
3#
4# SPDX-License-Identifier: BSD-3-Clause
Wei-Yu Chen49950b92021-11-08 19:19:18 +08005
6# pylint: disable=protected-access
7from unittest import TestCase
8
9from data_models.transform_for_magma import bandwidth, gps_tr181
10from exceptions import ConfigurationError
11
12
13class TransformForMagmaTests(TestCase):
14 def test_gps_tr181(self) -> None:
15 # Negative longitude
16 inp = '-122150583'
17 out = gps_tr181(inp)
18 expected = '-122.150583'
19 self.assertEqual(out, expected, 'Should convert negative longitude')
20
21 inp = '122150583'
22 out = gps_tr181(inp)
23 expected = '122.150583'
24 self.assertEqual(out, expected, 'Should convert positive longitude')
25
26 inp = '0'
27 out = gps_tr181(inp)
28 expected = '0.0'
29 self.assertEqual(out, expected, 'Should leave zero as zero')
30
31 def test_bandwidth(self) -> None:
32 inp = 'n6'
33 out = bandwidth(inp)
34 expected = 1.4
35 self.assertEqual(out, expected, 'Should convert RBs')
36
37 inp = 1.4
38 out = bandwidth(inp)
39 expected = 1.4
40 self.assertEqual(out, expected, 'Should accept MHz')
41
42 with self.assertRaises(ConfigurationError):
43 inp = 'asdf'
44 bandwidth(inp)
45
46 with self.assertRaises(ConfigurationError):
47 inp = 1234
48 bandwidth(inp)