|
8 | 8 |
|
9 | 9 | from django.contrib.auth.models import User |
10 | 10 | from django.core.cache import cache |
| 11 | +from django.conf import settings |
11 | 12 | from unittest import mock |
12 | 13 | from rest_framework.authtoken.models import Token |
13 | 14 |
|
@@ -36,6 +37,8 @@ def setUp(self): |
36 | 37 | self.app = App.objects.all()[0] |
37 | 38 |
|
38 | 39 | def tearDown(self): |
| 40 | + # Restore default tags to empty string |
| 41 | + settings.DEIS_DEFAULT_CONFIG_TAGS = '' |
39 | 42 | # make sure every test has a clean slate for k8s mocking |
40 | 43 | cache.clear() |
41 | 44 |
|
@@ -120,6 +123,37 @@ def test_config(self, mock_requests): |
120 | 123 | self.assertEqual(response.status_code, 405, response.data) |
121 | 124 | return config5 |
122 | 125 |
|
| 126 | + def test_default_tags(self, mock_requests): |
| 127 | + settings.DEIS_DEFAULT_CONFIG_TAGS = '{"ssd": "true"}' |
| 128 | + app_id = self.create_app() |
| 129 | + url = "/v2/apps/{app_id}/config".format(**locals()) |
| 130 | + |
| 131 | + response = self.client.get(url) |
| 132 | + expected = { |
| 133 | + 'owner': self.user.username, |
| 134 | + 'app': app_id, |
| 135 | + 'values': {}, |
| 136 | + 'memory': {}, |
| 137 | + 'cpu': {}, |
| 138 | + 'tags': {'ssd': 'true'}, |
| 139 | + 'registry': {} |
| 140 | + } |
| 141 | + self.assertDictContainsSubset(expected, response.data) |
| 142 | + |
| 143 | + # make sure changes not drop tags |
| 144 | + body = {'values': json.dumps({'PORT': '5001'})} |
| 145 | + response = self.client.post(url, body) |
| 146 | + expected = { |
| 147 | + 'owner': self.user.username, |
| 148 | + 'app': app_id, |
| 149 | + 'values': {'PORT': '5001'}, |
| 150 | + 'memory': {}, |
| 151 | + 'cpu': {}, |
| 152 | + 'tags': {'ssd': 'true'}, |
| 153 | + 'registry': {} |
| 154 | + } |
| 155 | + self.assertDictContainsSubset(expected, response.data) |
| 156 | + |
123 | 157 | def test_response_data(self, mock_requests): |
124 | 158 | """Test that the serialized response contains only relevant data.""" |
125 | 159 | app_id = self.create_app() |
|
0 commit comments