Skip to content

Commit

Permalink
Tests
Browse files Browse the repository at this point in the history
Signed-off-by: tempate <[email protected]>
  • Loading branch information
Tempate committed Jan 8, 2024
1 parent db43dd2 commit b4b01e3
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima).
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Tests for the fastddsspy executable."""

import test_class


class TestCase_instance (test_class.TestCase):
"""@brief A subclass of `test_class.TestCase` representing a specific test case."""

def __init__(self):
"""
@brief Initialize the TestCase_instance object.
Launch this test with:
fastddsspy
AdvancedConfigurationExample publisher
"""
super().__init__(
name='TopicsDDSNoConfigCommand',
one_shot=True,
command=[],
dds=True,
config='',
arguments_dds=[],
arguments_spy=['topics'],
commands_spy=[],
output="""- name: HelloWorldTopic\n\
type: HelloWorld\n\
datawriters: 1\n\
datareaders: 0\n\
rate: %%rate%%\n"""
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima).
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Tests for the fastddsspy executable."""

import test_class


class TestCase_instance (test_class.TestCase):
"""@brief A subclass of `test_class.TestCase` representing a specific test case."""

def __init__(self):
"""
@brief Initialize the TestCase_instance object.
This test is launched with:
fastddsspy
>> topics
AdvancedConfigurationExample publisher
"""
super().__init__(
name='ToolShowTopicDDSCommand',
one_shot=False,
command=[],
dds=True,
config='',
arguments_dds=[],
arguments_spy=[],
commands_spy=['topic HelloWorldTopic'],
output=""">> \x1b[0m- name: HelloWorldTopic\n\
\n\
type: HelloWorld\n\
\n\
datawriters: 1\n\
\n\
datareaders: 0\n\
\n\
rate: %%rate%%\n"""
)
13 changes: 7 additions & 6 deletions fastddsspy_tool/test/application/test_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,13 @@ def valid_rate(self, rate) -> bool:
@param rate: The rate to check.
@return Returns True if the rate is valid, False otherwise.
"""
pattern_1 = r'^(\d*\.?\d*\s(Hz))$' # rate: 10.5 Hz
pattern_2 = r'^((inf)\s(Hz))$' # rate: inf Hz
if re.match(pattern_1, rate):
return True
if re.match(pattern_2, rate):
return True
pattern = r'^(\d+(\.\d+)?|inf)\sHz$' # rate: (10.5 | inf) Hz

match = re.match(pattern, rate)

if match:
return match.group(1) == "inf" or float(match.group(1)) > 0

print('Not valid rate: ')
print(rate)
return False
Expand Down

0 comments on commit b4b01e3

Please sign in to comment.