Skip to content

Commit

Permalink
Merge pull request #5359 from willkg/1383113-getitem-mozilla
Browse files Browse the repository at this point in the history
bug 1383113: switch mozilla processor rules to getitem notation
  • Loading branch information
willkg committed Apr 28, 2020
2 parents 33a3e38 + f17c529 commit 1b97c7a
Show file tree
Hide file tree
Showing 10 changed files with 515 additions and 557 deletions.
145 changes: 74 additions & 71 deletions socorro/processor/rules/mozilla.py

Large diffs are not rendered by default.

19 changes: 0 additions & 19 deletions socorro/signature/tests/__init__.py
@@ -1,22 +1,3 @@
# 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/.

# NOTE(willkg): This is a duplicate of Socorro's WHATEVER, but it allows
# the signature generation code to stand alone.

from functools import total_ordering


@total_ordering
class EqualAnything(object):
def __eq__(self, other):
return True

def __lt__(self, other):
return True


#: Sentinel that is equal to anything; simplifies assertions in cases where
#: part of the value changes from test to test
WHATEVER = EqualAnything()
3 changes: 1 addition & 2 deletions socorro/signature/tests/test_signature_generator.py
Expand Up @@ -5,7 +5,6 @@
import importlib
from unittest import mock

from . import WHATEVER

# NOTE(willkg): We do this so that we can extract signature generation into its
# own namespace as an external library. This allows the tests to run if it's in
Expand Down Expand Up @@ -57,7 +56,7 @@ def predicate(self, crash_data, result):
assert error_handler.call_args_list == [
mock.call(
{"uuid": "ou812"},
exc_info=(Exception, exc_value, WHATEVER),
exc_info=(Exception, exc_value, mock.ANY),
extra={"rule": "BadRule"},
)
]
16 changes: 0 additions & 16 deletions socorro/unittest/__init__.py
@@ -1,19 +1,3 @@
# 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/.

from functools import total_ordering


@total_ordering
class EqualAnything(object):
def __eq__(self, other):
return True

def __lt__(self, other):
return True


#: Sentinel that is equal to anything; simplifies assertions in cases where
#: part of the value changes from test to test
WHATEVER = EqualAnything()
4 changes: 1 addition & 3 deletions socorro/unittest/processor/__init__.py
Expand Up @@ -30,6 +30,4 @@ def get_basic_config():


def get_basic_processor_meta():
processor_meta = DotDict()
processor_meta.processor_notes = []
return processor_meta
return {"processor_notes": []}
13 changes: 5 additions & 8 deletions socorro/unittest/processor/rules/test_breakpad.py
Expand Up @@ -16,10 +16,7 @@
JitCrashCategorizeRule,
MinidumpSha256Rule,
)


def get_basic_processor_meta():
return {"processor_notes": []}
from socorro.unittest.processor import get_basic_processor_meta


example_uuid = "00000000-0000-0000-0000-000002140504"
Expand Down Expand Up @@ -200,7 +197,7 @@ def _temp_raw_crash_json_file(self, raw_crash, crash_id):
yield "%s.json" % raw_crash["uuid"]


class TestCrashingThreadRule(object):
class TestCrashingThreadRule:
def test_everything_we_hoped_for(self):
raw_crash = copy.deepcopy(canonical_standard_raw_crash)
raw_dumps = {}
Expand All @@ -227,7 +224,7 @@ def test_stuff_missing(self):
]


class TestMinidumpSha256HashRule(object):
class TestMinidumpSha256HashRule:
def test_hash_not_in_raw_crash(self):
raw_crash = {}
raw_dumps = {}
Expand Down Expand Up @@ -260,7 +257,7 @@ def test_hash_in_raw_crash(self):
canonical_external_output_str = json.dumps(canonical_external_output)


class TestBreakpadTransformRule2015(object):
class TestBreakpadTransformRule2015:
def build_rule(self):
pprcb = ProcessorPipeline.required_config.breakpad

Expand Down Expand Up @@ -379,7 +376,7 @@ def test_temp_file_context(self, mocked_unlink):
mocked_unlink.reset_mock()


class TestJitCrashCategorizeRule(object):
class TestJitCrashCategorizeRule:
def build_rule(self):
pprcj = ProcessorPipeline.required_config.jit
return JitCrashCategorizeRule(
Expand Down
11 changes: 4 additions & 7 deletions socorro/unittest/processor/rules/test_general.py
Expand Up @@ -14,6 +14,7 @@
IdentifierRule,
OSInfoRule,
)
from socorro.unittest.processor import get_basic_processor_meta


canonical_standard_raw_crash = {
Expand Down Expand Up @@ -106,10 +107,6 @@
}


def get_basic_processor_meta():
return {"processor_notes": []}


class TestDeNoneRule:
@pytest.mark.parametrize(
"raw_crash, expected",
Expand Down Expand Up @@ -174,7 +171,7 @@ def test_rule_with_dotdict(self):
assert raw_crash == DotDict({"key1": "val1", "key2": b"val2", "key3": "val3"})


class TestIdentifierRule(object):
class TestIdentifierRule:
def test_everything_we_hoped_for(self):
uuid = "00000000-0000-0000-0000-000002140504"
raw_crash = {"uuid": uuid}
Expand Down Expand Up @@ -202,7 +199,7 @@ def test_uuid_missing(self):
assert processed_crash == {}


class TestCPUInfoRule(object):
class TestCPUInfoRule:
def test_everything_we_hoped_for(self):
raw_crash = copy.copy(canonical_standard_raw_crash)
raw_dumps = {}
Expand Down Expand Up @@ -262,7 +259,7 @@ def test_missing_json_dump(self):
assert raw_crash == {}


class TestOSInfoRule(object):
class TestOSInfoRule:
def test_everything_we_hoped_for(self):
raw_crash = {}
processed_crash = {
Expand Down
Expand Up @@ -17,7 +17,7 @@ def get_example_file_data(filename):
return json.loads(f.read())


class TestMemoryReportExtraction(object):
class TestMemoryReportExtraction:
def test_predicate_success(self):
rule = MemoryReportExtraction()

Expand Down

0 comments on commit 1b97c7a

Please sign in to comment.