From cb1e156c77d5a7a54695d88b5c9ac0ba910186c5 Mon Sep 17 00:00:00 2001
From: "Anders H. Rebner" <anderhre@stud.ntnu.no>
Date: Fri, 28 Feb 2020 09:15:55 +0100
Subject: [PATCH] =?UTF-8?q?#9=20Sm=C3=A5endringer=20i=20database.py=20og?=
 =?UTF-8?q?=20tilh=C3=B8rende=20test?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 soitool/database.py   | 13 ++++---------
 test/test_database.py |  4 ++--
 2 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/soitool/database.py b/soitool/database.py
index bd5078c..a797c0e 100644
--- a/soitool/database.py
+++ b/soitool/database.py
@@ -21,14 +21,13 @@ class Database():
     """Holds connection to database."""
 
     def __init__(self):
-        """Connect to existing db if found, creates new db if not."""
+        """Connect to existing db if found, create new db if not."""
         db_exists = os.path.exists(DBPATH)
 
         if db_exists:
-            print('connecting to existing DB.')
+            print('Connecting to existing DB.')
             self.conn = sqlite3.connect(DBPATH)
             print('DB-connection established.')
-            self.conn.row_factory = sqlite3.Row  # Enables row['columnName']
 
         else:
             print('Creating new DB.')
@@ -37,9 +36,8 @@ class Database():
             print('DB created.')
             self.fill_tables()
             print('Tables filled with data.')
-            self.conn.row_factory = sqlite3.Row  # Enables row['columnName']
 
-        self.categories = self.get_categories()
+        self.conn.row_factory = sqlite3.Row  # Enables row['columnName']
 
     def create_tables(self):
         """Create tables CodeBook, CategoryWords and ByHeart."""
@@ -103,7 +101,7 @@ class Database():
 
     def get_categories(self):
         """
-        Retrieve all categories from table CategoryWords.
+        Retrieve all categories from DB-table CategoryWords.
 
         Returns
         -------
@@ -117,6 +115,3 @@ class Database():
             categories.append(row['Category'])
 
         return categories
-
-
-# TEMP = Database()
diff --git a/test/test_database.py b/test/test_database.py
index 7edf8e8..6b52382 100644
--- a/test/test_database.py
+++ b/test/test_database.py
@@ -13,7 +13,7 @@ class DatabaseTest(unittest.TestCase):
     Parameters
     ----------
     unittest : Testcase
-        Used to subclass
+        DatabaseTest is subclass of TestCase
     """
 
     def setUp(self):
@@ -31,7 +31,7 @@ class DatabaseTest(unittest.TestCase):
         f = open(file_path, "r", encoding="utf-8")
         file_content = f.read()
 
-        # Retrieve number of expressions and expressions from file:
+        # Retrieve expressions from file:
         expressions = file_content.split("\n")[:-1]  # ignore bottom line
         no_of_expr = len(expressions)
 
-- 
GitLab