示例#1
0
def test_get_item_list_with_empty_item_dictionary():
    item_list = test_api_utils.get_item_list(
        item_dictionary={},
        search_filter=predicates.always_true(),
        template_to_data=t2d)

    assert item_list == []
示例#2
0
def test_get_empty_item_list_with_unused_id(item_template_dictionary):
    original_dict = deepcopy(item_template_dictionary)
    item_list = test_api_utils.get_item_list(
        item_dictionary=item_template_dictionary,
        search_filter=filtering_utils.get_full_filter_predicate([451], [],
                                                                None),
        template_to_data=t2d,
    )

    assert item_list == []
    # Check nothing changed in the original dictionary
    assert_equal_template_dictionaries(item_template_dictionary, original_dict)
示例#3
0
def test_get_item_list_with_id_filter(item_template_dictionary):
    original_dict = deepcopy(item_template_dictionary)
    item_list = test_api_utils.get_item_list(
        item_dictionary=item_template_dictionary,
        search_filter=filtering_utils.get_full_filter_predicate([12, 34], [],
                                                                None),
        template_to_data=t2d,
    )

    assert_equal_data_lists(
        item_list,
        [
            t2d(item_template_dictionary["12"]),
            t2d(item_template_dictionary["34"]),
        ],
    )
    # Check nothing changed in the original dictionary
    assert_equal_template_dictionaries(item_template_dictionary, original_dict)
示例#4
0
    def _get_item_list(
        cls,
        project_dictionary: Dictionaries,
        filter_predicate: predicates.predicate,
    ) -> Iterable[EventData]:
        """
        Gets a list of possible events that can occur in the system and returns
        their details in an ID-sorted list.

        :param project_dictionary: The dictionary object for the project
            containing the event type definitions
        :param filter_predicate: Test API predicate used to filter shown events
        :return: List of EventData items that passed the filter
        """
        event_list = test_api_utils.get_item_list(
            item_dictionary=project_dictionary.event_id,
            search_filter=filter_predicate,
            template_to_data=EventData.get_empty_obj,
        )
        return event_list
示例#5
0
def test_valid_get_item_list(item_template_dictionary):
    original_dict = deepcopy(item_template_dictionary)
    item_list = test_api_utils.get_item_list(
        item_dictionary=item_template_dictionary,
        search_filter=predicates.always_true(),
        template_to_data=t2d,
    )

    # Test all items present AND in ID-sorted order
    assert_equal_data_lists(
        item_list,
        [
            t2d(item_template_dictionary["SURPRISE!"]),
            t2d(item_template_dictionary["12"]),
            t2d(item_template_dictionary["34"]),
            t2d(item_template_dictionary["56"]),
            t2d(item_template_dictionary["78"]),
        ],
    )
    # Check nothing changed in the original dictionary
    assert_equal_template_dictionaries(item_template_dictionary, original_dict)
示例#6
0
    def _get_item_list(
        cls,
        project_dictionary: Dictionaries,
        filter_predicate: predicates.predicate,
    ) -> Iterable[ChData]:
        """
        Gets a list of open telemetry channels in the system and prints their
        details out in an ID-sorted list.

        :param project_dictionary: The dictionary object for the project
            containing the channel type definitions
        :param filter_predicate: Test API predicate used to filter shown
            channels
        :return: List of channels that passed the filter
        """
        channel_list = test_api_utils.get_item_list(
            item_dictionary=project_dictionary.channel_id,
            search_filter=filter_predicate,
            template_to_data=ChData.get_empty_obj,
        )
        return channel_list
示例#7
0
    def _get_item_list(
        cls,
        project_dictionary: Dictionaries,
        filter_predicate: predicates.predicate,
    ) -> Iterable[CmdTemplate]:
        """
        Gets a list of available commands in the system and return them in an
        ID-sorted list.

        :param project_dictionary: The dictionary object for the project
            containing the command definitions
        :param filter_predicate: Test API predicate used to filter shown
            channels
        """
        # NOTE: Trying to create a blank CmdData causes errors, so currently
        # just using templates (i.e. this function does nothing)
        create_empty_command = lambda cmd_template: cmd_template

        command_list = test_api_utils.get_item_list(
            item_dictionary=project_dictionary.command_id,
            search_filter=filter_predicate,
            template_to_data=create_empty_command,
        )
        return command_list