[chronojump/chronojump-importer] Adds a new unit test.
- From: Carles Pina i Estany <carlespina src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump/chronojump-importer] Adds a new unit test.
- Date: Wed, 7 Sep 2016 18:54:13 +0000 (UTC)
commit aecf2cb8ef4fc0cfdc5c7ddf2cbfe7e5a0824b99
Author: Carles Pina i Estany <carles pina cat>
Date: Wed Sep 7 19:53:38 2016 +0100
Adds a new unit test.
This is the first unit test creating a database, might be refactored
later on.
.../chronojump_importer_test.py | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/src/chronojump-importer/chronojump_importer_test.py
b/src/chronojump-importer/chronojump_importer_test.py
index abda1a3..150f22f 100755
--- a/src/chronojump-importer/chronojump_importer_test.py
+++ b/src/chronojump-importer/chronojump_importer_test.py
@@ -9,6 +9,7 @@ import shutil
import difflib
import ddt
import pprint
+import sqlite3
@ddt.ddt
class TestImporter(unittest.TestCase):
@@ -102,5 +103,21 @@ class TestImporter(unittest.TestCase):
self.assertTrue({'name': 'mark', 'personId': 12} in actual)
self.assertTrue({'name': 'alex', 'personId': 5} in actual)
+ def test_get_column_names(self):
+ filename = tempfile.mktemp(prefix="chronojump_importer_test_get_column_", suffix=".sqlite")
+ open(filename, 'a').close()
+
+ database = chronojump_importer.open_database(filename, read_only=False)
+ cursor = database.cursor()
+
+ cursor.execute("CREATE TABLE test (uniqueID INTEGER, name TEXT, surname1 TEXT, surname2 TEXT, age
INTEGER)")
+
+ columns = chronojump_importer.get_column_names(cursor=cursor, table="test",
skip_columns=["surname1", "surname2"])
+
+ self.assertEqual(columns, ["uniqueID", "name", "age"])
+
+ database.close()
+ os.remove(filename)
+
if __name__ == '__main__':
unittest.main()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]