Skip to content

Commit

Permalink
add get_obj_root_owner tests
Browse files Browse the repository at this point in the history
  • Loading branch information
maorfr committed Jun 14, 2021
1 parent f4abb55 commit cd7574e
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions reconcile/test/test_utils_oc.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,43 @@ def test_validate_pod_ready_one_missing(self, oc_get):
with self.assertRaises(PodNotReadyError):
# Bypass the retry stuff
oc.validate_pod_ready.__wrapped__(oc, 'namespace', 'podname')


class TestGetObjRootOwner(TestCase):
@patch.object(OC, 'get')
def test_owner(self, oc_get):
obj = {
'metadata': {
'name': 'pod1',
'ownerReferences': [
{
'controller': True,
'kind': 'ownerkind',
'name': 'ownername'
}
]
}
}
owner_obj = {
'kind': 'ownerkind',
'metadata': {'name': 'ownername'}
}

oc_get.side_effect = [
owner_obj
]

oc = OC('server', 'token', local=True)
result_owner_obj = oc.get_obj_root_owner('namespace', obj)
self.assertEqual(result_owner_obj, owner_obj)

def test_no_owner(self):
obj = {
'metadata': {
'name': 'pod1',
}
}

oc = OC('server', 'token', local=True)
result_obj = oc.get_obj_root_owner('namespace', obj)
self.assertEqual(result_obj, obj)

0 comments on commit cd7574e

Please sign in to comment.