Exemplo n.º 1
0
def test_error_dialog_attribute_error():
    try:
        exception = AttributeError('General Error')
        errorDialog = application.ErrorDialog(exception)
        errorDialog.close()

    except Exception as e:
        pytest.fail()
Exemplo n.º 2
0
def test_error_dialog_http_error():
    exception = urllib3.exceptions.HTTPError()
    errorDialog = application.ErrorDialog(exception)
    assert (
        errorDialog.message ==
        'A HTTP error occurred, this could be due to the SPARQL end-point being unavailable'
    )
    errorDialog.close()
Exemplo n.º 3
0
def test_error_dialog_general_error():
    try:
        exception = Exception('General Error')
        errorDialog = application.ErrorDialog(exception)
        errorDialog.close()

    except Exception as e:
        pytest.fail()
Exemplo n.º 4
0
def test_error_dialog_value_error():
    try:
        exception = ValueError('General Error')
        errorDialog = application.ErrorDialog(exception)

        errorDialog.close()
        errorDialog = None
    except Exception as e:
        pytest.fail()
Exemplo n.º 5
0
  def __init__(self, app, search, views, results, hasCalma):
    """
    Create an instance of the View class.

    The view class defines a series of layout, split into a tabbed list of buttons, and
    a series of data views (a combination of textual, chronological and geographical).

    Parameters
    ----------
    app : instance
        Reference to the main application module.
    search : instance
        Reference to the searchHandler instance.
    views : str[]
        A list of views requested.
    results : {}
        The results of the SPARQL query.
    hasCalma : boolean
        Boolean value indicating whether feature analyses are available for this set of results.
    """
    self.app = app
    self.search = search
    self.calma = calma.Calma(self.app.cache)
    self.hasCalma = hasCalma
    self.views = views

    self.viewWidget = QtWidgets.QWidget()
    self.viewLayout = QtWidgets.QVBoxLayout()
    self.viewWidget.setLayout(self.viewLayout)

    # If no results / error occured, log and return
    if isinstance(results, Exception):
      self.errorDialog = application.ErrorDialog(results)
      return

    # Generate components from user check boxes
    for v in views:
      if v == 'map' : self.generate_map(results)
      if v == 'timeline' : self.generate_plot_view()
      if v == 'table' : self.generate_table(results)


    # Check seperately to ensure added in 'correct' order
    if 'today in history' in views: self.add_history_label_view()
    if 'table' in views: self.viewLayout.addWidget(self.tableHandler.get_table_container())
    if 'map' in views: self.viewLayout.addWidget(self.mapSearchDialog)
    if 'timeline' in views: self.viewLayout.addWidget(self.calmaGraphView)

    if self.viewLayout.count() == 2:
      self.viewLayout.setStretch(0, 5)
      self.viewLayout.setStretch(1, 5)
    if self.viewLayout.count() == 3:
      self.viewLayout.setStretch(0, 2)
      self.viewLayout.setStretch(1, 6)
      self.viewLayout.setStretch(2, 2)
    if self.viewLayout.count() == 4:
      self.viewLayout.setStretch(0, 1)
      self.viewLayout.setStretch(1, 4)
      self.viewLayout.setStretch(2, 10)
      self.viewLayout.setStretch(3, 4)

    # Setup signals post-view creation
    self.app.searchForm.infoWindowWidgets['searchButton'].clicked.connect(self.search_table)
    self.app.searchForm.infoWindowWidgets['savePlotButton'].clicked.connect(self.save_calma_plot)
    self.app.searchForm.infoWindowWidgets['saveButton'].clicked.connect(self.save_search)
    self.app.searchForm.tracklistView.clicked.connect(self.graph_calma)