Closed jsvob closed 4 years ago
In your test that exhibits the issue:
def test_doveconf():
c = Doveconf(context_wrap(CONF))
assert c['auth_anonymous_username'].value == 'anonymous'
assert c['auth_anonymous_username'].line == 'auth_anonymous_username = anonymous'
c
is a <class 'insights.parsers.doveconf.Doveconf'>
and when you execute c['some_key']
a <class 'insights.parsr.query.Result'>
is returned. Result
includes all children that match the query some_key
so you would normally use indexing c['some_key'][0]
to access the object you want, which in this case is a <class 'insights.parsr.query.Directive'>
object. Directive
is a subclass of <class 'insights.parsr.query.Entry'>
. Result
has a couple of convenience functions value
and string_value
that will return the value from the Entry object when there is only one child. line
was not one of the convenience functions but is being added by #2815.
Indeed. Didn't notice the difference between c['auth_anonymous_username']
and c['auth_anonymous_username'][0]
and the different types.
When the test at https://github.com/RedHatInsights/insights-core/pull/2797/files#r510509478 is changed to use [0]
, it passes.
Also, when https://github.com/RedHatInsights/insights-core/pull/2815 is used, it also passes (even without [0]
).
I'm going to leave https://github.com/RedHatInsights/insights-core/pull/2797/files#r510509478 as is until https://github.com/RedHatInsights/insights-core/pull/2815 is merged so as not to cause any more chaos.
Thanks!
Details: