From 4ff32af3430389db812a43d8a3981713ecd9d697 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Thu, 26 May 2022 09:53:40 +0200 Subject: [PATCH] flows: fix flakiness in tests Signed-off-by: Jens Langhammer --- authentik/flows/tests/test_inspector.py | 5 +++-- authentik/flows/tests/test_transfer.py | 7 +++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/authentik/flows/tests/test_inspector.py b/authentik/flows/tests/test_inspector.py index 8d31e6e32..822b9088e 100644 --- a/authentik/flows/tests/test_inspector.py +++ b/authentik/flows/tests/test_inspector.py @@ -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, ) diff --git a/authentik/flows/tests/test_transfer.py b/authentik/flows/tests/test_transfer.py index ed93b2ff7..67a13148b 100644 --- a/authentik/flows/tests/test_transfer.py +++ b/authentik/flows/tests/test_transfer.py @@ -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"""