tests: use reliable references to objects (#44861)

This commit is contained in:
Valentin Deniaud 2020-07-06 15:30:58 +02:00
parent f833a08358
commit eb22673ee5
1 changed files with 4 additions and 4 deletions

View File

@ -205,8 +205,8 @@ def test_new_variable_service_view(app, admin_user):
def test_variable_update_view(app, admin_user):
app = login(app)
Variable.objects.create(name='foo', value='bar')
response = app.get('/sites/update-variable/1')
var = Variable.objects.create(name='foo', value='bar')
response = app.get('/sites/update-variable/%s' % var.pk)
assert response.html.find('input', {'name': 'name'})['value'] == 'foo'
assert response.html.find('textarea').text == '\nbar'
response.form['value'] = 'barbar'
@ -217,8 +217,8 @@ def test_variable_update_view(app, admin_user):
def test_variable_delete_view(app, admin_user):
app = login(app)
Variable.objects.create(name='foo', value='bar')
response = app.get('/sites/delete-variable/1')
var = Variable.objects.create(name='foo', value='bar')
response = app.get('/sites/delete-variable/%s' % var.pk)
assert response.html.find('h2').text == 'Removal of "foo"'
response = response.form.submit()
assert response.location == '/sites/variables'