~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/registry/tests/test_distroseriesdifference.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-08-16 13:03:42 UTC
  • mfrom: (13687.3.5 bug-826659)
  • Revision ID: launchpad@pqm.canonical.com-20110816130342-7b2z6s7ks2p39exq
[r=lifeless,
        wallyworld][bug=826659] Don't filter DSDs by type if no type filter
        is given.

Show diffs side-by-side

added added

removed removed

Lines of Context:
967
967
        diffs = {
968
968
            'normal': [],
969
969
            'unique': [],
 
970
            'missing': [],
970
971
            'ignored': [],
971
972
            }
972
973
        diffs['normal'].append(
978
979
                parent_series=parent_series,
979
980
                difference_type=(
980
981
                    DistroSeriesDifferenceType.UNIQUE_TO_DERIVED_SERIES)))
 
982
        diffs['missing'].append(
 
983
            self.factory.makeDistroSeriesDifference(
 
984
                derived_series=derived_series,
 
985
                parent_series=parent_series,
 
986
                difference_type=(
 
987
                    DistroSeriesDifferenceType.MISSING_FROM_DERIVED_SERIES)))
981
988
        diffs['ignored'].append(
982
989
            self.factory.makeDistroSeriesDifference(
983
990
                derived_series=derived_series,
1029
1036
            derived_series)
1030
1037
 
1031
1038
        self.assertContentEqual(
1032
 
            diffs['normal'], result)
 
1039
            diffs['normal'] + diffs['unique'] + diffs['missing'], result)
1033
1040
 
1034
1041
    def test_getForDistroSeries_filters_by_distroseries(self):
1035
1042
        # Differences for other series are not included.
1042
1049
 
1043
1050
        self.assertFalse(diff_for_other_series in results)
1044
1051
 
 
1052
    def test_getForDistroSeries_does_not_filter_dsd_type_by_default(self):
 
1053
        # If no difference_type is given, getForDistroSeries returns
 
1054
        # DSDs of all types (missing in derived series, different
 
1055
        # versions, or unique to derived series).
 
1056
        derived_series = self.makeDerivedSeries()
 
1057
        dsds = [
 
1058
            self.factory.makeDistroSeriesDifference(
 
1059
                derived_series, difference_type=diff_type)
 
1060
            for diff_type in DistroSeriesDifferenceType.items]
 
1061
        dsd_source = getUtility(IDistroSeriesDifferenceSource)
 
1062
        self.assertContentEqual(
 
1063
            dsds, dsd_source.getForDistroSeries(derived_series))
 
1064
 
1045
1065
    def test_getForDistroSeries_filters_by_type(self):
1046
1066
        # Only differences for the specified types are returned.
1047
1067
        derived_series = self.makeDerivedSeries()
1067
1087
    def test_getForDistroSeries_filters_by_multiple_statuses(self):
1068
1088
        # Multiple statuses can be passed for filtering.
1069
1089
        derived_series = self.makeDerivedSeries()
1070
 
        diffs = self.makeDiffsForDistroSeries(derived_series)
1071
 
 
1072
 
        result = getUtility(IDistroSeriesDifferenceSource).getForDistroSeries(
1073
 
            derived_series,
1074
 
            status=(
1075
 
                DistroSeriesDifferenceStatus.BLACKLISTED_CURRENT,
1076
 
                DistroSeriesDifferenceStatus.NEEDS_ATTENTION,
1077
 
                ))
1078
 
 
1079
 
        self.assertContentEqual(diffs['normal'] + diffs['ignored'], result)
 
1090
        for status in DistroSeriesDifferenceStatus.items:
 
1091
            self.factory.makeDistroSeriesDifference(
 
1092
                derived_series, status=status)
 
1093
 
 
1094
        statuses = (
 
1095
            DistroSeriesDifferenceStatus.BLACKLISTED_CURRENT,
 
1096
            DistroSeriesDifferenceStatus.NEEDS_ATTENTION,
 
1097
            )
 
1098
 
 
1099
        dsd_source = getUtility(IDistroSeriesDifferenceSource)
 
1100
        self.assertContentEqual(
 
1101
            statuses, [
 
1102
                dsd.status
 
1103
                for dsd in dsd_source.getForDistroSeries(
 
1104
                    derived_series, status=statuses)])
1080
1105
 
1081
1106
    def test_getForDistroSeries_matches_by_package_name(self):
1082
1107
        dsd = self.factory.makeDistroSeriesDifference()
1137
1162
 
1138
1163
    def test_getForDistroSeries_filters_by_parent(self):
1139
1164
        # The differences can be filtered by parent series.
1140
 
        dsp = self.factory.makeDistroSeriesParent()
1141
 
        derived_series = dsp.derived_series
1142
 
        parent_series = dsp.parent_series
1143
 
 
1144
 
        # Add another parent to this series.
1145
 
        parent_series2 = self.factory.makeDistroSeriesParent(
1146
 
            derived_series=derived_series).parent_series
1147
 
 
1148
 
        diffs = self.makeDiffsForDistroSeries(
1149
 
            derived_series, parent_series=parent_series)
1150
 
        diffs2 = self.makeDiffsForDistroSeries(
1151
 
            derived_series, parent_series=parent_series2)
1152
 
 
1153
 
        results = getUtility(
1154
 
            IDistroSeriesDifferenceSource).getForDistroSeries(
1155
 
                derived_series, parent_series=parent_series)
1156
 
        results2 = getUtility(
1157
 
            IDistroSeriesDifferenceSource).getForDistroSeries(
1158
 
                derived_series, parent_series=parent_series2)
1159
 
 
1160
 
        self.assertContentEqual(diffs['normal'], results)
1161
 
        self.assertContentEqual(diffs2['normal'], results2)
 
1165
        derived_series = self.factory.makeDistroSeries()
 
1166
        dsps = [
 
1167
            self.factory.makeDistroSeriesParent(derived_series=derived_series)
 
1168
            for counter in xrange(2)]
 
1169
        dsds = [
 
1170
            self.factory.makeDistroSeriesDifference(
 
1171
                parent_series=dsp.parent_series,
 
1172
                derived_series=derived_series)
 
1173
            for dsp in dsps]
 
1174
        dsd_source = getUtility(IDistroSeriesDifferenceSource)
 
1175
        self.assertContentEqual(
 
1176
            [dsds[0]],
 
1177
            dsd_source.getForDistroSeries(
 
1178
                derived_series, parent_series=dsps[0].parent_series))
1162
1179
 
1163
1180
    def test_getForDistroSeries_matches_packageset(self):
1164
1181
        dsd = self.factory.makeDistroSeriesDifference()