def test_single_language_single_file(self): self.deliverybuilder.add_filemeta(filename='Test.java', data='class Test {}') self.assertEquals(DetektorDeliveryParseResult.objects.count(), 0) deliveryparser = DeliveryParser(self.assignmentparser, self.deliverybuilder.delivery) deliveryparser.run_detektor() self.assertEquals(DetektorDeliveryParseResult.objects.count(), 1) parseresult = DetektorDeliveryParseResult.objects.all()[0] self.assertEquals(parseresult.get_operators_and_keywords_string(), 'class') self.assertEquals(parseresult.get_number_of_keywords(), 1) self.assertEquals(parseresult.get_number_of_operators(), 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)
def test_multiple_languages(self): self.deliverybuilder.add_filemeta(filename='Test.java', data='class Test {}') self.deliverybuilder.add_filemeta(filename='test.py', data='class Test: pass') self.assertEquals(DetektorDeliveryParseResult.objects.count(), 0) deliveryparser = DeliveryParser(self.assignmentparser, self.deliverybuilder.delivery) deliveryparser.run_detektor() self.assertEquals(DetektorDeliveryParseResult.objects.count(), 2) parseresults = DetektorDeliveryParseResult.objects.order_by('language') parseresult_java = parseresults[0] parseresult_python = parseresults[1] self.assertEquals(parseresult_java.get_operators_and_keywords_string(), 'class') self.assertEquals(parseresult_java.get_number_of_keywords(), 1) self.assertEquals(parseresult_java.get_number_of_operators(), 0) self.assertEquals(parseresult_python.get_operators_and_keywords_string(), 'classpass') self.assertEquals(parseresult_python.get_number_of_keywords(), 2) self.assertEquals(parseresult_python.get_number_of_operators(), 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_no_filemetas(self): self.assertEquals(DetektorDeliveryParseResult.objects.count(), 0) deliveryparser = DeliveryParser(self.assignmentparser, self.deliverybuilder.delivery) deliveryparser.run_detektor() self.assertEquals(DetektorDeliveryParseResult.objects.count(), 0)