def _test_units_checks_filter(qs, check_type, check_data): result = UnitChecksFilter(qs, **{check_type: check_data}).filter("checks") for item in result: assert item in qs assert result.count() == result.distinct().count() if check_type == "checks": for item in result: assert any( qc in item.qualitycheck_set.values_list("name", flat=True) for qc in check_data) assert( list(result) == list( qs.filter( qualitycheck__false_positive=False, qualitycheck__name__in=check_data).distinct())) else: for item in result: item.qualitycheck_set.values_list("category", flat=True) if check_data: assert( list(result) == list( qs.filter( qualitycheck__false_positive=False, qualitycheck__category=check_data).distinct())) else: assert( list(result) == list( qs.filter( qualitycheck__false_positive=False).distinct()))
def _test_units_checks_filter(qs, check_type, check_data): result = UnitChecksFilter(qs, **{check_type: check_data}).filter("checks") for item in result: assert item in qs assert result.count() == result.distinct().count() if check_type == "checks": for item in result: assert any( qc in item.qualitycheck_set.values_list("name", flat=True) for qc in check_data) assert( list(result) == list( qs.filter( qualitycheck__false_positive=False, qualitycheck__name__in=check_data).distinct())) else: for item in result: item.qualitycheck_set.values_list("category", flat=True) assert( list(result) == list( qs.filter( qualitycheck__false_positive=False, qualitycheck__category=check_data).distinct()))
def test_units_checks_filter_bad(): qs = Unit.objects.all() with pytest.raises(FilterNotFound): UnitChecksFilter(qs).filter("BAD") # if you dont supply check/category you get all checks assert ( UnitChecksFilter(qs).filter('checks').count() == Unit.objects.filter(qualitycheck__false_positive=False).distinct().count() )
def test_units_checks_filter_bad(): qs = Unit.objects.all() with pytest.raises(FilterNotFound): UnitChecksFilter(qs).filter("BAD") # if you dont supply check/category you get empty qs assert not UnitChecksFilter(qs).filter("checks").count()