예제 #1
0
파일: test_utils.py 프로젝트: z0x010/eums
    def test_should_get_lists_intersection(self):
        source_list = [[1, 2, 3]]
        self.assertEqual(get_lists_intersection(source_list), [1, 2, 3])

        source_list.append([2, 3, 4])
        self.assertEqual(get_lists_intersection(source_list), [2, 3])

        source_list.append([3, 4, 5])
        self.assertEqual(get_lists_intersection(source_list), [3])
예제 #2
0
    def test_get_lists_intersection(self):
        source_list = [[1, 2, 3]]
        self.assertEqual(get_lists_intersection(source_list), [1, 2, 3])

        source_list.append([2, 3, 4])
        self.assertEqual(get_lists_intersection(source_list), [2, 3])

        source_list.append([3, 4, 5])
        self.assertEqual(get_lists_intersection(source_list), [3])
def filter_answers(request, nodes, questions):
    runs_list = []
    for key, value in questions.iteritems():
        param = request.GET.get(key)
        if param:
            runs = MultipleChoiceAnswer.objects.filter(question__label__in=value,
                                                       value__text__iexact=param,
                                                       run__status__in=('scheduled', 'completed'),
                                                       run__runnable__in=nodes).values_list('run_id')
            runs_list.append(runs)

    if runs_list:
        nodes = nodes.filter(run__in=get_lists_intersection(runs_list))

    return nodes
예제 #4
0
def filter_answers(request, nodes, questions):
    runs_list = []
    for key, value in questions.iteritems():
        param = request.GET.get(key)
        if param:
            runs = MultipleChoiceAnswer.objects.filter(
                question__label__in=value,
                value__text__iexact=param,
                run__status__in=('scheduled', 'completed'),
                run__runnable__in=nodes).values_list('run_id')
            runs_list.append(runs)

    if runs_list:
        nodes = nodes.filter(run__in=get_lists_intersection(runs_list))

    return nodes