tests: add tests on client filters (#83267)
gitea/barbacompta/pipeline/head This commit looks good Details

This commit is contained in:
Benjamin Dauvergne 2023-11-09 10:46:05 +01:00
parent 7c9ad81fec
commit 3595c6f4e5
1 changed files with 37 additions and 1 deletions

View File

@ -15,8 +15,12 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import pytest
from django.contrib.auth import get_user_model
from eo_gestion.eo_facture.models import Contrat
from eo_gestion.eo_facture.models import Client, Contrat
from eo_gestion.eo_redmine.models import Project
User = get_user_model()
class TestLoggedIn:
@ -82,3 +86,35 @@ class TestLoggedIn:
assert contrat.factures.count() == 2
facture_avoir = facture.factures_avoir.get()
assert facture_avoir.intitule == 'AVOIR POUR LA FACTURE Contrat 1 du 01/12/2018 au 01/12/2019'
class TestFiltreClient:
@pytest.fixture(autouse=True)
def projects(self, db):
admin = User.objects.get(username='admin')
bd = User.objects.get(username='bdauvergne')
client1, client2 = Client.objects.all()[:2]
Project.objects.create(
name='projet 1',
client=client1,
).cpfs.set([admin, bd])
Project.objects.create(
name='projet 2',
client=client2,
).cpfs.set([admin, bd])
def test_mes_clients(self, app):
response = app.get('/eo_facture/client/')
assert response.pyquery('li.selected [title="mes clients"]')
assert len(response.pyquery('tbody tr')) == 2
Project.objects.all().delete()
response = app.get('/eo_facture/client/')
assert response.pyquery('li.selected [title="tous"]')
assert len(response.pyquery('tbody tr')) > 2
def test_derniere_facture(self, app):
response = app.get('/eo_facture/client/')
assert len(response.pyquery('tbody tr')) == 2
response = response.click('plus de 12 mois')
assert len(response.pyquery('tbody tr')) == 1