Ejemplo n.º 1
0
 def test_get_all_sort_by_published(self, app):
     with app.app_context():
         results = PluginsService.get_all("published")
         for idx, result in enumerate(results):
             if idx > 0:
                 assert dateutil.parser.parse(
                     result.published) <= dateutil.parser.parse(
                         results[idx - 1].published)
def test_save_new_data_error(save_data_error_mock, get_data_error_mock, send_message_to_topic_mock, app):  # noqa
    with app.app_context():
        get_data_error_mock.return_value = data_error

        DataErrorService.save_new_data_error(data_error)

        save_data_error_mock.assert_called_once()
        get_data_error_mock.assert_called_once()
        send_message_to_topic_mock.assert_called_once()
Ejemplo n.º 3
0
def test_get_all_ordered_by_invalid_column_doesnt_fail(db, app):  # noqa
    with app.app_context():
        g.order_by = 'purpose'
        g.order_dir = 'desc'
        yin = Entity(id=1, name="Yin", purpose="thing 2")
        yang = Entity(id=2, name="Yang", purpose="thing 1")
        db.session.add(yin)
        db.session.add(yang)
        db.session.commit()
        results = EntityService.get_all()
        assert len(results) == 2
Ejemplo n.º 4
0
def test_get_all_ordered_by_purpose(db, app):  # noqa
    with app.app_context():
        g.order_by = 'purpose'
        yin = Entity(id=1, name="Yin", purpose="thing 2")
        yang = Entity(id=2, name="Yang", purpose="thing 1")
        db.session.add(yin)
        db.session.add(yang)
        db.session.commit()
        results = EntityService.get_all()
        assert len(results) == 2
        assert results[0] == yang
Ejemplo n.º 5
0
def test_save_new_data_error(githubhelper_mock, app):  # noqa
    with app.app_context():
        resp = FeedbackService.create_issue(feedback)

        githubhelper_mock.assert_called_once()
        output = resp.get('data')
        assert output['subject'] == feedback['subject']
        assert output['description'] == feedback['description']
        assert output['url'] == feedback['url']
        assert output['feedback_type'] == feedback['feedback_type']
        assert output['browser'] == feedback['browser']
        assert output['reporter_name'] == feedback['reporter_name']
        assert output['reporter_email'] == feedback['reporter_email']
Ejemplo n.º 6
0
def test_index_query_params(app):
    with app.app_context():
        expected = {
            'page': {
                'description': 'Requested items page. Defaults to 1.'
            },
            'per_page': {
                'description': 'Ammount of items per page. Defaults to 20.'
            },
            'order_by': {
                'description':
                'Identifies the column in which to order the results.'
            },
            'order_dir': {
                'description':
                'Selects the direction in which the results should be sorted. Only allows `asc` and `desc` as values.'
            }
        }
        assert Query.index_query_params == expected
Ejemplo n.º 7
0
 def test_get_all_sort_by_plugin_id(self, app):
     with app.app_context():
         results = PluginsService.get_all("pluginID")
         for idx, result in enumerate(results):
             if idx > 0:
                 assert result.id <= results[idx - 1].id
Ejemplo n.º 8
0
 def test_get_all_sort_by_score(self, app):
     with app.app_context():
         results = PluginsService.get_all("score")
         for idx, result in enumerate(results):
             if idx > 0:
                 assert result.score <= results[idx - 1].score