def test_delete_template(self): client = OpenshiftClient(self.config) template = { 'apiVersion': 'v1', 'kind': 'Template', 'metadata': { 'name': 'test' }, 'objects': [{ 'apiVersion': 'v1', 'kind': 'BuildConfig', 'metadata': { 'name': 'test' } }] } with patch.object(client.session, 'request', return_value=helper.make_response(200, template)): try: client.delete(template) except KubeRequestError: self.fail('delete raised KubeRequestError unexpectedly')
def test_request_patch(self): client = KubeBase(self.config) with patch.object(client.session, 'request', return_value=helper.make_response(201, {})): data = client.request('patch', 'http://localhost:8080', [ {'op': 'replace', 'path': '/spec/replicas', 'value': 0} ]) self.assertEqual(data, {})
def test_create(self): client = OpenshiftClient(self.config) with patch.object(client.session, 'request', return_value=helper.make_response(200, {})): try: client.create({ 'apiVersion': 'v1', 'kind': 'BuildConfig', 'metadata': { 'name': 'test' } }) except KubeRequestError: self.fail('create raised KubeRequestError unexpectedly')
def test_request_no_data(self): client = KubeBase(self.config) with patch.object(client.session, 'request', return_value=helper.make_response(200, None)): data = client.request('get', 'http://localhost:8080') self.assertIsNone(data)
def test_request_response_error(self): client = KubeBase(self.config) with patch.object(client.session, 'request', return_value=helper.make_response(400, None)): with self.assertRaises(KubeRequestError): client.request('get', 'http://localhost:8080')
def test_by_selector_empty(self): client = KubeBase(self.config) with patch.object(client.session, 'request', return_value=helper.make_response(200, {})): data = client.nodes().by_selector(None) self.assertEqual(data, [])
def test_filters_status(self): client = KubeBase(self.config) with patch.object(client.session, 'request', return_value=helper.make_response(200, {})): data = client.nodes().filter(status='Running') self.assertEqual(data, [])
def test_metadata(self): client = KubeBase(self.config) with patch.object(client.session, 'request', return_value=helper.make_response(200, {})): data = client.nodes().metadata() self.assertEqual(data, [])
def test_by_name_simple(self): client = KubeBase(self.config) with patch.object(client.session, 'request', return_value=helper.make_response(200, {})): data = client.nodes().by_name('test') self.assertEqual(data, {})