def testInsert(self): unionFilter = QGalleryUnionFilter() metaDataFilter = QGalleryMetaDataFilter() intersectionFilter = QGalleryIntersectionFilter() unionFilter.append(metaDataFilter) unionFilter.append(metaDataFilter) unionFilter.append(intersectionFilter) unionFilter.append(metaDataFilter) # Inserts at the given position and shift the existing # filters, extending the filter list unionFilter.insert(1, intersectionFilter) unionFilter.insert(2, metaDataFilter) self.assertEqual(unionFilter.isEmpty(), False) self.assertEqual(unionFilter.filterCount(), 6) filters = unionFilter.filters() self.assertEqual(filters[0].type(), QGalleryFilter.MetaData) self.assertEqual(filters[1].type(), QGalleryFilter.Intersection) self.assertEqual(filters[2].type(), QGalleryFilter.MetaData) self.assertEqual(filters[3].type(), QGalleryFilter.MetaData) self.assertEqual(filters[4].type(), QGalleryFilter.Intersection) self.assertEqual(filters[5].type(), QGalleryFilter.MetaData)
def testPrependUnion(self): unionFilter = QGalleryUnionFilter() metaDataFilter = QGalleryMetaDataFilter() intersectionFilter = QGalleryIntersectionFilter() unionFilter.append(metaDataFilter) unionFilter.append(metaDataFilter) unionFilter.append(intersectionFilter) unionFilter.append(metaDataFilter) # Should append the *contents* of the union filter unionFilter.prepend(unionFilter) self.assertFalse(unionFilter.isEmpty()) self.assertEqual(unionFilter.filterCount(), 8) filters = unionFilter.filters() self.assertEqual(filters[0].type(), QGalleryFilter.MetaData) self.assertEqual(filters[1].type(), QGalleryFilter.MetaData) self.assertEqual(filters[2].type(), QGalleryFilter.Intersection) self.assertEqual(filters[3].type(), QGalleryFilter.MetaData) self.assertEqual(filters[4].type(), QGalleryFilter.MetaData) self.assertEqual(filters[5].type(), QGalleryFilter.MetaData) self.assertEqual(filters[6].type(), QGalleryFilter.Intersection) self.assertEqual(filters[7].type(), QGalleryFilter.MetaData)
def testReplace(self): unionFilter = QGalleryUnionFilter() metaDataFilter = QGalleryMetaDataFilter() intersectionFilter = QGalleryIntersectionFilter() unionFilter.append(metaDataFilter) unionFilter.append(intersectionFilter) unionFilter.append(metaDataFilter) unionFilter.append(intersectionFilter) unionFilter.clear() self.assertEqual(unionFilter.isEmpty(), True) self.assertEqual(unionFilter.filterCount(), 0)
def testMetaDataIntersection(self): metaDataFilter = QGalleryMetaDataFilter() intersectionFilter = QGalleryIntersectionFilter() intersectionFilter = metaDataFilter & intersectionFilter self.assertEqual(type(intersectionFilter), QGalleryIntersectionFilter) self.assertTrue(intersectionFilter.isValid(), True) self.assertFalse(intersectionFilter.isEmpty()) self.assertEqual(intersectionFilter.filterCount(), 1) filters = intersectionFilter.filters() self.assertEqual(len(filters), 1) self.assertEqual(filters[0].type(), QGalleryFilter.MetaData)
def testUnionMetaData(self): metaDataFilter = QGalleryMetaDataFilter() unionFilter = QGalleryUnionFilter() intersectionFilter = unionFilter & metaDataFilter self.assertEqual(type(intersectionFilter), QGalleryIntersectionFilter) self.assertTrue(intersectionFilter.isValid(), True) self.assertFalse(intersectionFilter.isEmpty()) self.assertEqual(intersectionFilter.filterCount(), 2) filters = intersectionFilter.filters() self.assertEqual(len(filters), 2) self.assertEqual(filters[0].type(), QGalleryFilter.Union) self.assertEqual(filters[1].type(), QGalleryFilter.MetaData)
def testAppendMetaData(self): unionFilter = QGalleryUnionFilter() metaDataFilter = QGalleryMetaDataFilter() intersectionFilter = QGalleryIntersectionFilter() unionFilter.append(metaDataFilter) unionFilter.append(metaDataFilter) unionFilter.append(intersectionFilter) unionFilter.append(metaDataFilter) self.assertFalse(unionFilter.isEmpty()) self.assertEqual(unionFilter.filterCount(), 4) filters = unionFilter.filters() self.assertEqual(len(filters), 4) self.assertEqual(filters[0].type(), QGalleryFilter.MetaData) self.assertEqual(filters[1].type(), QGalleryFilter.MetaData) self.assertEqual(filters[2].type(), QGalleryFilter.Intersection) self.assertEqual(filters[3].type(), QGalleryFilter.MetaData)
def testReplace(self): unionFilter = QGalleryUnionFilter() metaDataFilter = QGalleryMetaDataFilter() intersectionFilter = QGalleryIntersectionFilter() unionFilter.append(metaDataFilter) unionFilter.append(intersectionFilter) unionFilter.append(metaDataFilter) unionFilter.append(intersectionFilter) unionFilter.remove(0) unionFilter.remove(1) self.assertEqual(unionFilter.isEmpty(), False) self.assertEqual(unionFilter.filterCount(), 2) filters = unionFilter.filters() self.assertEqual(filters[0].type(), QGalleryFilter.Intersection) self.assertEqual(filters[1].type(), QGalleryFilter.Intersection)
def testMetaDataFilter(self): filt = QGalleryMetaDataFilter() self.assertTrue(filt.isValid()) self.assertEqual(filt.propertyName(), '') self.assertEqual(filt.value(), None) self.assertEqual(filt.comparator(), QGalleryFilter.Equals) self.assertFalse(filt.isNegated()) propertyName = 'album title' value = 'Greatest' comparator = QGalleryFilter.StartsWith negated = True filt.setPropertyName(propertyName) filt.setValue(value) filt.setComparator(comparator) filt.setNegated(negated) self.assertTrue(filt.isValid()) self.assertEqual(filt.propertyName(), propertyName) self.assertEqual(filt.value(), value) self.assertEqual(filt.comparator(), comparator) self.assertEqual(filt.isNegated(), negated)
def testCopyMetaData(self): metaDataFilter = QGalleryMetaDataFilter() filt = QGalleryFilter(metaDataFilter) self.assertTrue(filt.isValid()) self.assertEqual(filt.type(), QGalleryFilter.MetaData)