Exemplo n.º 1
0
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()

    assert dc.xpath('dataqual/logic')[0].text == 'this is a test'
Exemplo n.º 2
0
def test_mainwindow_from_xml(qtbot, mock):

    widget = MainWindow.PyMdWizardMainForm()
    qtbot.addWidget(widget)

    test_record_fname = "tests/data/GenericFGDCTemplate_FGDCtemp.xml"
    mock.patch.object(QMessageBox, 'question',
                      return_value=QMessageBox.No)
    widget.open_file(test_record_fname)

    assert widget.metadata_root.findChild(QPlainTextEdit, "fgdc_logic").toPlainText() == 'No formal logical accuracy tests were conducted. testing'
Exemplo n.º 3
0
def test_validation(qtbot, mock):

    widget = MainWindow.PyMdWizardMainForm()
    qtbot.addWidget(widget)

    test_record_fname = "tests/data/USGS_ASC_PolarBears_FGDC.xml"
    mock.patch.object(QMessageBox, 'question',
                      return_value=QMessageBox.No)
    mock.patch.object(QMessageBox, 'warning',
                      return_value=QMessageBox.Cancel)
    mock.patch.object(QMessageBox, 'information',
                      return_value=QMessageBox.Cancel)
    widget.open_file(test_record_fname)
    widget.validate()
    assert len(widget.error_list.errors) == 1
Exemplo n.º 4
0
def test_settings(qtbot, mock):

    settings = qt_api.QtCore.QSettings('USGS', 'pymdwizard')
    settings.setValue('template_fname',
                      'tests/data/USGS_ASC_PolarBears_FGDC.xml')

    widget = MainWindow.PyMdWizardMainForm()
    qtbot.addWidget(widget)

    widget.get_save_name = lambda: 'test_output.xml'

    mock.patch.object(QMessageBox, 'question', return_value=QMessageBox.No)
    widget.new_record()

    md = widget.metadata_root.to_xml()
    os.remove('test_output.xml')

    assert md.xpath('idinfo/spdom/bounding/westbc')[0].text == '178.2167'
Exemplo n.º 5
0
def test_settings(qtbot, mock):

    settings = qt_api.QtCore.QSettings("USGS_2.0.7", "pymdwizard_2.0.7")
    settings.setValue("template_fname",
                      "tests/data/USGS_ASC_PolarBears_FGDC.xml")

    widget = MainWindow.PyMdWizardMainForm()
    qtbot.addWidget(widget)

    widget.get_save_name = lambda: "test_output.xml"

    mock.patch.object(QMessageBox, "question", return_value=QMessageBox.No)
    widget.new_record()

    md = widget.metadata_root.to_xml()
    os.remove("test_output.xml")

    assert md.xpath("idinfo/spdom/bounding/westbc")[0].text == "178.2167"
Exemplo n.º 6
0
def test_validation(qtbot, mock):

    widget = MainWindow.PyMdWizardMainForm()
    qtbot.addWidget(widget)

    test_record_fname = "tests/data/USGS_ASC_PolarBears_FGDC.xml"
    mock.patch.object(QMessageBox, 'question', return_value=QMessageBox.No)
    mock.patch.object(QMessageBox, 'warning', return_value=QMessageBox.Cancel)
    mock.patch.object(QMessageBox,
                      'information',
                      return_value=QMessageBox.Cancel)
    widget.open_file(test_record_fname)
    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")
Exemplo n.º 7
0
def test_misc(qtbot, mock):
    widget = MainWindow.PyMdWizardMainForm()
    qtbot.addWidget(widget)

    mock.patch.object(QMessageBox, 'about', return_value=QMessageBox.Ok)
    widget.about()