Skip to content

Commit

Permalink
strip whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
keelerm84 committed Aug 20, 2024
1 parent ee80f9a commit 5bfdde6
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions ldclient/testing/test_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,22 +110,22 @@ def test_get_built_in_attribute_by_name(self):
assert c.get('kind') == 'b'
assert c.get('name') == 'c'
assert c.get('anonymous') is True

def test_get_unknown_attribute(self):
c = Context.create('a')
assert c.get('b') is None

def test_private_attributes(self):
assert list(Context.create('a').private_attributes) == []

c = Context.builder('a').private('b', '/c/d').private('e').build()
assert list(c.private_attributes) == ['b', '/c/d', 'e']

def test_fully_qualified_key(self):
assert Context.create('key1').fully_qualified_key == 'key1'
assert Context.create('key1', 'kind1').fully_qualified_key == 'kind1:key1'
assert Context.create('key%with:things', 'kind1').fully_qualified_key == 'kind1:key%25with%3Athings'

def test_builder_from_context(self):
c1 = Context.builder('a').kind('kind1').name('b').set('c', True).private('d').build()
b = Context.builder_from_context(c1)
Expand Down Expand Up @@ -167,7 +167,7 @@ def _assert_contexts_from_factory_equal(fn):
Context.create_multi(Context.create('a', 'kind1'), Context.create('b', 'kind2'))
assert Context.create_multi(Context.create('a', 'kind1'), Context.create('b', 'kind2')) != \
Context.create('a', 'kind1')

_assert_contexts_from_factory_equal(lambda: Context.create('invalid', 'kind'))
assert Context.create('invalid', 'kind') != Context.create_multi() # different errors

Expand Down Expand Up @@ -195,10 +195,10 @@ def test_json_decoding(self):
Context.builder('key1').kind('kind1').anonymous(True).build()
assert Context.from_dict({'kind': 'kind1', 'key': 'key1', '_meta': {'privateAttributes': ['b']}}) == \
Context.builder('key1').kind('kind1').private('b').build()

assert Context.from_dict({'kind': 'multi', 'kind1': {'key': 'key1'}, 'kind2': {'key': 'key2'}}) == \
Context.create_multi(Context.create('key1', 'kind1'), Context.create('key2', 'kind2'))

assert_context_invalid(Context.from_dict({'kind': 'kind1'}))
assert_context_invalid(Context.from_dict({'kind': 'kind1', 'key': 3}))
assert_context_invalid(Context.from_dict({'kind': 'multi'}))
Expand Down Expand Up @@ -256,33 +256,33 @@ class TestContextErrors:
def test_key_empty_string(self):
assert_context_invalid(Context.create(''))
assert_context_invalid(Context.builder('').build())

@pytest.mark.parametrize('kind', ['kind', 'multi', 'b$c', ''])
def test_kind_invalid_strings(self, kind):
assert_context_invalid(Context.create('a', kind))
assert_context_invalid(Context.builder('a').kind(kind).build())

def test_create_multi_with_no_contexts(self):
assert_context_invalid(Context.create_multi())

def test_multi_builder_with_no_contexts(self):
assert_context_invalid(Context.multi_builder().build())

def test_create_multi_with_duplicate_kind(self):
c1 = Context.create('a', 'kind1')
c2 = Context.create('b', 'kind1')
assert_context_invalid(Context.create_multi(c1, c2))

def test_multi_builder_with_duplicate_kind(self):
c1 = Context.create('a', 'kind1')
c2 = Context.create('b', 'kind1')
assert_context_invalid(Context.multi_builder().add(c1).add(c2).build())

def test_create_multi_with_invalid_context(self):
c1 = Context.create('a', 'kind1')
c2 = Context.create('')
assert_context_invalid(Context.create_multi(c1, c2))

def test_multi_builder_with_invalid_context(self):
c1 = Context.create('a', 'kind1')
c2 = Context.create('')
Expand Down

0 comments on commit 5bfdde6

Please sign in to comment.