flows: fix flakiness in tests

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2022-05-26 09:53:40 +02:00
parent 972868c15c
commit 4ff32af343
2 changed files with 8 additions and 4 deletions

View File

@ -9,6 +9,7 @@ from rest_framework.test import APITestCase
from authentik.core.tests.utils import create_test_admin_user
from authentik.flows.challenge import ChallengeTypes
from authentik.flows.models import Flow, FlowDesignation, FlowStageBinding, InvalidResponseAction
from authentik.lib.generators import generate_id
from authentik.stages.dummy.models import DummyStage
from authentik.stages.identification.models import IdentificationStage, UserFields
@ -24,8 +25,8 @@ class TestFlowInspector(APITestCase):
def test(self):
"""test inspector"""
flow = Flow.objects.create(
name="test-full",
slug="test-full",
name=generate_id(),
slug=generate_id(),
designation=FlowDesignation.AUTHENTICATION,
)

View File

@ -80,16 +80,19 @@ class TestFlowTransfer(TransactionTestCase):
def test_export_validate_import_re_import(self):
"""Test export and import it twice"""
count_initial = Prompt.objects.filter(field_key="username").count()
importer = FlowImporter(STATIC_PROMPT_EXPORT)
self.assertTrue(importer.validate())
self.assertTrue(importer.apply())
self.assertEqual(Prompt.objects.filter(field_key="username").count(), 1)
count_before = Prompt.objects.filter(field_key="username").count()
self.assertEqual(count_initial + 1, count_before)
importer = FlowImporter(STATIC_PROMPT_EXPORT)
self.assertTrue(importer.apply())
self.assertEqual(Prompt.objects.filter(field_key="username").count(), 1)
self.assertEqual(Prompt.objects.filter(field_key="username").count(), count_before)
def test_export_validate_import_policies(self):
"""Test export and validate it"""