def check_sources(self, expected_sources=None):
        """Check what sources are set in payload.

        :param expected_sources: list of expected sources after trying to set;
                                 including when exception raised
        :type expected_sources: list of source instances
        """
        expected_paths = PayloadSourceContainer.to_object_path_list(
            expected_sources)

        self._test.assertEqual(self.payload_interface.Sources, expected_paths)
    def set_sources(self, test_sources, exception=None):
        """Set sources to payload.

        :param test_sources: list of sources for emptiness failed check
        :type test_sources: list of source instances
        :param exception: exception class which will be raised for the given sources
        :return: caught exception if exception raised
        """
        paths = PayloadSourceContainer.to_object_path_list(test_sources)

        if exception:
            with self._test.assertRaises(exception) as cm:
                self.payload_interface.SetSources(paths)
            return cm

        self.payload_interface.SetSources(paths)
        return None
    def check_set_sources(self, test_sources, exception=None):
        """Default check to set sources.

        :param test_sources: list of sources for emptiness failed check
        :param exception: exception class which will be raised for the given sources
        """
        paths = PayloadSourceContainer.to_object_path_list(test_sources)

        if exception:
            with self._test.assertRaises(exception):
                self.payload_interface.SetSources(paths)

            self._test.assertEqual(self.payload_interface.Sources, [])
            self._test.assertFalse(self.payload_interface.HasSource())
        else:
            self.payload_interface.SetSources(paths)

            self._test.assertEqual(self.payload_interface.Sources, paths)
            self._test.assertTrue(self.payload_interface.HasSource())
 def Sources(self) -> List[ObjPath]:
     """Get list of sources attached to this payload."""
     return PayloadSourceContainer.to_object_path_list(
         self.implementation.sources
     )