Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
ekneg54 committed Oct 16, 2023
1 parent 9d3472b commit 0c03341
Showing 1 changed file with 0 additions and 9 deletions.
9 changes: 0 additions & 9 deletions tests/unit/processor/geoip_enricher/test_geoip_enricher.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,31 +103,27 @@ def specific_rules_dirs(self):
return self.CONFIG["specific_rules"]

def test_geoip_data_added(self):
assert self.object.metrics.number_of_processed_events == 0
document = {"client": {"ip": "1.2.3.4"}}

self.object.process(document)

assert document.get("geoip")

def test_geoip_data_added_not_exists(self):
assert self.object.metrics.number_of_processed_events == 0
document = {"client": {"ip": "127.0.0.1"}}

self.object.process(document)

assert document.get("geoip") is None

def test_no_geoip_data_added_if_source_field_is_none(self):
assert self.object.metrics.number_of_processed_events == 0
document = {"client": {"ip": None}}

self.object.process(document)

assert document.get("geoip") is None

def test_source_field_is_none_raises_processing_warning(self):
assert self.object.metrics.number_of_processed_events == 0
document = {"client": {"ip": None}}

with pytest.raises(
Expand All @@ -137,22 +133,19 @@ def test_source_field_is_none_raises_processing_warning(self):
self.object._apply_rules(document, self.object.rules[0])

def test_nothing_to_enrich(self):
assert self.object.metrics.number_of_processed_events == 0
document = {"something": {"something": "1.2.3.4"}}

self.object.process(document)
assert "geoip" not in document

def test_geoip_data_added_not_valid(self):
assert self.object.metrics.number_of_processed_events == 0
document = {"client": {"ip": "333.333.333.333"}}

self.object.process(document)

assert document.get("geoip") is None

def test_enrich_an_event_geoip(self):
assert self.object.metrics.number_of_processed_events == 0
document = {"client": {"ip": "8.8.8.8"}}

self.object.process(document)
Expand All @@ -171,15 +164,13 @@ def test_enrich_an_event_geoip(self):
assert geoip["properties"].get("accuracy_radius") == 1337

def test_enrich_an_event_geoip_with_existing_differing_geoip(self, caplog):
assert self.object.metrics.number_of_processed_events == 0
document = {"client": {"ip": "8.8.8.8"}, "geoip": {"type": "Feature"}}

with caplog.at_level(logging.WARNING):
self.object.process(document)
assert re.match(".*FieldExistsWarning.*geoip.type", caplog.text)

def test_configured_dotted_output_field(self):
assert self.object.metrics.number_of_processed_events == 0
document = {"source": {"ip": "8.8.8.8"}}

self.object.process(document)
Expand Down

0 comments on commit 0c03341

Please sign in to comment.