-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy path__init__.py
More file actions
36 lines (30 loc) · 1.09 KB
/
__init__.py
File metadata and controls
36 lines (30 loc) · 1.09 KB
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
30
31
32
33
34
35
36
from django.core.cache import cache
from django.test import TestCase as DjangoTestCase
from scheduler import mock
from scheduler.utils import generate_random_name
class TestCase(DjangoTestCase):
def setUp(self):
self.scheduler = mock.MockSchedulerClient()
# have a namespace available at all times
self.namespace = self.create_namespace()
def tearDown(self):
# make sure every test has a clean slate for k8s mocking
cache.clear()
def create_namespace(self):
namespace = generate_random_name()
response = self.scheduler.create_namespace(namespace)
self.assertEqual(response.status_code, 201, response.json())
# assert minimal amount data
data = response.json()
self.assertEqual(data['apiVersion'], 'v1')
self.assertEqual(data['kind'], 'Namespace')
self.assertDictContainsSubset(
{
'name': namespace,
'labels': {
'heritage': 'deis'
}
},
data['metadata']
)
return namespace