Added a 'make unittest' command to the Makefile.

pull/17/head
Christian Jacobs 2013-09-15 00:21:58 +01:00
rodzic ff458e1ab6
commit 74fa770a05
3 zmienionych plików z 23 dodań i 14 usunięć

Wyświetl plik

@ -21,15 +21,20 @@
input: clean install documentation
install:
@echo **********Setting up PyQSO
@echo **********Installing PyQSO
python setup.py install
manual:
cd doc; pdflatex manual.tex; cd ..; done
@echo **********Compiling the user manual
cd doc; pdflatex manual.tex; cd ..
unittest:
@echo **********Running the unit tests
cd pyqso; for file in *.py ; do (python $$file); done; cd ..
clean:
@echo **********Cleaning build directory
rm -rf build
@echo **********Cleaning doc directory
cd doc; rm -rf *.log *.aux *.dvi *.pdf *.ps *.toc; cd ..; done
cd doc; rm -rf *.log *.aux *.dvi *.pdf *.ps *.toc; cd ..

Wyświetl plik

@ -380,13 +380,17 @@ class TestADIF(unittest.TestCase):
f = open("ADIF.test_read.adi", 'w')
f.write("""Some test ADI data.<eoh>
<call:4>TEST<band:3>40M<mode:2>CW
<call:4>TEST<band:3>40m<mode:2>CW
<qso_date:8:d>20130322<time_on:4>1955<eor>""")
f.close()
records = adif.read("ADIF.test_read.adi")
assert records == [{'BAND': '40M', 'TIME_ON': '1955', 'CALL': 'TEST', 'MODE': 'CW', 'QSO_DATE': '20130322'}]
expected_records = [{'TIME_ON': '1955', 'BAND': '40m', 'CALL': 'TEST', 'MODE': 'CW', 'QSO_DATE': '20130322'}]
print "Imported records: ", records
print "Expected records: ", expected_records
assert(len(records) == 1)
assert(len(records[0].keys()) == len(expected_records[0].keys()))
assert(records == expected_records)
if(__name__ == '__main__'):
unittest.main()

Wyświetl plik

@ -44,7 +44,7 @@ class Log(Gtk.ListStore):
logging.debug("New Log instance created!")
def populate(self):
""" Removes everything in the Gtk.ListStore that is rendered already (via the TreeView), and starts afresh """
""" Remove everything in the Gtk.ListStore that is rendered already (via the TreeView), and start afresh """
self.add_missing_db_columns()
self.clear()
records = self.get_all_records()
@ -59,7 +59,7 @@ class Log(Gtk.ListStore):
return
def add_missing_db_columns(self):
""" Checks whether each field name in AVAILABLE_FIELD_NAMES_ORDERED is in the database table. If not, PyQSO will add it
""" Check whether each field name in AVAILABLE_FIELD_NAMES_ORDERED is in the database table. If not, add it
(with all entries being set to NULL initially). """
with(self.connection):
c = self.connection.cursor()
@ -75,7 +75,7 @@ class Log(Gtk.ListStore):
return
def add_record(self, fields_and_data):
""" Adds a record comprising data given in the 'fields_and_data' argument to the log. """
""" Add a record comprising data given in the 'fields_and_data' argument to the log. """
liststore_entry = []
field_names = AVAILABLE_FIELD_NAMES_ORDERED
for i in range(0, len(field_names)):
@ -112,7 +112,7 @@ class Log(Gtk.ListStore):
return
def delete_record(self, index, iter=None):
""" Deletes a record with a specific index in the log. If 'iter' is not None, the corresponding record is also deleted from the Gtk.ListStore data structure. """
""" Delete a record with a specific index in the log. If 'iter' is not None, the corresponding record is also deleted from the Gtk.ListStore data structure. """
# Get the selected row in the logbook
with(self.connection):
c = self.connection.cursor()
@ -124,7 +124,7 @@ class Log(Gtk.ListStore):
return
def edit_record(self, index, field_name, data):
""" Edits a specified record by replacing the data in the field 'field_name' with the data given in the argument called 'data'. """
""" Edit a specified record by replacing the data in the field 'field_name' with the data given in the argument called 'data'. """
with(self.connection):
c = self.connection.cursor()
query = "UPDATE %s SET %s" % (self.name, field_name)
@ -133,20 +133,20 @@ class Log(Gtk.ListStore):
return
def get_record_by_index(self, index):
""" Returns a record with a given index in the log. The record is represented by a dictionary of field-value pairs. """
""" Return a record with a given index in the log. The record is represented by a dictionary of field-value pairs. """
c = self.connection.cursor()
query = "SELECT * FROM %s WHERE id=?" % self.name
c.execute(query, [index])
return c.fetchone()
def get_all_records(self):
""" Returns a list of all the records in the log. Each record is represented by a dictionary. """
""" Return a list of all the records in the log. Each record is represented by a dictionary. """
c = self.connection.cursor()
c.execute("SELECT * FROM %s" % self.name)
return c.fetchall()
def get_number_of_records(self):
""" Returns the total number of records in the log. """
""" Return the total number of records in the log. """
c = self.connection.cursor()
c.execute("SELECT Count(*) FROM %s" % self.name)
return c.fetchone()[0]