Tests for rich logging, apply ruff formatting
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from kanta.logging import format_diff
|
||||
from kanta.logging import _ADD, _DELETE, format_diff
|
||||
|
||||
|
||||
def test_add():
|
||||
@@ -6,6 +6,28 @@ def test_add():
|
||||
assert any("name" in line for line in lines)
|
||||
|
||||
|
||||
def test_add_path_is_green():
|
||||
lines = format_diff({"name": "Alice"}, previous={})
|
||||
assert any(_ADD in line for line in lines)
|
||||
|
||||
|
||||
def test_nested_add_path_final_element_is_green():
|
||||
lines = format_diff({"users": {"alice": 1}}, previous={"users": {}})
|
||||
assert any(_ADD in line and "alice" in line for line in lines)
|
||||
|
||||
|
||||
def test_update_path_not_colored_as_add():
|
||||
lines = format_diff({"name": "Bob"}, previous={"name": "Alice"})
|
||||
assert lines
|
||||
assert all(_ADD not in line for line in lines)
|
||||
|
||||
|
||||
def test_delete_path_not_colored_as_add():
|
||||
lines = format_diff({"$delete": ["old_key"]}, previous={"old_key": 1})
|
||||
assert any(_DELETE in line for line in lines)
|
||||
assert all(_ADD not in line for line in lines)
|
||||
|
||||
|
||||
def test_update():
|
||||
lines = format_diff({"name": "Bob"}, previous={"name": "Alice"})
|
||||
assert any("Bob" in line for line in lines)
|
||||
|
||||
Reference in New Issue
Block a user