Skip to content

Commit

Permalink
Fix bug when use_spelling setting is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinTalbert committed May 10, 2018
1 parent ec9a11c commit 5ac53ec
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pymdwizard/gui/MainWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,9 @@ def __init__(self, parent=None):

self.load_default()
settings = QSettings('USGS', 'pymdwizard')
use_spelling = settings.value('use_spelling', True)
use_spelling = eval(use_spelling.capitalize())
use_spelling = settings.value('use_spelling', "true")
if isinstance(use_spelling, str):
use_spelling = eval(use_spelling.capitalize())
self.switch_spelling(use_spelling)

def build_ui(self):
Expand Down Expand Up @@ -1041,8 +1042,8 @@ def generate_review_doc(self):
def open_file(filename):
if sys.platform == "win32":
os.startfile('"{}"'.format(filename))
else:
opener = "open" if sys.platform == "darwin" else "xdg-open"
elif sys.platform == "darwin":
opener = "open"
subprocess.call([opener, filename])

open_file(out_fname)
Expand Down
11 changes: 11 additions & 0 deletions tests/test_mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ def test_mainwindow_from_xml(qtbot, mock):

assert widget.metadata_root.findChild(QPlainTextEdit, "fgdc_logic").toPlainText() == 'No formal logical accuracy tests were conducted. testing'


def test_mainwindow_to_xml(qtbot):
widget = MainWindow.PyMdWizardMainForm()
qtbot.addWidget(widget)

widget.metadata_root.findChild(QPlainTextEdit, "fgdc_logic").setPlainText("this is a test")
dc = widget.metadata_root.to_xml()

Expand All @@ -61,6 +66,12 @@ def test_validation(qtbot, mock):
widget.validate()
assert len(widget.error_list.errors) == 1

# For some reason this part of the test is causing it to hang on TravisCI
mock.patch.object(QMessageBox, 'question',
return_value=QMessageBox.No)
mock.patch.object(QMessageBox, 'information',
return_value=QMessageBox.Ok)
widget.last_updated = time.time()
widget.generate_review_doc()
assert os.path.exists("tests/data/USGS_ASC_PolarBears_FGDC_REVIEW.docx")
os.remove("tests/data/USGS_ASC_PolarBears_FGDC_REVIEW.docx")
Expand Down

0 comments on commit 5ac53ec

Please sign in to comment.