File: __init__.py

package info (click to toggle)
python-openshift 0.13.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 332 kB
  • sloc: python: 1,824; makefile: 20; sh: 14
file content (29 lines) | stat: -rw-r--r-- 969 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import unittest

from kubernetes import config
from kubernetes.client import api_client, Configuration

from openshift.dynamic import DynamicClient

class RestClientTestCase(unittest.TestCase):

    @classmethod
    def setUpClass(cls):
        try:
            config.load_kube_config()
        except config.ConfigException:
            config.load_incluster_config()
        cls.config = Configuration.get_default_copy()
        cls.client = DynamicClient(api_client.ApiClient(configuration=cls.config))

    def setUp(self):
        # Generate a namespace name from the test case name
        self.namespace = self.id().split('.')[-1].replace('_', '-')
        v1_namespaces = self.client.resources.get(api_version='v1', kind='Namespace')

        self.addCleanup(v1_namespaces.delete, name=self.namespace)
        v1_namespaces.create(body=dict(
            apiVersion='v1',
            kind='Namespace',
            metadata=dict(name=self.namespace),
        ))