-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtest_workflow_manager.py
More file actions
57 lines (47 loc) · 1.86 KB
/
test_workflow_manager.py
File metadata and controls
57 lines (47 loc) · 1.86 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# -*- coding: utf-8 -*-
"""
Unit tests for the Drycc api app.
Run the tests with "./manage.py test api"
"""
import base64
from django.core.cache import cache
from django.conf import settings
from django.contrib.auth import get_user_model
from api.tests import adapter, DryccTransactionTestCase
import requests_mock
User = get_user_model()
@requests_mock.Mocker(real_http=True, adapter=adapter)
class ManagerTest(DryccTransactionTestCase):
"""Tests setting and updating config values"""
fixtures = ['tests.json']
def setUp(self):
self.user = User.objects.get(username='autotest')
self.token = self.get_or_create_token(self.user)
self.client.credentials(HTTP_AUTHORIZATION='Token ' + self.token)
self.app_id = self.create_app()
self.user_id = 7
# workflow manager token
token = base64.b85encode(b"%s:%s" % (
settings.WORKFLOW_MANAGER_ACCESS_KEY.encode("utf8"),
settings.WORKFLOW_MANAGER_SECRET_KEY.encode("utf8"),
)).decode("utf8")
self.client.credentials(HTTP_AUTHORIZATION='Token ' + token)
def tearDown(self):
# make sure every test has a clean slate for k8s mocking
cache.clear()
def test_block(self, mock_requests):
response = self.client.post(
'/v2/manager/{}/{}/block/'.format("apps", self.app_id),
data={'remark': 'Arrears blockade'},
)
self.assertEqual(response.status_code, 201)
def test_unblock(self, mock_requests):
response = self.client.post(
'/v2/manager/{}/{}/block/'.format("apps", self.app_id),
data={'remark': 'Arrears blockade'},
)
self.assertEqual(response.status_code, 201)
response = self.client.delete(
'/v2/manager/{}/{}/unblock/'.format("apps", self.app_id),
)
self.assertEqual(response.status_code, 204)