MCPcopy Create free account
hub / github.com/treeverse/dvc / test

Function test

tests/func/test_import_db.py:51–108  ·  view source on GitHub ↗
(tmp_dir, scm, dvc, db_connection, seed_db, output_format, args, file_name)

Source from the content-addressed store, hash-verified

49 ],
50)
51def test(tmp_dir, scm, dvc, db_connection, seed_db, output_format, args, file_name):
52 seed_db(values=range(5))
53 if output_format == "json":
54 file_size = 96, 192
55 md5 = "6039fe7565d212b339aaa446ca234e5d", "e1b8adf4d9eb9ab2b64d3ab0bb5f65ac"
56 elif os.name == "nt":
57 file_size = 35, 61
58 md5 = "14c34db5ddd184345c06f74718539f04", "3bb836e6d43c9afa43a9d73b36bbbab4"
59 else:
60 file_size = 29, 50
61 md5 = "6f7fc0d701d1ac13eec83d79fffaf427", "c04f712f8167496a2fb43f289f2b7e28"
62
63 db = compact(
64 {
65 "file_format": output_format,
66 "connection": db_connection,
67 "table": args.get("table"),
68 "query": args.get("sql"),
69 }
70 )
71 stage = dvc.imp_db(**args, connection=db_connection, output_format=output_format)
72
73 output_file = f"{file_name}.{output_format}"
74 df = load_data(output_file, output_format)
75 assert df.values.tolist() == [[i + 1, i] for i in range(5)]
76 assert (tmp_dir / stage.relpath).parse() == {
77 "md5": M.instance_of(str),
78 "frozen": True,
79 "deps": [{"db": db}],
80 "outs": [
81 {
82 "md5": md5[0],
83 "size": file_size[0],
84 "hash": "md5",
85 "path": output_file,
86 }
87 ],
88 }
89
90 seed_db(values=range(5, 10))
91
92 dvc.update(stage.addressing)
93
94 df = load_data(output_file, output_format)
95 assert df.values.tolist() == [[i + 1, i] for i in range(10)]
96 assert (tmp_dir / stage.relpath).parse() == {
97 "md5": M.instance_of(str),
98 "frozen": True,
99 "deps": [{"db": db}],
100 "outs": [
101 {
102 "md5": md5[1],
103 "size": file_size[1],
104 "hash": "md5",
105 "path": output_file,
106 }
107 ],
108 }

Callers

nothing calls this directly

Calls 5

seed_dbFunction · 0.85
load_dataFunction · 0.85
parseMethod · 0.80
getMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…