MCPcopy Index your code
hub / github.com/Persper/code-analytics / test_az

Function test_az

test/test_analytics/test_analyzer_js.py:41–83  ·  view source on GitHub ↗
(az: Analyzer)

Source from the content-addressed store, hash-verified

39
40
41def test_az(az: Analyzer):
42 my_env = os.environ.copy()
43 my_env["PORT"] = str(server_port)
44 p = subprocess.Popen(['node', server_path], env=my_env)
45
46 try:
47 # wait for the server to spin up
48 time.sleep(1.0)
49 az._graph_server.reset_graph()
50 az.analyze()
51 ccgraph = az.get_graph()
52
53 history_truth = {
54 'C': {'main.js:funcB:9:12': 1,
55 'main.js:global': 1,
56 'main.js:main:7:16': 1},
57 'B': {'main.js:funcB:9:11': 3,
58 'main.js:global': 7,
59 'main.js:main:7:15': 7},
60 'A': {'main.js:funcA:3:5': 3,
61 'main.js:main:7:10': 4,
62 'main.js:global': 12}
63 }
64
65 commits = ccgraph.commits()
66 for func, data in ccgraph.nodes(data=True):
67 history = data['history']
68 for cindex, csize in history.items():
69 commit_message = commits[cindex]['message']
70 assert(csize == history_truth[commit_message.strip()][func])
71
72 edges_truth = [
73 ('main.js:funcB:9:12', 'Native:Window_prototype_print'),
74 ('main.js:funcB:9:12', 'main.js:funcA:3:5'),
75 ('main.js:funcA:3:5', 'Native:Window_prototype_print'),
76 ('main.js:main:7:16', 'main.js:funcB:9:12'),
77 ('main.js:main:7:16', 'main.js:funcA:3:5'),
78 ('main.js:global', 'main.js:main:7:16')
79 ]
80 assert(set(az.graph_server.get_graph().edges()) == set(edges_truth))
81
82 finally:
83 p.terminate()

Callers

nothing calls this directly

Calls 7

commitsMethod · 0.80
nodesMethod · 0.80
itemsMethod · 0.80
edgesMethod · 0.80
reset_graphMethod · 0.45
analyzeMethod · 0.45
get_graphMethod · 0.45

Tested by

no test coverage detected