-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy path__init__.py
More file actions
35 lines (29 loc) · 1.12 KB
/
__init__.py
File metadata and controls
35 lines (29 loc) · 1.12 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
from django.core.cache import cache
from django.test import TestCase as DjangoTestCase
from django.conf import settings
from scheduler import mock
from scheduler.tests.utils import generate_random_name
class TestCase(DjangoTestCase):
def setUp(self):
self.scheduler = mock.MockSchedulerClient(settings.SCHEDULER_URL)
# 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.ns.create(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')
metadata = {
'name': namespace,
'labels': {
'heritage': 'drycc'
}
}
self.assertEqual(data['metadata'], metadata | data['metadata'])
return namespace