def test_stats(self):
     self.assertEqual(
         evaluate_dataset_and_provide_stats(self.rankings_str1)['invalid'],
         True)
     self.assertEqual(
         evaluate_dataset_and_provide_stats(self.rankings_str2)['invalid'],
         True)
Example #2
0
 def test_9(self):
     evaluation = evaluate_dataset_and_provide_stats(
         cleanup_dataset(self.rankings_9).split("\n"))
     assert evaluation["n"] == 2
     assert evaluation["m"] == 2
     assert not evaluation["complete"]
     assert not evaluation["invalid"]
def sound_dataset_validator(value):
    evaluation = evaluate_dataset_and_provide_stats(value.split('\n'))
    if evaluation['invalid']:
        raise ValidationError(
            "content attribute must contains a valid dataset: %s" % ', '.join([
                'line %i: %s' % (k, v)
                for k, v in evaluation["invalid_rankings_id"].items()
            ]), )
    return evaluation
Example #4
0
def dataset_evaluate(request):
    if request.method != 'POST':
        return HttpResponseBadRequest()
    dataset_evaluation = evaluate_dataset_and_provide_stats(
        request.POST.get("dataset").split("\n"))
    dataset_evaluation["has_homonym"] = DataSet.objects \
        .filter(Q(owner=request.user) | Q(public=True)) \
        .filter(name=request.POST.get("name")) \
        .exists()
    return JsonResponse(dataset_evaluation)
Example #5
0
 def test_2(self):
     evaluation = evaluate_dataset_and_provide_stats(self.rankings_2)
     assert evaluation["n"] == 2
     assert evaluation["m"] == 2
     assert evaluation["complete"]
     assert not evaluation["invalid"]
Example #6
0
 def test_5(self):
     evaluation = evaluate_dataset_and_provide_stats(self.rankings_5)
     assert evaluation["invalid"]