forked from fox-it/flow.record
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_deprecations.py
60 lines (47 loc) · 1.68 KB
/
test_deprecations.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import pytest
from flow.record import RecordDescriptor
from flow.record.base import parse_def
def test_deprecate_ipv4_address():
TestRecord = RecordDescriptor(
"test/net/ipv4/Address",
[
("net.ipv4.Address", "ip"),
],
)
with pytest.warns(DeprecationWarning, match="net.ipv4.address fieldtype is deprecated, use net.ipaddress instead"):
TestRecord("127.0.0.1")
def test_deprecate_ipv4_subnet():
TestRecord = RecordDescriptor(
"test/net/ipv4/Subnet",
[
("net.ipv4.Subnet", "network"),
],
)
with pytest.warns(DeprecationWarning, match="net.ipv4.subnet fieldtype is deprecated, use net.ipnetwork instead"):
TestRecord("192.168.0.0/24")
def test_deprecate_parse_def():
with pytest.deprecated_call():
parse_def("test/record")
def test_deprecate_recorddescriptor_init():
# Test deprecated RecordDescriptor init with string def
with pytest.deprecated_call():
TestRecord = RecordDescriptor("test/record", None)
assert TestRecord.name == "test/record"
# Test deprecated RecordDescriptor init with string def and some fields
with pytest.deprecated_call():
TestRecord = RecordDescriptor(
"""test/record
string foo
"""
)
assert TestRecord(foo="bar").foo == "bar"
TestRecord = RecordDescriptor(
"test/record",
[
("string", "foo"),
],
)
# Test deprecated RecordDescriptor init with another RecordDescriptor
with pytest.deprecated_call():
TestRecord2 = RecordDescriptor("test/init_other_descriptor", TestRecord)
assert TestRecord2(foo="bar").foo == "bar"