Esempio n. 1
0
 def test_processing_ok_no_deliveries(self):
     DetektorAssignment.objects.create(
         assignment_id=self.assignmentbuilder.assignment.id,
         processing_started_by=self.testuser)
     AssignmentParser(assignment_id=self.assignmentbuilder.assignment.id).run_detektor()
     detektorassignment = DetektorAssignment.objects.all()[0]
     self.assertEquals(detektorassignment.parseresults.count(), 0)
Esempio n. 2
0
 def setUp(self):
     assignmentbuilder = PeriodBuilder.quickadd_ducku_duck1010_active()\
         .add_assignment('testassignment')
     self.deliverybuilder = assignmentbuilder\
         .add_group()\
         .add_deadline_in_x_weeks(weeks=1)\
         .add_delivery()
     DetektorAssignment.objects.create(
         assignment=assignmentbuilder.assignment)
     self.assignmentparser = AssignmentParser(assignmentbuilder.assignment.id)
Esempio n. 3
0
    def test_get_unprocessed_delivery_queryset_none(self):
        delivery1builder = self.assignmentbuilder\
            .add_group()\
            .add_deadline_in_x_weeks(weeks=1)\
            .add_delivery()
        delivery1builder.add_filemeta(filename='Test.java', data='class Test {}')
        delivery2builder = self.assignmentbuilder\
            .add_group()\
            .add_deadline_in_x_weeks(weeks=1)\
            .add_delivery()
        delivery2builder.add_filemeta(filename='Test2.java', data='if(i==10) {}')

        DetektorAssignment.objects.create(
            assignment_id=self.assignmentbuilder.assignment.id,
            processing_started_by=self.testuser)

        assignmentparser = AssignmentParser(assignment_id=self.assignmentbuilder.assignment.id)
        DeliveryParser(assignmentparser, delivery1builder.delivery).run_detektor()
        DeliveryParser(assignmentparser, delivery2builder.delivery).run_detektor()
        self.assertEqual(assignmentparser.get_unprocessed_delivery_queryset().count(), 0)
Esempio n. 4
0
    def test_processing_ok_has_all_previous_results(self):
        delivery1builder = self.assignmentbuilder\
            .add_group()\
            .add_deadline_in_x_weeks(weeks=1)\
            .add_delivery()
        delivery1builder.add_filemeta(filename='Test.java', data='class Test {}')
        delivery2builder = self.assignmentbuilder\
            .add_group()\
            .add_deadline_in_x_weeks(weeks=1)\
            .add_delivery()
        delivery2builder.add_filemeta(filename='Test2.java', data='if(i==10) {}')

        detektorassignment = DetektorAssignment.objects.create(
            assignment_id=self.assignmentbuilder.assignment.id,
            processing_started_by=self.testuser)

        assignmentparser = AssignmentParser(assignment_id=self.assignmentbuilder.assignment.id)
        self.assertEquals(detektorassignment.parseresults.count(), 0)
        DeliveryParser(assignmentparser, delivery1builder.delivery).run_detektor()
        self.assertEquals(detektorassignment.parseresults.count(), 1)
        assignmentparser.run_detektor()
        self.assertEquals(detektorassignment.parseresults.count(), 2)
    def test_results_ordering(self):
        self.assignmentbuilder\
            .add_group(name='Group A')\
            .add_deadline_in_x_weeks(weeks=1)\
            .add_delivery()\
            .add_filemeta(filename='Test1.java', data='if(i==10) {}')
        self.assignmentbuilder\
            .add_group(name='Group B')\
            .add_deadline_in_x_weeks(weeks=1)\
            .add_delivery()\
            .add_filemeta(filename='Test2.java', data='class Test {if(i==10) {}}')
        self.assignmentbuilder\
            .add_group(name='Group C')\
            .add_deadline_in_x_weeks(weeks=1)\
            .add_delivery()\
            .add_filemeta(filename='Test3.java', data='class Test {}')
        detektorassignment = DetektorAssignment.objects.create(
            assignment_id=self.assignmentbuilder.assignment.id,
            processing_started_by=self.testuser)
        AssignmentParser(assignment_id=self.assignmentbuilder.assignment.id).run_detektor()
        CompareManyCollection(detektorassignment).save()

        request = self._create_mock_getrequest(data={
            'language': 'java'
        })
        response = AssignmentAssemblyView.as_view()(
            request, assignmentid=self.assignmentbuilder.assignment.id)
        response.render()

        displaynames = []
        for displayname1, displayname2 in zip(
                [span.text.strip() for span in
                 cssFind(response.content, '#detektorassembly-results .detektorassembly-delivery1-displayname')],
                [span.text.strip() for span in
                 cssFind(response.content, '#detektorassembly-results .detektorassembly-delivery2-displayname')]):
            displaynames.append({displayname1, displayname2})
        self.assertEqual(
            displaynames,
            [
                {'Group A', 'Group B'},
                {'Group A', 'Group C'},
            ])
Esempio n. 6
0
    def test_processing_ok_has_deliveries(self):
        self.assignmentbuilder\
            .add_group()\
            .add_deadline_in_x_weeks(weeks=1)\
            .add_delivery()\
            .add_filemeta(filename='Test.java', data='class Test {}')
        self.assignmentbuilder\
            .add_group()\
            .add_deadline_in_x_weeks(weeks=1)\
            .add_delivery()\
            .add_filemeta(filename='Test2.java', data='if(i==10) {}')

        DetektorAssignment.objects.create(
            assignment_id=self.assignmentbuilder.assignment.id,
            processing_started_by=self.testuser)
        AssignmentParser(assignment_id=self.assignmentbuilder.assignment.id).run_detektor()

        detektorassignment = DetektorAssignment.objects.all()[0]
        self.assertEquals(detektorassignment.parseresults.count(), 2)
        parseresults = detektorassignment.parseresults.order_by('number_of_operators')
        self.assertEquals(parseresults[0].get_operators_and_keywords_string(), 'class')
        self.assertEquals(parseresults[1].get_operators_and_keywords_string(), 'if==')
Esempio n. 7
0
 def test_processing_detektorassignment_doesnotexist(self):
     with self.assertRaises(DetektorAssignment.DoesNotExist):
         AssignmentParser(assignment_id=self.assignmentbuilder.assignment.id)
Esempio n. 8
0
 def test_invalid_assignment(self):
     with self.assertRaises(DetektorAssignment.DoesNotExist):
         AssignmentParser(assignment_id=200001)