Source code for meta_package_manager.tests.test_platforms
# Copyright Kevin Deldycke <kevin@deldycke.com> and contributors.## This program is Free Software; you can redistribute it and/or# modify it under the terms of the GNU General Public License# as published by the Free Software Foundation; either version 2# of the License, or (at your option) any later version.## This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# GNU General Public License for more details.## You should have received a copy of the GNU General Public License# along with this program; if not, write to the Free Software# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.from__future__importannotationsfromitertoolsimportcombinationsfromclick_extra.platformsimportALL_PLATFORMS,Groupfrommeta_package_manager.platformsimportPLATFORM_GROUPSfrom.conftestimportall_managers
[docs]deftest_unique_ids():"""IDs must be unique."""all_group_ids={g.idforginPLATFORM_GROUPS}assertlen(all_group_ids)==len(PLATFORM_GROUPS)
[docs]deftest_platform_groups_no_overlap():"""Check our platform groups are mutually exclusive."""forcombinationincombinations(PLATFORM_GROUPS,2):assertcombination[0].isdisjoint(combination[1])
[docs]@all_managersdeftest_all_platforms_covered_by_groups(manager):"""Check all platforms supported by managers are covered by a local group."""leftover_platforms=manager.platforms.copy()forgroupinPLATFORM_GROUPS:# Check the group fully overlap the manager platforms.ifnotgroup.isdisjoint(manager.platforms):assertgroup.issubset(manager.platforms)# Remove the group platforms from the uncovered list.leftover_platforms-=set(group.platforms)assertlen(leftover_platforms)==0
# At this stage we know all platforms of the manager can be partitioned by a# combination of PLATFORM_GROUPS elements, without any overlap or leftover.