mirror of
https://github.com/ansible/awx.git
synced 2026-03-13 15:09:32 -02:30
Ported old/ha.py test
This commit is contained in:
@@ -1,24 +0,0 @@
|
|||||||
# Copyright (c) 2015 Ansible, Inc.
|
|
||||||
|
|
||||||
# Python
|
|
||||||
import mock
|
|
||||||
|
|
||||||
# Django
|
|
||||||
from django.test import SimpleTestCase
|
|
||||||
|
|
||||||
# AWX
|
|
||||||
from awx.main.models import * # noqa
|
|
||||||
from awx.main.ha import * # noqa
|
|
||||||
|
|
||||||
__all__ = ['HAUnitTest',]
|
|
||||||
|
|
||||||
class HAUnitTest(SimpleTestCase):
|
|
||||||
|
|
||||||
@mock.patch('awx.main.models.Instance.objects.count', return_value=2)
|
|
||||||
def test_multiple_instances(self, ignore):
|
|
||||||
self.assertTrue(is_ha_environment())
|
|
||||||
|
|
||||||
@mock.patch('awx.main.models.Instance.objects.count', return_value=1)
|
|
||||||
def test_db_localhost(self, ignore):
|
|
||||||
self.assertFalse(is_ha_environment())
|
|
||||||
|
|
||||||
15
awx/main/tests/unit/test_ha.py
Normal file
15
awx/main/tests/unit/test_ha.py
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
# Copyright (c) 2016 Ansible, Inc.
|
||||||
|
|
||||||
|
# Python
|
||||||
|
import mock
|
||||||
|
|
||||||
|
# AWX
|
||||||
|
from awx.main.ha import is_ha_environment
|
||||||
|
|
||||||
|
@mock.patch('awx.main.models.Instance.objects.count', lambda: 2)
|
||||||
|
def test_multiple_instances():
|
||||||
|
assert is_ha_environment()
|
||||||
|
|
||||||
|
@mock.patch('awx.main.models.Instance.objects.count', lambda: 1)
|
||||||
|
def test_db_localhost():
|
||||||
|
assert is_ha_environment() is False
|
||||||
Reference in New Issue
Block a user