Skip to content

Commit 9995ca4

Browse files
author
Keerthan Mala
committed
patch the get_port function
1 parent 1ebdfa8 commit 9995ca4

7 files changed

Lines changed: 16 additions & 0 deletions

File tree

rootfs/api/tests/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
from django.test.runner import DiscoverRunner
88

99

10+
def mock_port(*args, **kwargs):
11+
return 5000
12+
13+
1014
# Mock out router requests and add in some jitter
1115
# Used for application is available in router checks
1216
def fake_responses(request, context):

rootfs/api/tests/test_app.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from scheduler import KubeException
1818

1919
from . import adapter
20+
from . import mock_port
2021
import requests_mock
2122

2223

@@ -30,6 +31,7 @@ def _mock_run(*args, **kwargs):
3031

3132
@requests_mock.Mocker(real_http=True, adapter=adapter)
3233
@mock.patch('api.models.release.publish_release', lambda *args: None)
34+
@mock.patch('scheduler.KubeHTTPClient._get_port', mock_port)
3335
class AppTest(APITestCase):
3436
"""Tests creation of applications"""
3537

rootfs/api/tests/test_build.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@
1919
from scheduler import KubeException
2020

2121
from . import adapter
22+
from . import mock_port
2223
import requests_mock
2324

2425

2526
@requests_mock.Mocker(real_http=True, adapter=adapter)
2627
@mock.patch('api.models.release.publish_release', lambda *args: None)
28+
@mock.patch('scheduler.KubeHTTPClient._get_port', mock_port)
2729
class BuildTest(APITransactionTestCase):
2830

2931
"""Tests build notification from build system"""

rootfs/api/tests/test_config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@
1515
from api.models import App, Config
1616

1717
from . import adapter
18+
from . import mock_port
1819
import requests_mock
1920

2021

2122
@requests_mock.Mocker(real_http=True, adapter=adapter)
2223
@mock.patch('api.models.release.publish_release', lambda *args: None)
24+
@mock.patch('scheduler.KubeHTTPClient._get_port', mock_port)
2325
class ConfigTest(APITransactionTestCase):
2426

2527
"""Tests setting and updating config values"""

rootfs/api/tests/test_hooks.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from rest_framework.authtoken.models import Token
1212

1313
from . import adapter
14+
from . import mock_port
1415
import requests_mock
1516

1617
RSA_PUBKEY = (
@@ -34,6 +35,7 @@
3435

3536
@requests_mock.Mocker(real_http=True, adapter=adapter)
3637
@mock.patch('api.models.release.publish_release', lambda *args: None)
38+
@mock.patch('scheduler.KubeHTTPClient._get_port', mock_port)
3739
class HookTest(APITransactionTestCase):
3840

3941
"""Tests API hooks used to trigger actions from external components"""

rootfs/api/tests/test_pods.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@
1818
from scheduler import KubeException
1919

2020
from . import adapter
21+
from . import mock_port
2122
import requests_mock
2223

2324

2425
@requests_mock.Mocker(real_http=True, adapter=adapter)
2526
@mock.patch('api.models.release.publish_release', lambda *args: None)
27+
@mock.patch('scheduler.KubeHTTPClient._get_port', mock_port)
2628
class PodTest(APITransactionTestCase):
2729
"""Tests creation of pods on nodes"""
2830

rootfs/api/tests/test_release.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@
1717
from api.models import Release
1818
from scheduler import KubeHTTPException
1919
from . import adapter
20+
from . import mock_port
2021
import requests_mock
2122

2223

2324
@requests_mock.Mocker(real_http=True, adapter=adapter)
2425
@mock.patch('api.models.release.publish_release', lambda *args: None)
26+
@mock.patch('scheduler.KubeHTTPClient._get_port', mock_port)
2527
class ReleaseTest(APITransactionTestCase):
2628

2729
"""Tests push notification from build system"""

0 commit comments

Comments
 (0)