Skip to content

Commit 8a55e2c

Browse files
authored
Merge pull request #751 from cderici/check-subordinate-field-value
#751 #### Description This checks the `subordinate` field value from `default-release.revision` from charmhub. Previously we were just checking if it exists. fixes #750 #### QA Steps ``` tox -e integration -- tests/integration/test_charmhub.py::test_subordinate_false_field_exists ```
2 parents 35ef84f + 072b2d6 commit 8a55e2c

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

juju/charmhub.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ async def is_subordinate(self, charm_name):
3838
url = "{}/v2/charms/info/{}?fields=default-release.revision.subordinate".format(charmhub_url.value, charm_name)
3939
_response = await self.request_charmhub_with_retry(url, 5)
4040
response = json.loads(_response.text)
41-
return 'subordinate' in response['default-release']['revision']
41+
rev_response = response['default-release']['revision']
42+
return 'subordinate' in rev_response and rev_response['subordinate']
4243

4344
# TODO (caner) : we should be able to recreate the channel-map through the
4445
# api call without needing the CharmHub facade

tests/integration/test_charmhub.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,14 @@ async def test_subordinate_charm_zero_units(event_loop):
121121
assert len(app2.units) == 0
122122

123123

124+
@base.bootstrapped
125+
@pytest.mark.asyncio
126+
async def test_subordinate_false_field_exists(event_loop):
127+
async with base.CleanModel() as model:
128+
assert await model.charmhub.is_subordinate("rsyslog-forwarder-ha")
129+
assert not await model.charmhub.is_subordinate("mysql-innodb-cluster")
130+
131+
124132
@base.bootstrapped
125133
@pytest.mark.asyncio
126134
async def test_list_resources(event_loop):

0 commit comments

Comments
 (0)