зеркало из https://github.com/mozilla/MozDef.git
Modify super calls for python3
This commit is contained in:
Родитель
943507e819
Коммит
4d7f78e98f
|
@ -29,7 +29,7 @@ def mock_add_hostname_to_ip(ip):
|
||||||
class AlertTestSuite(UnitTestSuite):
|
class AlertTestSuite(UnitTestSuite):
|
||||||
def teardown(self):
|
def teardown(self):
|
||||||
os.chdir(self.orig_path)
|
os.chdir(self.orig_path)
|
||||||
super(AlertTestSuite, self).teardown()
|
super().teardown()
|
||||||
sys.path.remove(self.alerts_path)
|
sys.path.remove(self.alerts_path)
|
||||||
sys.path.remove(self.alerts_lib_path)
|
sys.path.remove(self.alerts_lib_path)
|
||||||
if 'lib' in sys.modules:
|
if 'lib' in sys.modules:
|
||||||
|
@ -37,7 +37,7 @@ class AlertTestSuite(UnitTestSuite):
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
self.orig_path = os.getcwd()
|
self.orig_path = os.getcwd()
|
||||||
super(AlertTestSuite, self).setup()
|
super().setup()
|
||||||
self.alerts_path = os.path.join(os.path.dirname(__file__), "../../alerts")
|
self.alerts_path = os.path.join(os.path.dirname(__file__), "../../alerts")
|
||||||
self.alerts_lib_path = os.path.join(os.path.dirname(__file__), "../../alerts/lib")
|
self.alerts_lib_path = os.path.join(os.path.dirname(__file__), "../../alerts/lib")
|
||||||
sys.path.insert(0, self.alerts_path)
|
sys.path.insert(0, self.alerts_path)
|
||||||
|
|
|
@ -42,7 +42,7 @@ class TestHostnameFromIP(AlertTaskTest):
|
||||||
|
|
||||||
class TestAddHostnameToIP(AlertTaskTest):
|
class TestAddHostnameToIP(AlertTaskTest):
|
||||||
def setup(self):
|
def setup(self):
|
||||||
super(TestAddHostnameToIP, self).setup()
|
super().setup()
|
||||||
self.formatted_string = '{0} ({1})'
|
self.formatted_string = '{0} ({1})'
|
||||||
|
|
||||||
def test_internal_hostname(self):
|
def test_internal_hostname(self):
|
||||||
|
|
|
@ -7,7 +7,7 @@ class HTTPTestSuite(UnitTestSuite):
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
self.app = TestApp(self.application)
|
self.app = TestApp(self.application)
|
||||||
super(HTTPTestSuite, self).setup()
|
super().setup()
|
||||||
|
|
||||||
def response_per_route(self, route):
|
def response_per_route(self, route):
|
||||||
return self.app.get(route)
|
return self.app.get(route)
|
||||||
|
|
|
@ -16,4 +16,4 @@ class LoginputTestSuite(HTTPTestSuite):
|
||||||
OptionParser.parse_args = mock.Mock(return_value=(sample_config, {}))
|
OptionParser.parse_args = mock.Mock(return_value=(sample_config, {}))
|
||||||
from loginput import index as loginput_index
|
from loginput import index as loginput_index
|
||||||
self.application = loginput_index.application
|
self.application = loginput_index.application
|
||||||
super(LoginputTestSuite, self).setup()
|
super().setup()
|
||||||
|
|
|
@ -10,7 +10,7 @@ from tests.unit_test_suite import UnitTestSuite
|
||||||
class SearchQueryUnitTest(UnitTestSuite):
|
class SearchQueryUnitTest(UnitTestSuite):
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
super(SearchQueryUnitTest, self).setup()
|
super().setup()
|
||||||
self.query = SearchQuery()
|
self.query = SearchQuery()
|
||||||
assert self.query.must == []
|
assert self.query.must == []
|
||||||
assert self.query.must_not == []
|
assert self.query.must_not == []
|
||||||
|
|
|
@ -8,7 +8,7 @@ from tests.unit_test_suite import UnitTestSuite
|
||||||
|
|
||||||
class BulkQueueTest(UnitTestSuite):
|
class BulkQueueTest(UnitTestSuite):
|
||||||
def setup(self):
|
def setup(self):
|
||||||
super(BulkQueueTest, self).setup()
|
super().setup()
|
||||||
|
|
||||||
def num_objects_saved(self):
|
def num_objects_saved(self):
|
||||||
self.refresh(self.event_index_name)
|
self.refresh(self.event_index_name)
|
||||||
|
@ -21,7 +21,7 @@ class BulkQueueTest(UnitTestSuite):
|
||||||
class TestBasicInit(BulkQueueTest):
|
class TestBasicInit(BulkQueueTest):
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
super(TestBasicInit, self).setup()
|
super().setup()
|
||||||
self.queue = BulkQueue(self.es_client)
|
self.queue = BulkQueue(self.es_client)
|
||||||
|
|
||||||
def test_threshold(self):
|
def test_threshold(self):
|
||||||
|
@ -44,7 +44,7 @@ class TestInitWithThreshold(BulkQueueTest):
|
||||||
class TestAdd(BulkQueueTest):
|
class TestAdd(BulkQueueTest):
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
super(TestAdd, self).setup()
|
super().setup()
|
||||||
self.queue = BulkQueue(self.es_client, threshold=20)
|
self.queue = BulkQueue(self.es_client, threshold=20)
|
||||||
|
|
||||||
def test_basic_add(self):
|
def test_basic_add(self):
|
||||||
|
|
|
@ -18,7 +18,7 @@ from tests.unit_test_suite import UnitTestSuite
|
||||||
|
|
||||||
class ElasticsearchClientTest(UnitTestSuite):
|
class ElasticsearchClientTest(UnitTestSuite):
|
||||||
def setup(self):
|
def setup(self):
|
||||||
super(ElasticsearchClientTest, self).setup()
|
super().setup()
|
||||||
self.es_client = ElasticsearchClient(self.options.esservers, bulk_refresh_time=3)
|
self.es_client = ElasticsearchClient(self.options.esservers, bulk_refresh_time=3)
|
||||||
|
|
||||||
def get_num_events(self):
|
def get_num_events(self):
|
||||||
|
@ -50,7 +50,7 @@ class MockTransportClass:
|
||||||
|
|
||||||
class TestWriteWithRead(ElasticsearchClientTest):
|
class TestWriteWithRead(ElasticsearchClientTest):
|
||||||
def setup(self):
|
def setup(self):
|
||||||
super(TestWriteWithRead, self).setup()
|
super().setup()
|
||||||
|
|
||||||
self.alert = {
|
self.alert = {
|
||||||
'category': 'correlatedalerts',
|
'category': 'correlatedalerts',
|
||||||
|
@ -115,7 +115,7 @@ class TestNoResultsFound(ElasticsearchClientTest):
|
||||||
class TestCloseIndex(ElasticsearchClientTest):
|
class TestCloseIndex(ElasticsearchClientTest):
|
||||||
|
|
||||||
def teardown(self):
|
def teardown(self):
|
||||||
super(TestCloseIndex, self).teardown()
|
super().teardown()
|
||||||
if self.config_delete_indexes:
|
if self.config_delete_indexes:
|
||||||
self.es_client.delete_index('test_index')
|
self.es_client.delete_index('test_index')
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ class TestCloseIndex(ElasticsearchClientTest):
|
||||||
class TestWritingToClosedIndex(ElasticsearchClientTest):
|
class TestWritingToClosedIndex(ElasticsearchClientTest):
|
||||||
|
|
||||||
def teardown(self):
|
def teardown(self):
|
||||||
super(TestWritingToClosedIndex, self).teardown()
|
super().teardown()
|
||||||
if self.config_delete_indexes:
|
if self.config_delete_indexes:
|
||||||
self.es_client.delete_index('test_index')
|
self.es_client.delete_index('test_index')
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ class TestWritingToClosedIndex(ElasticsearchClientTest):
|
||||||
class TestOpenIndex(ElasticsearchClientTest):
|
class TestOpenIndex(ElasticsearchClientTest):
|
||||||
|
|
||||||
def teardown(self):
|
def teardown(self):
|
||||||
super(TestOpenIndex, self).teardown()
|
super().teardown()
|
||||||
if self.config_delete_indexes:
|
if self.config_delete_indexes:
|
||||||
self.es_client.delete_index('test_index')
|
self.es_client.delete_index('test_index')
|
||||||
|
|
||||||
|
@ -292,14 +292,14 @@ class TestSimpleWrites(ElasticsearchClientTest):
|
||||||
class BulkTest(ElasticsearchClientTest):
|
class BulkTest(ElasticsearchClientTest):
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
super(BulkTest, self).setup()
|
super().setup()
|
||||||
self.mock_class = MockTransportClass()
|
self.mock_class = MockTransportClass()
|
||||||
self.mock_class.backup_function(self.es_client.es_connection.transport.perform_request)
|
self.mock_class.backup_function(self.es_client.es_connection.transport.perform_request)
|
||||||
self.es_client.es_connection.transport.perform_request = self.mock_class.perform_request
|
self.es_client.es_connection.transport.perform_request = self.mock_class.perform_request
|
||||||
|
|
||||||
def teardown(self):
|
def teardown(self):
|
||||||
self.es_client.finish_bulk()
|
self.es_client.finish_bulk()
|
||||||
super(BulkTest, self).teardown()
|
super().teardown()
|
||||||
|
|
||||||
|
|
||||||
class TestBulkWrites(BulkTest):
|
class TestBulkWrites(BulkTest):
|
||||||
|
@ -399,7 +399,7 @@ class TestWriteWithIDExists(ElasticsearchClientTest):
|
||||||
class TestGetIndices(ElasticsearchClientTest):
|
class TestGetIndices(ElasticsearchClientTest):
|
||||||
|
|
||||||
def teardown(self):
|
def teardown(self):
|
||||||
super(TestGetIndices, self).teardown()
|
super().teardown()
|
||||||
if self.config_delete_indexes:
|
if self.config_delete_indexes:
|
||||||
self.es_client.delete_index('test_index')
|
self.es_client.delete_index('test_index')
|
||||||
|
|
||||||
|
@ -429,7 +429,7 @@ class TestGetIndices(ElasticsearchClientTest):
|
||||||
class TestIndexExists(ElasticsearchClientTest):
|
class TestIndexExists(ElasticsearchClientTest):
|
||||||
|
|
||||||
def teardown(self):
|
def teardown(self):
|
||||||
super(TestIndexExists, self).teardown()
|
super().teardown()
|
||||||
if self.config_delete_indexes:
|
if self.config_delete_indexes:
|
||||||
self.es_client.delete_index('test_index')
|
self.es_client.delete_index('test_index')
|
||||||
|
|
||||||
|
@ -462,14 +462,14 @@ class TestClusterHealth(ElasticsearchClientTest):
|
||||||
class TestCreatingAlias(ElasticsearchClientTest):
|
class TestCreatingAlias(ElasticsearchClientTest):
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
super(TestCreatingAlias, self).setup()
|
super().setup()
|
||||||
if self.config_delete_indexes:
|
if self.config_delete_indexes:
|
||||||
self.es_client.delete_index('index1', True)
|
self.es_client.delete_index('index1', True)
|
||||||
self.es_client.delete_index('index2', True)
|
self.es_client.delete_index('index2', True)
|
||||||
self.es_client.delete_index('alias1', True)
|
self.es_client.delete_index('alias1', True)
|
||||||
|
|
||||||
def teardown(self):
|
def teardown(self):
|
||||||
super(TestCreatingAlias, self).teardown()
|
super().teardown()
|
||||||
if self.config_delete_indexes:
|
if self.config_delete_indexes:
|
||||||
self.es_client.delete_index('index1', True)
|
self.es_client.delete_index('index1', True)
|
||||||
self.es_client.delete_index('index2', True)
|
self.es_client.delete_index('index2', True)
|
||||||
|
@ -512,7 +512,7 @@ class TestCreatingAlias(ElasticsearchClientTest):
|
||||||
class TestBulkInvalidFormatProblem(BulkTest):
|
class TestBulkInvalidFormatProblem(BulkTest):
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
super(TestBulkInvalidFormatProblem, self).setup()
|
super().setup()
|
||||||
|
|
||||||
mapping = {
|
mapping = {
|
||||||
"mappings": {
|
"mappings": {
|
||||||
|
|
|
@ -19,9 +19,10 @@ import sys
|
||||||
class TestEsworkerSNSSQS(UnitTestSuite):
|
class TestEsworkerSNSSQS(UnitTestSuite):
|
||||||
def teardown(self):
|
def teardown(self):
|
||||||
sys.path.remove(self.mq_path)
|
sys.path.remove(self.mq_path)
|
||||||
|
super().teardown()
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
super(TestEsworkerSNSSQS, self).setup()
|
super().setup()
|
||||||
mq_conn = 'abc'
|
mq_conn = 'abc'
|
||||||
task_queue = 'example-logs-mozdef'
|
task_queue = 'example-logs-mozdef'
|
||||||
es_connection = self.es_client
|
es_connection = self.es_client
|
||||||
|
|
|
@ -30,4 +30,4 @@ class RestTestSuite(HTTPTestSuite):
|
||||||
importlib.reload(plugins)
|
importlib.reload(plugins)
|
||||||
from rest import index as rest_index
|
from rest import index as rest_index
|
||||||
self.application = rest_index.application
|
self.application = rest_index.application
|
||||||
super(RestTestSuite, self).setup()
|
super().setup()
|
||||||
|
|
|
@ -46,12 +46,12 @@ class TestKibanaDashboardsRoute(RestTestSuite):
|
||||||
return self.es_client.save_object(body=dashboardjson, index='.kibana', doc_id=dashid)
|
return self.es_client.save_object(body=dashboardjson, index='.kibana', doc_id=dashid)
|
||||||
|
|
||||||
def teardown(self):
|
def teardown(self):
|
||||||
super(TestKibanaDashboardsRoute, self).teardown()
|
super().teardown()
|
||||||
if self.config_delete_indexes:
|
if self.config_delete_indexes:
|
||||||
self.es_client.delete_index('.kibana', True)
|
self.es_client.delete_index('.kibana', True)
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
super(TestKibanaDashboardsRoute, self).setup()
|
super().setup()
|
||||||
if self.config_delete_indexes:
|
if self.config_delete_indexes:
|
||||||
self.es_client.delete_index('.kibana', True)
|
self.es_client.delete_index('.kibana', True)
|
||||||
self.es_client.create_index('.kibana')
|
self.es_client.create_index('.kibana')
|
||||||
|
@ -84,14 +84,14 @@ class TestKibanaDashboardsRouteWithoutDashboards(RestTestSuite):
|
||||||
status_code = 200
|
status_code = 200
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
super(TestKibanaDashboardsRouteWithoutDashboards, self).setup()
|
super().setup()
|
||||||
if self.config_delete_indexes:
|
if self.config_delete_indexes:
|
||||||
self.es_client.delete_index('.kibana', True)
|
self.es_client.delete_index('.kibana', True)
|
||||||
self.es_client.create_index('.kibana')
|
self.es_client.create_index('.kibana')
|
||||||
time.sleep(0.2)
|
time.sleep(0.2)
|
||||||
|
|
||||||
def teardown(self):
|
def teardown(self):
|
||||||
super(TestKibanaDashboardsRouteWithoutDashboards, self).teardown()
|
super().teardown()
|
||||||
if self.config_delete_indexes:
|
if self.config_delete_indexes:
|
||||||
self.es_client.delete_index('.kibana', True)
|
self.es_client.delete_index('.kibana', True)
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ class TestLoginCountsRoute(RestTestSuite):
|
||||||
status_code = 200
|
status_code = 200
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
super(TestLoginCountsRoute, self).setup()
|
super().setup()
|
||||||
|
|
||||||
# ttesterson test events
|
# ttesterson test events
|
||||||
for count in range(10):
|
for count in range(10):
|
||||||
|
|
Загрузка…
Ссылка в новой задаче