summaryrefslogtreecommitdiff
path: root/tests/test_engine.py
diff options
context:
space:
mode:
authorÁrni Dagur <agudmundsson@fc-md.umd.edu>2020-06-21 18:20:20 -0400
committerÁrni Dagur <agudmundsson@fc-md.umd.edu>2020-06-21 18:20:20 -0400
commit019b5b35ebf07022e37d6b8715820b439a18f32b (patch)
tree9b4cc5cbe5b50dc9d748ca23a224dc31237ca903 /tests/test_engine.py
parent4bb4cb4e6c49226740e80a8dd1639274e0719b53 (diff)
Correct return type for the serialize method
Diffstat (limited to 'tests/test_engine.py')
-rw-r--r--tests/test_engine.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/test_engine.py b/tests/test_engine.py
index af15b6d..28e25e6 100644
--- a/tests/test_engine.py
+++ b/tests/test_engine.py
@@ -1,4 +1,5 @@
1import adblock 1import adblock
2import pytest
2 3
3 4
4def test_engine_arguments(): 5def test_engine_arguments():
@@ -9,3 +10,31 @@ def test_engine_arguments():
9 adblock.Engine(network_filters=[]) 10 adblock.Engine(network_filters=[])
10 adblock.Engine(load_network=False, load_cosmetic=True, debug=False) 11 adblock.Engine(load_network=False, load_cosmetic=True, debug=False)
11 adblock.Engine(debug=True) 12 adblock.Engine(debug=True)
13
14
15def test_serde_file(tmpdir):
16 path = str(tmpdir / "cache.dat")
17
18 engine0 = adblock.Engine()
19 with pytest.raises(FileNotFoundError):
20 # We haven't created the cache.dat file, so we should get an exception
21 # when attempting to deserialize.
22 engine0.deserialize_from_file(path)
23
24 engine1 = adblock.Engine()
25 serialization_result = engine1.serialize_to_file(path)
26 assert serialization_result is None
27
28 engine2 = adblock.Engine()
29 deserialization_result = engine2.deserialize_from_file(path)
30 assert deserialization_result is None
31
32
33def test_serde():
34 engine = adblock.Engine()
35 serialization_result = engine.serialize()
36 assert isinstance(serialization_result, bytes)
37
38 engine2 = adblock.Engine()
39 deserialization_result = engine2.deserialize(serialization_result)
40 assert deserialization_result is None