From 5530a7a8ff1360a0517cf1cc994283fe6f17732e Mon Sep 17 00:00:00 2001 From: Chris Kerr Date: Tue, 2 Apr 2019 22:05:41 +0200 Subject: [PATCH] Add a simple test for loading Arbin .res files --- tests/test_Arbin.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 tests/test_Arbin.py diff --git a/tests/test_Arbin.py b/tests/test_Arbin.py new file mode 100644 index 0000000..9ceec8e --- /dev/null +++ b/tests/test_Arbin.py @@ -0,0 +1,26 @@ +"""Tests for loading Arbin .res files.""" + +import os +import sqlite3 +import subprocess + +import pytest + +from galvani import res2sqlite + + +# TODO - change to subprocess.DEVNULL when python 2 support is removed +have_mdbtools = (subprocess.call(['which', 'mdb-export'], stdout=None) == 0) + + +@pytest.mark.skipif(not have_mdbtools, reason='Reading the Arbin file requires MDBTools') +@pytest.mark.parametrize('basename', ['arbin1']) +def test_convert_Arbin_to_sqlite(testdata_dir, tmpdir, basename): + """Convert an Arbin file to SQLite using the functional interface.""" + res_file = os.path.join(testdata_dir, basename + '.res') + sqlite_file = os.path.join(str(tmpdir), basename + '.s3db') + res2sqlite.convert_arbin_to_sqlite(res_file, sqlite_file) + assert os.path.isfile(sqlite_file) + with sqlite3.connect(sqlite_file) as conn: + csr = conn.execute('SELECT * FROM Channel_Normal_Table;') + csr.fetchone()