-
Notifications
You must be signed in to change notification settings - Fork 31
/
noderunner.py
46 lines (35 loc) · 1.03 KB
/
noderunner.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
from unittest.mock import patch
from dokuztas.node import command_line_runner
class FakeParser(object):
def __init__(self, arg_port):
self.argport = arg_port
def parse_args(self):
return self.get_fake_args(self.argport)
def get_fake_args(self, port):
class FakeArgs(object):
def __init__(self, inner_port):
self.port = inner_port
return FakeArgs(port)
#
# import threading
# import time
# patcher = patch('dokuztas.node.get_parser')
# mock = patcher.start()
# for i in range(5002, 5005):
# print(i)
# mock.return_value = FakeParser(i)
# t = threading.Thread(target=command_line_runner)
# # command_line_runner()
# t.start()
# time.sleep(3)
#
# patcher.stop()
# python noderunner.py -p 500x
command_line_runner()
# from noderunner import new_node
# def new_node(port):
# patcher = patch('dokuztas.node.get_parser')
# mock = patcher.start()
# mock.return_value = FakeParser(arg_port=port)
# command_line_runner()
# patcher.stop()