Exemple #1
0
 def test_find_non_existent(self,
                            base: str = 'Vehicle.Cabin',
                            extra: str = 'Foo') -> None:
     with self.assertRaisesRegex(
             VSSBranchError,
             f'branch {base!r} has no such child {extra!r}'):
         find_signal(f'{base}.{extra}')
Exemple #2
0
 def test_find_past_leaf(self,
                         base: str = 'Vehicle.AverageSpeed',
                         extra: str = 'FooBar') -> None:
     with self.assertRaisesRegex(
             VSSBranchError,
             f"attempted to follow branch {extra!r} from leaf node {base!r}"
     ):
         find_signal(f'{base}.{extra}')
     with self.assertRaisesRegex(
             VSSBranchError,
             f"attempted to follow branch {extra!r} from leaf node {base!r}"
     ):
         find_signal(tuple(base.split('.')) + (extra, ))
Exemple #3
0
 def test_illegal_args(self):
     with self.assertRaisesRegex(TypeError, 'name.*str.*got int'):
         find_signal(1)
     with self.assertRaisesRegex(TypeError, 'name.*str.*got None'):
         find_signal(None)
     with self.assertRaisesRegex(TypeError, 'spec.*Dict.*got int'):
         find_signal('abc', 1)
Exemple #4
0
 def test_empty_root(self) -> None:
     with self.assertRaisesRegex(VSSBranchError,
                                 "no such domain 'Vehicle'"):
         find_signal('Vehicle.Foo.Bar', {})
     with self.assertRaisesRegex(VSSBranchError,
                                 "no such domain 'Vehicle'"):
         find_signal(('Vehicle', 'Foo', 'Bar'), {})
     with self.assertRaisesRegex(VSSBranchError, "no such domain 'Bar'"):
         find_signal(('Bar', 'Baz', 'Qux'), {})
Exemple #5
0
 def test_find_branch(self, namespace: str = 'Vehicle.Cabin.HVAC'):
     with self.assertRaisesRegex(
             VSSBranchError,
             f'node {namespace!r} is a branch, not a signal'):
         find_signal(namespace)
Exemple #6
0
 def test_empty_namespace(self) -> None:
     with self.assertRaisesRegex(ValueError,
                                 'namespace must contain at least one key'):
         find_signal(())
     with self.assertRaisesRegex(ValueError,
                                 'namespace must contain at least one key'):
         find_signal('')
     with self.assertRaisesRegex(ValueError,
                                 'namespace cannot contain an empty key'):
         find_signal('.')
     with self.assertRaisesRegex(ValueError,
                                 'namespace cannot contain an empty key'):
         find_signal('Foo.Bar..Baz')
     with self.assertRaisesRegex(ValueError,
                                 'namespace cannot contain an empty key'):
         find_signal('Foo.Bar.Baz.')
     with self.assertRaisesRegex(ValueError,
                                 'namespace cannot contain an empty key'):
         find_signal('.Foo.Bar.Baz')
     with self.assertRaisesRegex(ValueError,
                                 'namespace cannot contain an empty key'):
         find_signal(('Foo', '', 'Baz'))
Exemple #7
0
 def test_find_avg_speed_str(self) -> None:
     self._assert_is_avg_speed(find_signal('Vehicle.AverageSpeed'))
Exemple #8
0
 def test_signal_with_ratio_unit() -> None:
     find_signal('Vehicle.OBD.CommandedEquivalenceRatio')
Exemple #9
0
 def test_signal_with_kpa_unit() -> None:
     find_signal('Vehicle.Powertrain.CombustionEngine.Engine.MAP')