Skip to content

Commit

Permalink
fixed unit test and linting
Browse files Browse the repository at this point in the history
  • Loading branch information
dave-kennedy-ecs committed Sep 20, 2024
1 parent 7e3a226 commit 5475f07
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/registrar/tests/test_utilities.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
from django.test import TestCase
from django.contrib.auth.models import User
from registrar.models import User
from waffle.testutils import override_flag
from registrar.utility.waffle import flag_is_active_for_user


class FlagIsActiveForUserTest(TestCase):

def setUp(self):
# Set up a test user
self.user = User.objects.create_user(username="testuser", password="testpassword")
self.user = User.objects.create_user(username="testuser")

@override_flag("test_flag", active=True)
def test_flag_active_for_user(self):
Expand Down
3 changes: 2 additions & 1 deletion src/registrar/utility/waffle.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from django.http import HttpRequest
from waffle.decorators import flag_is_active


def flag_is_active_for_user(user, flag_name):
"""flag_is_active_for_user can be used when a waffle_flag may be
activated for a user, but the context of where the flag needs to
be tested does not have a request object available.
When the request is available, flag_is_active should be used."""
request = HttpRequest()
request.user = user
return flag_is_active(request, flag_name)
return flag_is_active(request, flag_name)

0 comments on commit 5475f07

Please sign in to comment.