kopia lustrzana https://github.com/ctjacobs/pyqso
Separate resources for tests and for the pyqso module.
rodzic
74256cd7b5
commit
a200eae434
|
@ -62,10 +62,10 @@ class PyQSO:
|
||||||
# Get the PyQSO main window defined in the Glade file.
|
# Get the PyQSO main window defined in the Glade file.
|
||||||
self.builder = Gtk.Builder()
|
self.builder = Gtk.Builder()
|
||||||
try:
|
try:
|
||||||
glade_file_path = pkg_resources.resource_filename("pyqso", os.path.join(os.pardir, "res", "pyqso.glade"))
|
glade_file_path = pkg_resources.resource_filename("pyqso", os.path.join("res", "pyqso.glade"))
|
||||||
except ImportError:
|
except ImportError:
|
||||||
# Assume the resources directory is in the parent directory of the directory containing this file.
|
# Assume the resources directory is in the parent directory of the directory containing this file.
|
||||||
glade_file_path = os.path.join(os.path.realpath(os.path.dirname(__file__)), os.pardir, "res", "pyqso.glade")
|
glade_file_path = os.path.join(os.path.realpath(os.path.dirname(__file__)), os.pardir, "pyqso", "res", "pyqso.glade")
|
||||||
self.builder.add_from_file(glade_file_path)
|
self.builder.add_from_file(glade_file_path)
|
||||||
self.window = self.builder.get_object("pyqso")
|
self.window = self.builder.get_object("pyqso")
|
||||||
|
|
||||||
|
@ -133,10 +133,10 @@ class PyQSO:
|
||||||
|
|
||||||
# Get the About dialog defined in the Glade file.
|
# Get the About dialog defined in the Glade file.
|
||||||
try:
|
try:
|
||||||
glade_file_path = pkg_resources.resource_filename("pyqso", os.path.join(os.pardir, "res", "pyqso.glade"))
|
glade_file_path = pkg_resources.resource_filename("pyqso", os.path.join("res", "pyqso.glade"))
|
||||||
except ImportError:
|
except ImportError:
|
||||||
# Assume the resources directory is in the parent directory of the directory containing this file.
|
# Assume the resources directory is in the parent directory of the directory containing this file.
|
||||||
glade_file_path = os.path.join(os.path.realpath(os.path.dirname(__file__)), os.pardir, "res", "pyqso.glade")
|
glade_file_path = os.path.join(os.path.realpath(os.path.dirname(__file__)), os.pardir, "pyqso", "res", "pyqso.glade")
|
||||||
self.builder.add_objects_from_file(glade_file_path, ("about_dialog",))
|
self.builder.add_objects_from_file(glade_file_path, ("about_dialog",))
|
||||||
about = self.builder.get_object("about_dialog")
|
about = self.builder.get_object("about_dialog")
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ class CabrilloExportDialog:
|
||||||
logging.debug("Building new Cabrillo export dialog...")
|
logging.debug("Building new Cabrillo export dialog...")
|
||||||
|
|
||||||
self.builder = application.builder
|
self.builder = application.builder
|
||||||
glade_file_path = os.path.join(os.path.realpath(os.path.dirname(__file__)), os.pardir, "res", "pyqso.glade")
|
glade_file_path = os.path.join(os.path.realpath(os.path.dirname(__file__)), "res", "pyqso.glade")
|
||||||
self.builder.add_objects_from_file(glade_file_path, ("cabrillo_export_dialog",))
|
self.builder.add_objects_from_file(glade_file_path, ("cabrillo_export_dialog",))
|
||||||
self.dialog = self.builder.get_object("cabrillo_export_dialog")
|
self.dialog = self.builder.get_object("cabrillo_export_dialog")
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ class CalendarDialog:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.builder = application.builder
|
self.builder = application.builder
|
||||||
glade_file_path = os.path.join(os.path.realpath(os.path.dirname(__file__)), os.pardir, "res", "pyqso.glade")
|
glade_file_path = os.path.join(os.path.realpath(os.path.dirname(__file__)), "res", "pyqso.glade")
|
||||||
self.builder.add_objects_from_file(glade_file_path, ("calendar_dialog",))
|
self.builder.add_objects_from_file(glade_file_path, ("calendar_dialog",))
|
||||||
self.dialog = self.builder.get_object("calendar_dialog")
|
self.dialog = self.builder.get_object("calendar_dialog")
|
||||||
self.calendar = self.builder.get_object("calendar")
|
self.calendar = self.builder.get_object("calendar")
|
||||||
|
|
|
@ -36,7 +36,7 @@ class LogNameDialog:
|
||||||
logging.debug("Building new log name dialog...")
|
logging.debug("Building new log name dialog...")
|
||||||
|
|
||||||
self.builder = application.builder
|
self.builder = application.builder
|
||||||
glade_file_path = os.path.join(os.path.realpath(os.path.dirname(__file__)), os.pardir, "res", "pyqso.glade")
|
glade_file_path = os.path.join(os.path.realpath(os.path.dirname(__file__)), "res", "pyqso.glade")
|
||||||
self.builder.add_objects_from_file(glade_file_path, ("log_name_dialog",))
|
self.builder.add_objects_from_file(glade_file_path, ("log_name_dialog",))
|
||||||
self.dialog = self.builder.get_object("log_name_dialog")
|
self.dialog = self.builder.get_object("log_name_dialog")
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ class PreferencesDialog:
|
||||||
|
|
||||||
self.application = application
|
self.application = application
|
||||||
self.builder = self.application.builder
|
self.builder = self.application.builder
|
||||||
glade_file_path = os.path.join(os.path.realpath(os.path.dirname(__file__)), os.pardir, "res", "pyqso.glade")
|
glade_file_path = os.path.join(os.path.realpath(os.path.dirname(__file__)), "res", "pyqso.glade")
|
||||||
self.builder.add_objects_from_file(glade_file_path, ("preferences_dialog",))
|
self.builder.add_objects_from_file(glade_file_path, ("preferences_dialog",))
|
||||||
self.dialog = self.builder.get_object("preferences_dialog")
|
self.dialog = self.builder.get_object("preferences_dialog")
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ class RecordDialog:
|
||||||
|
|
||||||
self.application = application
|
self.application = application
|
||||||
self.builder = self.application.builder
|
self.builder = self.application.builder
|
||||||
glade_file_path = os.path.join(os.path.realpath(os.path.dirname(__file__)), os.pardir, "res", "pyqso.glade")
|
glade_file_path = os.path.join(os.path.realpath(os.path.dirname(__file__)), "res", "pyqso.glade")
|
||||||
self.builder.add_objects_from_file(glade_file_path, ("record_dialog",))
|
self.builder.add_objects_from_file(glade_file_path, ("record_dialog",))
|
||||||
self.dialog = self.builder.get_object("record_dialog")
|
self.dialog = self.builder.get_object("record_dialog")
|
||||||
self.builder.get_object("record_dialog").connect("key-press-event", self.on_key_press)
|
self.builder.get_object("record_dialog").connect("key-press-event", self.on_key_press)
|
||||||
|
|
Przed Szerokość: | Wysokość: | Rozmiar: 667 B Po Szerokość: | Wysokość: | Rozmiar: 667 B |
Przed Szerokość: | Wysokość: | Rozmiar: 47 KiB Po Szerokość: | Wysokość: | Rozmiar: 47 KiB |
Przed Szerokość: | Wysokość: | Rozmiar: 6.8 KiB Po Szerokość: | Wysokość: | Rozmiar: 6.8 KiB |
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
from gi.repository import Gtk
|
from gi.repository import Gtk
|
||||||
import logging
|
import logging
|
||||||
from os import pardir
|
|
||||||
from os.path import basename, getmtime, expanduser, dirname, join, realpath
|
from os.path import basename, getmtime, expanduser, dirname, join, realpath
|
||||||
from datetime import datetime, date
|
from datetime import datetime, date
|
||||||
try:
|
try:
|
||||||
|
@ -51,7 +50,7 @@ class Summary(object):
|
||||||
self.application = application
|
self.application = application
|
||||||
self.logbook = self.application.logbook
|
self.logbook = self.application.logbook
|
||||||
self.builder = self.application.builder
|
self.builder = self.application.builder
|
||||||
glade_file_path = join(realpath(dirname(__file__)), pardir, "res", "pyqso.glade")
|
glade_file_path = join(realpath(dirname(__file__)), "res", "pyqso.glade")
|
||||||
self.builder.add_objects_from_file(glade_file_path, ("summary_page",))
|
self.builder.add_objects_from_file(glade_file_path, ("summary_page",))
|
||||||
self.summary_page = self.builder.get_object("summary_page")
|
self.summary_page = self.builder.get_object("summary_page")
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ class TelnetConnectionDialog:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.builder = application.builder
|
self.builder = application.builder
|
||||||
glade_file_path = os.path.join(os.path.realpath(os.path.dirname(__file__)), os.pardir, "res", "pyqso.glade")
|
glade_file_path = os.path.join(os.path.realpath(os.path.dirname(__file__)), "res", "pyqso.glade")
|
||||||
self.builder.add_objects_from_file(glade_file_path, ("telnet_connection_dialog",))
|
self.builder.add_objects_from_file(glade_file_path, ("telnet_connection_dialog",))
|
||||||
self.dialog = self.builder.get_object("telnet_connection_dialog")
|
self.dialog = self.builder.get_object("telnet_connection_dialog")
|
||||||
self.sources = {"HOST": self.builder.get_object("host_entry"),
|
self.sources = {"HOST": self.builder.get_object("host_entry"),
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -35,7 +35,7 @@ setup(name="PyQSO",
|
||||||
],
|
],
|
||||||
packages=["pyqso"],
|
packages=["pyqso"],
|
||||||
package_dir={"pyqso": "pyqso"},
|
package_dir={"pyqso": "pyqso"},
|
||||||
package_data={"pyqso": ["../res/pyqso.glade", "../res/log_64x64.png"]},
|
package_data={"pyqso": ["res/pyqso.glade", "res/log_64x64.png"]},
|
||||||
scripts=["bin/pyqso"],
|
scripts=["bin/pyqso"],
|
||||||
zip_safe=False
|
zip_safe=False
|
||||||
)
|
)
|
||||||
|
|
|
@ -163,7 +163,7 @@ class TestADIF(unittest.TestCase):
|
||||||
""" Check that records can be written to an ADIF file from a test database file. """
|
""" Check that records can be written to an ADIF file from a test database file. """
|
||||||
import sqlite3
|
import sqlite3
|
||||||
import os.path
|
import os.path
|
||||||
path_to_test_database = os.path.join(os.path.realpath(os.path.dirname(__file__)), os.pardir, "res/test.db")
|
path_to_test_database = os.path.join(os.path.realpath(os.path.dirname(__file__)), "res", "test.db")
|
||||||
self.connection = sqlite3.connect(path_to_test_database)
|
self.connection = sqlite3.connect(path_to_test_database)
|
||||||
self.connection.row_factory = sqlite3.Row
|
self.connection.row_factory = sqlite3.Row
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ class TestAwards(unittest.TestCase):
|
||||||
PyQSO = mock.MagicMock()
|
PyQSO = mock.MagicMock()
|
||||||
self.awards = Awards(application=PyQSO())
|
self.awards = Awards(application=PyQSO())
|
||||||
self.logbook = Logbook(application=PyQSO())
|
self.logbook = Logbook(application=PyQSO())
|
||||||
path_to_test_database = os.path.join(os.path.realpath(os.path.dirname(__file__)), os.pardir, "res/test.db")
|
path_to_test_database = os.path.join(os.path.realpath(os.path.dirname(__file__)), "res", "test.db")
|
||||||
success = self.logbook.db_connect(path_to_test_database)
|
success = self.logbook.db_connect(path_to_test_database)
|
||||||
assert(success)
|
assert(success)
|
||||||
self.logbook.logs = self.logbook.get_logs()
|
self.logbook.logs = self.logbook.get_logs()
|
||||||
|
|
|
@ -38,7 +38,7 @@ class TestLogbook(unittest.TestCase):
|
||||||
self.logbook = Logbook(application=mock.MagicMock())
|
self.logbook = Logbook(application=mock.MagicMock())
|
||||||
|
|
||||||
# Open the test database file.
|
# Open the test database file.
|
||||||
path_to_test_database = os.path.join(os.path.realpath(os.path.dirname(__file__)), os.pardir, "res/test.db")
|
path_to_test_database = os.path.join(os.path.realpath(os.path.dirname(__file__)), "res", "test.db")
|
||||||
opened = self.logbook.open(path=path_to_test_database)
|
opened = self.logbook.open(path=path_to_test_database)
|
||||||
assert(opened)
|
assert(opened)
|
||||||
assert(self.logbook.connection is not None)
|
assert(self.logbook.connection is not None)
|
||||||
|
@ -75,7 +75,7 @@ class TestLogbook(unittest.TestCase):
|
||||||
def test_open_invalid_logbook(self, mock_handle_gtk_dialog):
|
def test_open_invalid_logbook(self, mock_handle_gtk_dialog):
|
||||||
""" Open an invalid database file (comprising only one line of plain text) and check that an error occurs. """
|
""" Open an invalid database file (comprising only one line of plain text) and check that an error occurs. """
|
||||||
invalid_logbook = Logbook(application=mock.MagicMock())
|
invalid_logbook = Logbook(application=mock.MagicMock())
|
||||||
path_to_invalid_database = os.path.join(os.path.realpath(os.path.dirname(__file__)), os.pardir, "res/invalid.db")
|
path_to_invalid_database = os.path.join(os.path.realpath(os.path.dirname(__file__)), "res", "invalid.db")
|
||||||
opened = invalid_logbook.open(path=path_to_invalid_database)
|
opened = invalid_logbook.open(path=path_to_invalid_database)
|
||||||
assert(not opened)
|
assert(not opened)
|
||||||
assert(not invalid_logbook.logs)
|
assert(not invalid_logbook.logs)
|
||||||
|
@ -86,7 +86,7 @@ class TestLogbook(unittest.TestCase):
|
||||||
def test_new_log(self, mock_LogNameDialog, mock_handle_gtk_dialog, mock_render_log):
|
def test_new_log(self, mock_LogNameDialog, mock_handle_gtk_dialog, mock_render_log):
|
||||||
""" Create an empty logbook file, open it, and check that a new log can successfully be added. """
|
""" Create an empty logbook file, open it, and check that a new log can successfully be added. """
|
||||||
# Create a copy of the test database just for use in this particular test, since the contents will need to be modified.
|
# Create a copy of the test database just for use in this particular test, since the contents will need to be modified.
|
||||||
path_to_test_database = os.path.join(os.path.realpath(os.path.dirname(__file__)), os.pardir, "res/test.db")
|
path_to_test_database = os.path.join(os.path.realpath(os.path.dirname(__file__)), "res", "test.db")
|
||||||
destination = "Logbook.test_new_log.db"
|
destination = "Logbook.test_new_log.db"
|
||||||
copyfile(path_to_test_database, destination)
|
copyfile(path_to_test_database, destination)
|
||||||
opened = self.logbook.open(path=destination)
|
opened = self.logbook.open(path=destination)
|
||||||
|
|
|
@ -36,7 +36,7 @@ class TestSummary(unittest.TestCase):
|
||||||
PyQSO = mock.MagicMock()
|
PyQSO = mock.MagicMock()
|
||||||
self.summary = Summary(application=PyQSO())
|
self.summary = Summary(application=PyQSO())
|
||||||
self.summary.logbook = Logbook(application=PyQSO())
|
self.summary.logbook = Logbook(application=PyQSO())
|
||||||
path_to_test_database = os.path.join(os.path.realpath(os.path.dirname(__file__)), os.pardir, "res/test.db")
|
path_to_test_database = os.path.join(os.path.realpath(os.path.dirname(__file__)), "res", "test.db")
|
||||||
success = self.summary.logbook.db_connect(path_to_test_database)
|
success = self.summary.logbook.db_connect(path_to_test_database)
|
||||||
assert(success)
|
assert(success)
|
||||||
self.summary.logbook.logs = self.summary.logbook.get_logs()
|
self.summary.logbook.logs = self.summary.logbook.get_logs()
|
||||||
|
|
Ładowanie…
Reference in New Issue