diff --git a/awx/main/tests/activity_stream.py b/awx/main/tests/activity_stream.py index a2e233569e..fd2d2e340e 100644 --- a/awx/main/tests/activity_stream.py +++ b/awx/main/tests/activity_stream.py @@ -29,6 +29,7 @@ class ActivityStreamTest(BaseTest): def setUp(self): super(ActivityStreamTest, self).setUp() + self.setup_instances() self.setup_users() self.org_created = self.post(reverse('api:organization_list'), dict(name='test org', description='test descr'), expect=201, auth=self.get_super_credentials()) diff --git a/awx/main/tests/base.py b/awx/main/tests/base.py index 3a354d53e9..4afa188755 100644 --- a/awx/main/tests/base.py +++ b/awx/main/tests/base.py @@ -69,6 +69,9 @@ class BaseTestMixin(object): os.environ['AWX_TEST_DATABASE_%s' % opt] = settings.DATABASES['default'][opt] # Set flag so that task chain works with unit tests. settings.CELERY_UNIT_TEST = True + settings.SYSTEM_UUID='00000000-0000-0000-0000-000000000000' + settings.BROKER_URL='redis://localhost:16379/' + # Create unique random consumer and queue ports for zeromq callback. if settings.CALLBACK_CONSUMER_PORT: callback_port = random.randint(55700, 55799) @@ -214,6 +217,10 @@ class BaseTestMixin(object): )) return results + def setup_instances(self): + instance = Instance(uuid=settings.SYSTEM_UUID, primary=True, ip_address='127.0.0.1') + instance.save() + def setup_users(self, just_super_user=False): # Create a user. self.super_username = 'admin' @@ -479,8 +486,6 @@ class BaseTestMixin(object): self.redis_process = None -@override_settings(SYSTEM_UUID='00000000-0000-0000-0000-000000000000', - BROKER_URL='redis://localhost:16379/') class BaseTest(BaseTestMixin, django.test.TestCase): ''' Base class for unit tests. diff --git a/awx/main/tests/commands.py b/awx/main/tests/commands.py index e015885296..39cda14201 100644 --- a/awx/main/tests/commands.py +++ b/awx/main/tests/commands.py @@ -104,6 +104,7 @@ class BaseCommandMixin(object): ''' def create_test_inventories(self): + self.setup_instances() self.setup_users() self.organizations = self.make_organizations(self.super_django_user, 2) self.projects = self.make_projects(self.normal_django_user, 2) diff --git a/awx/main/tests/inventory.py b/awx/main/tests/inventory.py index 80d36d8f98..c402e61c24 100644 --- a/awx/main/tests/inventory.py +++ b/awx/main/tests/inventory.py @@ -28,6 +28,7 @@ class InventoryTest(BaseTest): def setUp(self): self.start_redis() super(InventoryTest, self).setUp() + self.setup_instances() self.setup_users() self.organizations = self.make_organizations(self.super_django_user, 3) self.organizations[0].admins.add(self.normal_django_user) diff --git a/awx/main/tests/jobs.py b/awx/main/tests/jobs.py index 80ff23beff..3a4898d8fc 100644 --- a/awx/main/tests/jobs.py +++ b/awx/main/tests/jobs.py @@ -200,6 +200,7 @@ class BaseJobTestMixin(BaseTestMixin): def setUp(self): self.start_redis() + self.setup_instances() super(BaseJobTestMixin, self).setUp() def tearDown(self): diff --git a/awx/main/tests/licenses.py b/awx/main/tests/licenses.py index e7271b7704..fe9ce58461 100644 --- a/awx/main/tests/licenses.py +++ b/awx/main/tests/licenses.py @@ -17,6 +17,7 @@ class LicenseTests(BaseTest): def setUp(self): self.start_redis() + self.setup_instances() super(LicenseTests, self).setUp() self.setup_users() u = self.super_django_user diff --git a/awx/main/tests/organizations.py b/awx/main/tests/organizations.py index 88d39038ac..af97cdf575 100644 --- a/awx/main/tests/organizations.py +++ b/awx/main/tests/organizations.py @@ -18,6 +18,7 @@ class OrganizationsTest(BaseTest): def setUp(self): super(OrganizationsTest, self).setUp() + self.setup_instances() self.setup_users() self.organizations = self.make_organizations(self.super_django_user, 10) diff --git a/awx/main/tests/projects.py b/awx/main/tests/projects.py index ced007ffdd..8a148bea32 100644 --- a/awx/main/tests/projects.py +++ b/awx/main/tests/projects.py @@ -42,6 +42,7 @@ class ProjectsTest(BaseTransactionTest): return reverse('api:project_list') def setUp(self): + self.setup_instances() super(ProjectsTest, self).setUp() self.setup_users() diff --git a/awx/main/tests/schedules.py b/awx/main/tests/schedules.py index c6883c37ce..15c7440ceb 100644 --- a/awx/main/tests/schedules.py +++ b/awx/main/tests/schedules.py @@ -58,6 +58,7 @@ class ScheduleTest(BaseTest): def setUp(self): super(ScheduleTest, self).setUp() self.start_redis() + self.setup_instances() self.setup_users() self.organizations = self.make_organizations(self.super_django_user, 2) self.organizations[0].admins.add(self.normal_django_user) diff --git a/awx/main/tests/scripts.py b/awx/main/tests/scripts.py index 4908e59cb2..095012b003 100644 --- a/awx/main/tests/scripts.py +++ b/awx/main/tests/scripts.py @@ -69,6 +69,7 @@ class InventoryScriptTest(BaseScriptTest): def setUp(self): super(InventoryScriptTest, self).setUp() self.start_redis() + self.setup_instances() self.setup_users() self.organizations = self.make_organizations(self.super_django_user, 2) self.projects = self.make_projects(self.normal_django_user, 2) diff --git a/awx/main/tests/tasks.py b/awx/main/tests/tasks.py index 0b401fb7ea..be1e7b4d26 100644 --- a/awx/main/tests/tasks.py +++ b/awx/main/tests/tasks.py @@ -358,6 +358,7 @@ class RunJobTest(BaseCeleryTest): def setUp(self): super(RunJobTest, self).setUp() self.test_project_path = None + self.setup_instances() self.setup_users() self.organization = self.make_organizations(self.super_django_user, 1)[0] self.inventory = self.organization.inventories.create(name='test-inventory', diff --git a/awx/main/tests/users.py b/awx/main/tests/users.py index c53dcaa632..03d9761db3 100644 --- a/awx/main/tests/users.py +++ b/awx/main/tests/users.py @@ -26,6 +26,7 @@ class UsersTest(BaseTest): return reverse('api:user_list') def setUp(self): + self.setup_instances() super(UsersTest, self).setUp() self.setup_users() self.organizations = self.make_organizations(self.super_django_user, 2)