Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lnt/server/ui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ def __call__(self, environ, start_response):
return self.app(environ, start_response)


class LNTObjectJSONEncoder(flask.json.JSONEncoder):
class LNTObjectJSONEncoder(flask.json.provider.DefaultJSONProvider):
"""Take SQLAlchemy objects and jsonify them. If the object has an __json__
method, use that instead."""

def __init__(self, *args, **kwargs):
super(LNTObjectJSONEncoder, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)

def default(self, obj):
if hasattr(obj, '__json__'):
Expand All @@ -74,7 +74,7 @@ def default(self, obj):

return fields

return flask.json.JSONEncoder.default(self, obj)
return super().default(self, obj)


class Request(flask.Request):
Expand Down Expand Up @@ -140,7 +140,7 @@ def create_with_instance(instance):
# Construct the application.
app = App(__name__)

app.json_encoder = LNTObjectJSONEncoder
app.json = LNTObjectJSONEncoder(app)
# Register additional filters.
create_jinja_environment(app.jinja_env)

Expand Down
14 changes: 7 additions & 7 deletions lnt/server/ui/regression_views.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import flask
import sqlalchemy
import json
import flask
from flask import g
from flask import abort
from flask import render_template
from flask import request
from flask import flash
import flask_wtf
from sqlalchemy import desc
from sqlalchemy.orm.exc import NoResultFound
from wtforms import SelectMultipleField, StringField, widgets, SelectField
from wtforms import HiddenField
from flask_wtf import Form
from wtforms.validators import DataRequired

from lnt.server.ui.decorators import v4_route
Expand Down Expand Up @@ -39,7 +39,7 @@ class MultiCheckboxField(SelectMultipleField):
option_widget = widgets.CheckboxInput()


class TriagePageSelectedForm(Form):
class TriagePageSelectedForm(flask_wtf.FlaskForm):
field_changes = MultiCheckboxField("Changes", coerce=int)
name = StringField('name', validators=[DataRequired()])

Expand Down Expand Up @@ -125,7 +125,7 @@ def calc_impact(session, ts, fcs):
return PrecomputedCR(1, 1, True)


class MergeRegressionForm(Form):
class MergeRegressionForm(flask_wtf.FlaskForm):
regression_checkboxes = MultiCheckboxField("regression_checkboxes",
coerce=int)

Expand Down Expand Up @@ -251,7 +251,7 @@ def _get_regressions_from_selected_form(session, form, ts):
return reg_inds, regressions


class EditRegressionForm(Form):
class EditRegressionForm(flask_wtf.FlaskForm):
title = StringField(u'Title', validators=[DataRequired()])
bug = StringField(u'Bug', validators=[DataRequired()])
field_changes = MultiCheckboxField("Changes", coerce=int)
Expand All @@ -265,7 +265,7 @@ def name(cls):
return cls.__class__.__name__


class LNTEncoder(flask.json.JSONEncoder):
class LNTEncoder(json.JSONEncoder):
"""Encode all the common LNT objects."""
def default(self, obj):
# Most of our objects have a __json__ defined.
Expand All @@ -276,7 +276,7 @@ def default(self, obj):
return
if name(obj) == "SampleField":
return obj.name
return flask.json.JSONEncoder.default(self, obj)
return flask.json.provider.DefaultJSONProvider.default(obj)


@v4_route("/regressions/<int:id>", methods=["GET", "POST"])
Expand Down
6 changes: 3 additions & 3 deletions lnt/server/ui/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from io import BytesIO

import flask
import flask_wtf
import sqlalchemy.sql
from flask import abort
from flask import current_app
Expand All @@ -18,7 +19,6 @@
from flask import render_template
from flask import request, url_for
from flask import send_file
from flask_wtf import Form
from sqlalchemy.orm import joinedload
from sqlalchemy.orm.exc import NoResultFound
from wtforms import SelectField, StringField, SubmitField
Expand Down Expand Up @@ -584,7 +584,7 @@ def v4_run(id):
return render_template("v4_run.html", **data)


class PromoteOrderToBaseline(Form):
class PromoteOrderToBaseline(flask_wtf.FlaskForm):
name = StringField('Name', validators=[DataRequired(), Length(max=32)])
description = StringField('Description', validators=[Length(max=256)])
promote = SubmitField('Promote')
Expand Down Expand Up @@ -1845,7 +1845,7 @@ def v4_search():
]


class MatrixOptions(Form):
class MatrixOptions(flask_wtf.FlaskForm):
limit = SelectField('Size', choices=MATRIX_LIMITS)


Expand Down
20 changes: 10 additions & 10 deletions requirements.client.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
# The client has fewer requirements than the server code.
.
aniso8601==1.2.0
click==6.7
Flask-RESTful==0.3.4
Flask-WTF==0.12
Flask==0.12.2
itsdangerous==0.24
Jinja2==2.11.3
MarkupSafe==1.1.1
click==8.1.8
Flask-RESTful==0.3.10
Flask-WTF==1.2.0
Flask==3.1.2
itsdangerous==2.2.0
Jinja2==3.1.6
MarkupSafe==3.0.3
python-gnupg==0.3.7
pytz==2016.10
SQLAlchemy==1.3.24
Werkzeug==0.15.6
WTForms==2.0.2
pyyaml==5.1.2
Werkzeug==3.1.3
WTForms==3.2.1
pyyaml==6.0.3
2 changes: 0 additions & 2 deletions tests/lit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ else:

config.available_features.add(platform.system())

config.available_features.add('TODO-FIXME')

# Enable coverage.py reporting, assuming the coverage module has been installed
# and sitecustomize.py in the virtualenv has been modified appropriately.
if lit_config.params.get('check-coverage', None):
Expand Down
28 changes: 12 additions & 16 deletions tests/server/ui/V4Pages.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# XFAIL: TODO-FIXME

# Perform basic sanity checking of the V4 UI pages.
#
# create temporary instance
Expand Down Expand Up @@ -458,9 +456,9 @@ def main():
client, '/v4/nts/daily_report/2012/5/04', "Execution Time")
check_table_content(result_table_20120504,
[["test1", ""],
["", "machine2", "1.000", "-", "900.00%", ""],
["", "machine2", "1.000", "-", "10.000", ""],
["test2", ""],
["", "machine2", "FAIL", "-", "PASS", ""]])
["", "machine2", "FAIL", "-", "-", ""]])
check_table_links(result_table_20120504,
[[],
["/db_default/v4/nts/graph?plot.0=2.4.2&highlight_run=6"],
Expand All @@ -477,13 +475,13 @@ def main():
client, '/v4/nts/daily_report/2012/5/13?num_days=3', "Execution Time")
check_table_content(result_table_20120513,
[["test6", ""],
["", "machine2", "1.000", "FAIL", "PASS", ""],
["", "machine2", "1.000", "FAIL", "1.200", ""],
["test_hash1", ""],
["", "machine2", "1.000", '-', '20.00%', ""],
["", "machine2", "1.000", '1.000', '1.200', ""],
["test_hash2", ""],
["", "machine2", "1.000", '-', '20.00%', ""],
["", "machine2", "1.000", '1.000', '1.200', ""],
["test_mhash_on_run", ""],
["", "machine2", "1.000", '-', '20.00%', ""], ])
["", "machine2", "1.000", '1.000', '1.200', ""], ])
check_table_links(result_table_20120513,
[[],
['/db_default/v4/nts/graph?plot.0=2.6.2&highlight_run=9'],
Expand Down Expand Up @@ -637,16 +635,14 @@ def main():
lines_in_function = len(code_for_fn)
assert 2 == lines_in_function

# Make sure the new option does not break anything
check_html(client, '/db_default/v4/nts/graph?aggregation_function=mean&plot.0=1.3.2&submit=Update')
check_json(client, '/db_default/v4/nts/graph?aggregation_function=mean&plot.0=1.3.2&json=true&submit=Update')
check_html(client, '/db_default/v4/nts/graph?aggregation_function=mean&plot.0=1.3.2')
check_json(client, '/db_default/v4/nts/graph?aggregation_function=mean&plot.0=1.3.2&json=true')
check_html(client, '/db_default/v4/nts/graph?aggregation_function=nonexistent&plot.0=1.3.2', expected_code=404)
# Test with various aggregation functions
for fn in ['mean', 'median', 'min', 'max']:
check_html(client, f'/db_default/v4/nts/graph?aggregation_function={fn}&plot.7.2=2.7.2')
check_json(client, f'/db_default/v4/nts/graph?aggregation_function={fn}&plot.7.2=2.7.2&json=true')
check_html(client, '/db_default/v4/nts/graph?aggregation_function=nonexistent&plot.7.2=2.7.2', expected_code=404)
app.testing = False
error_page = check_html(client, '/explode', expected_code=500)
assert re.search("division (or modulo )?by zero",
error_page.get_data(as_text=True))
assert re.search("InternalServerError", error_page.get_data(as_text=True))

error_page = check_html(client, '/gone', expected_code=404)
assert "test" in error_page.get_data(as_text=True)
Expand Down
Loading