barbacompta/tests/test_admin.py

59 lines
2.3 KiB
Python

# barbacompta - invoicing for dummies
# Copyright (C) 2022 Entr'ouvert
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import pytest
class TestLoggedIn:
@pytest.fixture
def app(self, app):
# login
response = app.get('/').follow()
response.form['username'] = 'admin'
response.form['password'] = 'admin'
response.form.submit()
return app
def test_contrat_recurrent_no_debut(self, app):
response = app.get('/eo_facture/contrat/add/')
response.form['client'].force_value('1')
response.form['intitule'] = 'Contrat 1'
response.form['periodicite'] = 'annuelle'
response = response.form.submit('_continue')
assert len(response.pyquery('.errorlist'))
def test_contrat_recurrent_debut_changed(self, app):
response = app.get('/eo_facture/contrat/add/')
response.form['client'].force_value('1')
response.form['intitule'] = 'Contrat 1'
response.form['periodicite'] = 'annuelle'
response.form['periodicite_debut'] = '2018-12-01'
response = response.form.submit('_continue').follow()
response.form['periodicite_debut'] = '2018-12-02'
response = response.form.submit('_continue').follow()
# Créer la facture de première échéance
response = app.get('/')
assert 'facturer-echeance' in response.form.action
response = response.form.submit().follow()
# Essayons de modifier le début
response = response.click('Contrat', index=1)
response.form['periodicite_debut'] = '2018-12-01'
response = response.form.submit('_continue')
# Il y a une erreur
assert len(response.pyquery('.errorlist.nonfield'))