MozDef/tests/conftest.py

46 строки
2.3 KiB
Python
Исходник Обычный вид История

2017-06-02 02:13:23 +03:00
#!/usr/bin/env python
2017-06-02 02:13:23 +03:00
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# Copyright (c) 2017 Mozilla Corporation
2017-12-27 06:52:00 +03:00
import time
def pytest_addoption(parser):
parser.addoption(
"--delete_indexes",
action='store_true',
default=False,
help="A flag to indicate if we should delete all indexes in ES before each test. This could result in inconsistent tests if not specified."
)
2017-09-09 00:40:24 +03:00
parser.addoption(
"--delete_queues",
action='store_true',
default=False,
help="A flag to indicate if we should delete the contents of rabbitmq queues. This could result in inconsistent tests if not specified."
)
2017-09-28 22:23:15 +03:00
def pytest_configure(config):
warning_text = ""
if not config.option.delete_indexes:
warning_text += "\n** WARNING - Some unit tests will not pass unless the --delete_indexes is specified."
warning_text += "\nThis is due to the fact that some tests need a 'clean' ES environment **\n"
warning_text += "** DISCLAIMER - If you enable this flag, all indexes that MozDef uses will be deleted upon test execution **\n"
else:
warning_text += "\n** WARNING - The --delete_indexes flag has been set. We will be deleting important indexes from ES before test execution**\n"
warning_text += "Continuing the unit test execution in 10 seconds...CANCEL ME IF YOU DO NOT WANT PREVIOUS INDEXES DELETED!!! **\n"
if not config.option.delete_queues:
warning_text += "\n** WARNING - Some unit tests will not pass unless the --delete_queues is specified."
warning_text += "\nThis is due to the fact that some tests need a 'clean' RabbitMQ environment **\n"
warning_text += "** DISCLAIMER - If you enable this flag, the queues in rabbitmq that MozDef uses will be deleted upon test execution **\n"
else:
warning_text += "\n** WARNING - The --delete_queues flag has been set. We will be purging RabbitMQ queues before test execution**\n"
warning_text += "Continuing the unit test execution in 10 seconds...CANCEL ME IF YOU DO NOT WANT PREVIOUS QUEUES PURGED!!! **\n"
print warning_text
time.sleep(10)