[chronojump/chronojump-importer] Uses internal difflib instead of external difflib.
- From: Carles Pina i Estany <carlespina src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump/chronojump-importer] Uses internal difflib instead of external difflib.
- Date: Mon, 5 Sep 2016 17:11:43 +0000 (UTC)
commit af8da4fb3bcdd8c0d941e1800851d9a2c8bf716f
Author: Carles Pina i Estany <carles pina cat>
Date: Mon Sep 5 18:00:03 2016 +0100
Uses internal difflib instead of external difflib.
src/chronojump-importer/chronojump_importer.py | 15 +++++++++------
.../chronojump_importer_test.py | 19 ++++++++++++++-----
.../tests/generic-expected-b.sqlite | Bin 58368 -> 61440 bytes
3 files changed, 23 insertions(+), 11 deletions(-)
---
diff --git a/src/chronojump-importer/chronojump_importer.py b/src/chronojump-importer/chronojump_importer.py
index 557e9db..62fd96a 100755
--- a/src/chronojump-importer/chronojump_importer.py
+++ b/src/chronojump-importer/chronojump_importer.py
@@ -5,6 +5,9 @@ import argparse
import sqlite3
import sys
import pprint
+import logging
+
+logging.basicConfig(level=logging.INFO)
def results_delete_column(column, results):
@@ -435,8 +438,8 @@ def update_session_ids(table, new_session_id):
def import_database(source_path, destination_path, source_session):
""" Imports the session source_session from source_db into destination_db """
- print("source path:", source_path)
- print("destination path:", destination_path)
+ logging.debug("source path:" + source_path)
+ logging.debug("destination path:" + destination_path)
source_db = open_database(source_path, read_only=True)
destination_db = open_database(destination_path, read_only=False)
@@ -453,9 +456,9 @@ def import_database(source_path, destination_path, source_session):
insert_data(cursor=destination_cursor, table_name="JumpType", data=jump_types,
matches_columns=get_column_names(destination_cursor, "JumpType", ["uniqueID"]))
- cursor = destination_db.cursor()
- cursor.execute("select * from jumptype")
- pprint.pprint(cursor.fetchall())
+ # cursor = destination_db.cursor()
+ # cursor.execute("select * from jumptype")
+ # pprint.pprint(cursor.fetchall())
#cursor.execute('INSERT INTO Jump
(weight,angle,tc,type,tv,fall,description,sessionID,personID,simulated) VALUES
("0","-1.0","0.0","Free","0.729703","0.0","","1","1","-1")')
#destination_db.commit()
@@ -554,7 +557,7 @@ def open_database(filename, read_only):
def execute_and_log(cursor, sql, comment = ""):
- print("SQL:", sql, comment)
+ logging.debug("SQL: {} -- {}".format(sql,comment))
cursor.execute(sql)
diff --git a/src/chronojump-importer/chronojump_importer_test.py
b/src/chronojump-importer/chronojump_importer_test.py
index d7af7dd..b7a9d14 100755
--- a/src/chronojump-importer/chronojump_importer_test.py
+++ b/src/chronojump-importer/chronojump_importer_test.py
@@ -6,6 +6,8 @@ import os
import subprocess
import tempfile
import shutil
+import difflib
+import pprint
class TestImporter(unittest.TestCase):
@@ -35,17 +37,24 @@ class TestImporter(unittest.TestCase):
shutil.copy("tests/{}".format(destination_file_name), destination_file_path)
shutil.copy("tests/{}".format(destination_file_name), original_destination_file_path)
- # command = "python3 ./chronojump_importer.py --source {} --destination {} --source_session
1".format(source_file_path, destination_file_path)
- # print("Command:", command)
- # os.system(command)
-
chronojump_importer.import_database(source_file_path, destination_file_path, 1)
os.system("echo .dump | sqlite3 {} > {}/destination.sql".format(destination_file_path,
self.temporary_directory_path))
os.system("echo .dump | sqlite3 tests/{} > {}/expected.sql".format(expected_file_name,
self.temporary_directory_path))
+ actual_file = open(self.temporary_directory_path + "/destination.sql")
+ expected_file = open(self.temporary_directory_path + "/expected.sql")
+
+ actual_dump = actual_file.readlines()
+ expected_dump = expected_file.readlines()
+
+ actual_file.close()
+ expected_file.close()
+
+ diff = difflib.unified_diff(actual_dump, expected_dump)
+ diff = "".join(diff)
+ print(diff)
command = "diff -u {}/destination.sql {}/expected.sql".format(self.temporary_directory_path,
self.temporary_directory_path)
- print("command:",command)
diff = subprocess.getoutput(command)
self.maxDiff = None
diff --git a/src/chronojump-importer/tests/generic-expected-b.sqlite
b/src/chronojump-importer/tests/generic-expected-b.sqlite
index ceab57c..d14d148 100644
Binary files a/src/chronojump-importer/tests/generic-expected-b.sqlite and
b/src/chronojump-importer/tests/generic-expected-b.sqlite differ
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]