From c9d4da3c36bc1a340a37a40046b277eadf3f5df9 Mon Sep 17 00:00:00 2001
From: Jacek Lebioda <jacek.lebioda@uni.lu>
Date: Tue, 6 Oct 2020 19:05:17 +0200
Subject: [PATCH] fix: some test fixes

---
 smash/web/importer/csv_tns_visit_import_reader.py | 1 +
 smash/web/tests/test_process_file.py              | 2 +-
 smash/web/tests/view/test_configuration.py        | 8 ++++----
 smash/web/tests/view/test_statistics.py           | 4 ++--
 4 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/smash/web/importer/csv_tns_visit_import_reader.py b/smash/web/importer/csv_tns_visit_import_reader.py
index ffe50d78..1d844fbc 100644
--- a/smash/web/importer/csv_tns_visit_import_reader.py
+++ b/smash/web/importer/csv_tns_visit_import_reader.py
@@ -328,4 +328,5 @@ class TnsCsvVisitImportReader:
 
 
 def remove_bom(line):
+    line = line.decode('utf8')
     return line[3:] if line.startswith(codecs.BOM_UTF8) else line
diff --git a/smash/web/tests/test_process_file.py b/smash/web/tests/test_process_file.py
index c2d428d8..8d392026 100644
--- a/smash/web/tests/test_process_file.py
+++ b/smash/web/tests/test_process_file.py
@@ -30,7 +30,7 @@ class TestDocxProcessor(TestCase):
             "##ADDRESS2##": "61-234, Poznan",
             "##COUNTRY##": "POLAND",
             "##CONTENT##": "1",
-            "##DATE##": datetime.datetime.now().date().strftime("%A %d %B %Y").decode(date_format_encoding()),
+            "##DATE##": datetime.datetime.now().date().strftime("%A %d %B %Y"),
         }
         process_file(template_path, output_path, changes)
         self.assertTrue(os.path.isfile(output_path))
diff --git a/smash/web/tests/view/test_configuration.py b/smash/web/tests/view/test_configuration.py
index 49a32739..4d9c0196 100644
--- a/smash/web/tests/view/test_configuration.py
+++ b/smash/web/tests/view/test_configuration.py
@@ -5,14 +5,14 @@ from web.tests import LoggedInTestCase
 import logging
 logger = logging.getLogger(__name__)
 
+
 class ConfigurationViewTests(LoggedInTestCase):
     def test_visit_details_request(self):
-    	self.login_as_admin()
+        self.login_as_admin()
         response = self.client.get(reverse('web.views.configuration'))
-
         self.assertEqual(response.status_code, 200)
-
+        
     def test_visit_details_request_without_permissions(self):
-    	self.login_as_staff()
+        self.login_as_staff()
         response = self.client.get(reverse('web.views.configuration'))
         self.assertEqual(response.status_code, 302)
diff --git a/smash/web/tests/view/test_statistics.py b/smash/web/tests/view/test_statistics.py
index aa7fee20..c017934b 100644
--- a/smash/web/tests/view/test_statistics.py
+++ b/smash/web/tests/view/test_statistics.py
@@ -15,10 +15,10 @@ class TestStatisticsView(LoggedInTestCase):
         response = self.client.get(url)
         self.assertEqual(response.status_code, 200)
         current_month = datetime.now().month - 1 or 12
-        content = response.content
+        content = response.content.decode('utf8')
         self.assertIn('<option value="{}" selected>'.format(current_month), content)
         response = self.client.get(url, {"month": 10, "year": 2017, "subject_type": -1, "visit": -1})
-        content = response.content
+        content = response.content.decode('utf8')
         self.assertIn('<option value="10" selected>October', content)
 
     def test_statistics_request_without_permission(self):
-- 
GitLab