From 5db68857f35d5aa40ed0d59306758453dfe16e47 Mon Sep 17 00:00:00 2001
From: Piotr Gawron <piotr.gawron@uni.lu>
Date: Thu, 30 Nov 2017 14:17:36 +0100
Subject: [PATCH] unit test that checks if ordering by invalid sort column
 doesn't crash

---
 smash/web/api_views/subject.py            | 2 +-
 smash/web/tests/api_views/test_subject.py | 5 ++++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/smash/web/api_views/subject.py b/smash/web/api_views/subject.py
index e26ae352..b96a452f 100644
--- a/smash/web/api_views/subject.py
+++ b/smash/web/api_views/subject.py
@@ -95,7 +95,7 @@ def get_subjects_order(subjects_to_be_ordered, order_column, order_direction):
     elif order_column == "visit_8":
         result = order_by_visit(subjects_to_be_ordered, order_direction, 8)
     else:
-        logger.warn("Unknown sort column: " + order_column)
+        logger.warn("Unknown sort column: " + str(order_column))
     return result
 
 
diff --git a/smash/web/tests/api_views/test_subject.py b/smash/web/tests/api_views/test_subject.py
index b1321d56..672266db 100644
--- a/smash/web/tests/api_views/test_subject.py
+++ b/smash/web/tests/api_views/test_subject.py
@@ -368,7 +368,7 @@ class TestApi(TestCase):
     def test_subjects_filter_visit_1_SHOULD_BE_IN_PROGRESS(self):
         subject = self.study_subject
 
-        visit = create_visit(subject)
+        create_visit(subject)
 
         self.check_subject_filtered([["visit_1", "SHOULD_BE_IN_PROGRESS"]], [subject])
         self.check_subject_filtered([["visit_2", "SHOULD_BE_IN_PROGRESS"]], [])
@@ -421,3 +421,6 @@ class TestApi(TestCase):
         appointment.save()
 
         self.check_subject_ordered("visit_1", [subject, subject2])
+
+    def test_invalid_order(self):
+        self.check_subject_ordered(None, [self.study_subject])
-- 
GitLab