mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 18:09:57 -03:30
Merge pull request #1617 from anoek/unit-test-cleanup
Test cleanup and slow test separation
This commit is contained in:
commit
545fa95d87
5
Makefile
5
Makefile
@ -427,16 +427,17 @@ pylint: reports
|
||||
|
||||
check: flake8 pep8 # pyflakes pylint
|
||||
|
||||
TEST_DIRS=awx/main/tests
|
||||
# Run all API unit tests.
|
||||
test:
|
||||
py.test awx/main/tests awx/api/tests
|
||||
py.test $(TEST_DIRS)
|
||||
|
||||
test_unit:
|
||||
py.test awx/main/tests/unit
|
||||
|
||||
# Run all API unit tests with coverage enabled.
|
||||
test_coverage:
|
||||
py.test --create-db --cov=awx --cov-report=xml --junitxml=./reports/junit.xml awx/main/tests awx/api/tests
|
||||
py.test --create-db --cov=awx --cov-report=xml --junitxml=./reports/junit.xml $(TEST_DIRS)
|
||||
|
||||
# Output test coverage as HTML (into htmlcov directory).
|
||||
coverage_html:
|
||||
|
||||
@ -1,7 +0,0 @@
|
||||
# Copyright (c) 2015 Ansible, Inc.
|
||||
# All Rights Reserved.
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
from .decorator_paginated import PaginatedDecoratorTests # noqa
|
||||
from .job_tasks import JobTasksTests # noqa
|
||||
@ -7,6 +7,8 @@ import os
|
||||
import subprocess
|
||||
import tempfile
|
||||
import mock
|
||||
import unittest2 as unittest
|
||||
|
||||
|
||||
# Django
|
||||
from django.conf import settings
|
||||
@ -58,6 +60,7 @@ class BaseAdHocCommandTest(BaseJobExecutionTest):
|
||||
return self.credential
|
||||
|
||||
|
||||
@unittest.skipIf(os.environ.get('SKIP_SLOW_TESTS', False), 'Skipping slow test')
|
||||
class RunAdHocCommandTest(BaseAdHocCommandTest):
|
||||
'''
|
||||
Test cases for RunAdHocCommand celery task.
|
||||
@ -375,6 +378,7 @@ class RunAdHocCommandTest(BaseAdHocCommandTest):
|
||||
def run_pexpect_mock(self, *args, **kwargs):
|
||||
return 'successful', 0
|
||||
|
||||
@unittest.skipIf(os.environ.get('SKIP_SLOW_TESTS', False), 'Skipping slow test')
|
||||
class AdHocCommandApiTest(BaseAdHocCommandTest):
|
||||
'''
|
||||
Test API list/detail views for ad hoc commands.
|
||||
|
||||
@ -108,6 +108,7 @@ grandchild
|
||||
parent
|
||||
'''
|
||||
|
||||
|
||||
class BaseCommandMixin(object):
|
||||
'''
|
||||
Base class for tests that run management commands.
|
||||
@ -381,6 +382,7 @@ class CleanupJobsTest(BaseCommandMixin, BaseLiveServerTest):
|
||||
self.assertFalse(ad_hoc_commands_after)
|
||||
|
||||
|
||||
@unittest.skipIf(os.environ.get('SKIP_SLOW_TESTS', False), 'Skipping slow test')
|
||||
class CleanupActivityStreamTest(BaseCommandMixin, BaseTest):
|
||||
'''
|
||||
Test cases for cleanup_activitystream management command.
|
||||
@ -447,6 +449,7 @@ class CleanupActivityStreamTest(BaseCommandMixin, BaseTest):
|
||||
'create took %0.3fs, cleanup took %0.3fs, expected < %0.3fs' % (create_elapsed, cleanup_elapsed, create_elapsed / 4))
|
||||
|
||||
|
||||
@unittest.skipIf(os.environ.get('SKIP_SLOW_TESTS', False), 'Skipping slow test')
|
||||
class InventoryImportTest(BaseCommandMixin, BaseLiveServerTest):
|
||||
'''
|
||||
Test cases for inventory_import management command.
|
||||
@ -935,6 +938,11 @@ class InventoryImportTest(BaseCommandMixin, BaseLiveServerTest):
|
||||
self.assertNotEqual(new_inv.total_groups, 0)
|
||||
self.assertElapsedLessThan(60)
|
||||
|
||||
@unittest.skipIf(True,
|
||||
'This test is deprecated and being removed from '
|
||||
'integration and unit tests in favor of writing '
|
||||
'an explicit unit test around what the original '
|
||||
'problem was')
|
||||
def test_splunk_inventory(self):
|
||||
new_inv = self.organizations[0].inventories.create(name='splunk')
|
||||
self.assertEqual(new_inv.hosts.count(), 0)
|
||||
|
||||
@ -8,6 +8,8 @@ import os
|
||||
import re
|
||||
import tempfile
|
||||
import time
|
||||
import unittest2 as unittest
|
||||
|
||||
|
||||
# Django
|
||||
from django.conf import settings
|
||||
@ -37,6 +39,7 @@ inventory['group-\u037c\u03b4\u0138\u0137\u03cd\u03a1\u0121\u0137\u0138\u01a1'].
|
||||
print json.dumps(inventory)
|
||||
"""
|
||||
|
||||
@unittest.skipIf(os.environ.get('SKIP_SLOW_TESTS', False), 'Skipping slow test')
|
||||
class InventoryTest(BaseTest):
|
||||
|
||||
def setUp(self):
|
||||
@ -1097,6 +1100,7 @@ class InventoryTest(BaseTest):
|
||||
self.assertEqual(response['hosts']['failed'], 8)
|
||||
|
||||
|
||||
@unittest.skipIf(os.environ.get('SKIP_SLOW_TESTS', False), 'Skipping slow test')
|
||||
@override_settings(CELERY_ALWAYS_EAGER=True,
|
||||
CELERY_EAGER_PROPAGATES_EXCEPTIONS=True,
|
||||
IGNORE_CELERY_INSPECTOR=True,
|
||||
|
||||
@ -3,6 +3,8 @@
|
||||
|
||||
# Python
|
||||
from __future__ import absolute_import
|
||||
import os
|
||||
import unittest2 as unittest
|
||||
|
||||
# Django
|
||||
import django
|
||||
@ -15,6 +17,7 @@ import yaml
|
||||
|
||||
__all__ = ['JobTemplateLaunchTest', 'JobTemplateLaunchPasswordsTest']
|
||||
|
||||
@unittest.skipIf(os.environ.get('SKIP_SLOW_TESTS', False), 'Skipping slow test')
|
||||
class JobTemplateLaunchTest(BaseJobTestMixin, django.test.TransactionTestCase):
|
||||
def setUp(self):
|
||||
super(JobTemplateLaunchTest, self).setUp()
|
||||
@ -183,6 +186,7 @@ class JobTemplateLaunchTest(BaseJobTestMixin, django.test.TransactionTestCase):
|
||||
with self.current_user(self.user_sue):
|
||||
self.post(self.launch_url, {}, expect=400)
|
||||
|
||||
@unittest.skipIf(os.environ.get('SKIP_SLOW_TESTS', False), 'Skipping slow test')
|
||||
class JobTemplateLaunchPasswordsTest(BaseJobTestMixin, django.test.TransactionTestCase):
|
||||
def setUp(self):
|
||||
super(JobTemplateLaunchPasswordsTest, self).setUp()
|
||||
|
||||
@ -9,6 +9,9 @@ import struct
|
||||
import threading
|
||||
import time
|
||||
import urlparse
|
||||
import os
|
||||
import unittest2 as unittest
|
||||
|
||||
|
||||
# Django
|
||||
import django.test
|
||||
@ -183,6 +186,7 @@ TEST_SURVEY_REQUIREMENTS = '''
|
||||
}
|
||||
'''
|
||||
|
||||
@unittest.skipIf(os.environ.get('SKIP_SLOW_TESTS', False), 'Skipping slow test')
|
||||
class JobTemplateTest(BaseJobTestMixin, django.test.TransactionTestCase):
|
||||
|
||||
JOB_TEMPLATE_FIELDS = ('id', 'type', 'url', 'related', 'summary_fields',
|
||||
@ -501,6 +505,7 @@ class JobTemplateTest(BaseJobTestMixin, django.test.TransactionTestCase):
|
||||
with self.current_user(self.user_doug):
|
||||
self.get(detail_url, expect=403)
|
||||
|
||||
@unittest.skipIf(os.environ.get('SKIP_SLOW_TESTS', False), 'Skipping slow test')
|
||||
class JobTest(BaseJobTestMixin, django.test.TransactionTestCase):
|
||||
|
||||
def test_get_job_list(self):
|
||||
@ -653,6 +658,7 @@ class JobTest(BaseJobTestMixin, django.test.TransactionTestCase):
|
||||
# and that jobs come back nicely serialized with related resources and so on ...
|
||||
# that we can drill all the way down and can get at host failure lists, etc ...
|
||||
|
||||
@unittest.skipIf(os.environ.get('SKIP_SLOW_TESTS', False), 'Skipping slow test')
|
||||
@override_settings(CELERY_ALWAYS_EAGER=True,
|
||||
CELERY_EAGER_PROPAGATES_EXCEPTIONS=True,
|
||||
ANSIBLE_TRANSPORT='local')
|
||||
@ -1028,6 +1034,7 @@ class JobTemplateCallbackTest(BaseJobTestMixin, django.test.LiveServerTestCase):
|
||||
self.post(url, data, expect=400, remote_addr=host_ip)
|
||||
|
||||
|
||||
@unittest.skipIf(os.environ.get('SKIP_SLOW_TESTS', False), 'Skipping slow test')
|
||||
@override_settings(CELERY_ALWAYS_EAGER=True,
|
||||
CELERY_EAGER_PROPAGATES_EXCEPTIONS=True,
|
||||
ANSIBLE_TRANSPORT='local')
|
||||
@ -1092,6 +1099,7 @@ class JobTransactionTest(BaseJobTestMixin, django.test.LiveServerTestCase):
|
||||
self.assertEqual(job.status, 'successful', job.result_stdout)
|
||||
self.assertFalse(errors)
|
||||
|
||||
@unittest.skipIf(os.environ.get('SKIP_SLOW_TESTS', False), 'Skipping slow test')
|
||||
class JobTemplateSurveyTest(BaseJobTestMixin, django.test.TransactionTestCase):
|
||||
def setUp(self):
|
||||
super(JobTemplateSurveyTest, self).setUp()
|
||||
|
||||
@ -3,6 +3,8 @@
|
||||
|
||||
# Python
|
||||
from __future__ import absolute_import
|
||||
import os
|
||||
import unittest2 as unittest
|
||||
|
||||
# Django
|
||||
from django.core.urlresolvers import reverse
|
||||
@ -15,6 +17,7 @@ from awx.main.tests.job_base import BaseJobTestMixin
|
||||
|
||||
__all__ = ['JobStartCancelTest',]
|
||||
|
||||
@unittest.skipIf(os.environ.get('SKIP_SLOW_TESTS', False), 'Skipping slow test')
|
||||
class JobStartCancelTest(BaseJobTestMixin, BaseLiveServerTest):
|
||||
|
||||
def test_job_start(self):
|
||||
|
||||
@ -237,6 +237,7 @@ TEST_VAULT_PLAYBOOK = '''$ANSIBLE_VAULT;1.1;AES256
|
||||
|
||||
TEST_VAULT_PASSWORD = '1234'
|
||||
|
||||
@unittest.skipIf(os.environ.get('SKIP_SLOW_TESTS', False), 'Skipping slow test')
|
||||
class RunJobTest(BaseJobExecutionTest):
|
||||
'''
|
||||
Test cases for RunJob celery task.
|
||||
@ -337,10 +338,9 @@ class RunJobTest(BaseJobExecutionTest):
|
||||
print
|
||||
qs = self.super_django_user.get_queryset(JobEvent)
|
||||
for je in qs.filter(job=job):
|
||||
print je.get_event_display2()
|
||||
print je.event, je, je.failed
|
||||
print je.event_data
|
||||
print
|
||||
print(je.get_event_display2())
|
||||
print(je.event, je, je.failed)
|
||||
print(je.event_data)
|
||||
for job_event in job_events:
|
||||
unicode(job_event) # For test coverage.
|
||||
job_event.save()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user