Skip to content

Commit

Permalink
Take advantage of __eq__ in feature flag tests
Browse files Browse the repository at this point in the history
  • Loading branch information
imjoehaines committed Jul 21, 2023
1 parent 77e5039 commit ba0ce8b
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions tests/test_feature_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,28 +387,23 @@ def test_delegate_clear_does_nothing_when_there_are_no_flags():

def test_delegate_to_list_returns_a_list_of_feature_flags():
delegate = FeatureFlagDelegate()
delegate.merge([FeatureFlag('a'), FeatureFlag('b'), FeatureFlag('c')])

flag1 = FeatureFlag('a')
flag2 = FeatureFlag('b')
flag3 = FeatureFlag('c')

delegate.merge([flag1, flag2, flag3])

assert delegate.to_list() == [flag1, flag2, flag3]
assert delegate.to_list() == [
FeatureFlag('a'),
FeatureFlag('b'),
FeatureFlag('c')
]


def test_delegate_can_be_mutated_without_affecting_the_internal_storage():
delegate = FeatureFlagDelegate()

flag1 = FeatureFlag('a')
flag2 = FeatureFlag('b')

delegate.merge([flag1, flag2])
delegate.merge([FeatureFlag('a'), FeatureFlag('b')])

flags = delegate.to_list()
flags.pop()
flags.append(1234)
flags.append(5678)

assert flags == [flag1, 1234, 5678]
assert delegate.to_list() == [flag1, flag2]
assert flags == [FeatureFlag('a'), 1234, 5678]
assert delegate.to_list() == [FeatureFlag('a'), FeatureFlag('b')]

0 comments on commit ba0ce8b

Please sign in to comment.