forked from mitmproxy/mitmproxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
protobuf: tests implemented, full coverage
- Loading branch information
Showing
11 changed files
with
200 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ MANIFEST | |
*.py[cdo] | ||
*.swp | ||
*.swo | ||
*.sqlite | ||
*.egg-info/ | ||
.coverage* | ||
.idea | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
|
||
from .io import FlowWriter, FlowReader, FilteredFlowWriter, read_flows_from_paths | ||
from .db import DbHandler | ||
from .db import DBHandler | ||
|
||
|
||
__all__ = [ | ||
"FlowWriter", "FlowReader", "FilteredFlowWriter", "read_flows_from_paths", "DbHandler" | ||
"FlowWriter", "FlowReader", "FilteredFlowWriter", "read_flows_from_paths", "DBHandler" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from mitmproxy.io import db | ||
from mitmproxy.test import tflow | ||
|
||
|
||
class TestDB: | ||
|
||
def test_create(self, tdata): | ||
dh = db.DBHandler(db_path=tdata.path("mitmproxy/data") + "/tmp.sqlite") | ||
with dh._con as c: | ||
cur = c.cursor() | ||
cur.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='FLOWS';") | ||
assert cur.fetchall() == [('FLOWS',)] | ||
|
||
def test_roundtrip(self, tdata): | ||
dh = db.DBHandler(db_path=tdata.path("mitmproxy/data") + "/tmp.sqlite", mode='write') | ||
flows = [] | ||
for i in range(10): | ||
flows.append(tflow.tflow()) | ||
dh.store(flows) | ||
dh = db.DBHandler(db_path=tdata.path("mitmproxy/data") + "/tmp.sqlite") | ||
with dh._con as c: | ||
cur = c.cursor() | ||
cur.execute("SELECT count(*) FROM FLOWS;") | ||
assert cur.fetchall()[0][0] == 10 | ||
loaded_flows = dh.load() | ||
assert len(loaded_flows) == len(flows) |
Oops, something went wrong.