def __init__(self, backup_dir, backup_target, transform=lambda tool: None): self.tool = NodeControlTool(backup_dir=backup_dir, backup_target=backup_target) transform(self.tool) self.p = multiprocessing.Process(target=self.tool.start) self.p.start() logger.debug("NCTProcess was started with pid: {}".format(self.p.pid))
def testNodeControlResolvesDependencies(monkeypatch, tconf): nct = NodeControlTool(config=tconf) node_package = ('indy-node', '0.0.1') anoncreds_package = ('indy-anoncreds', '0.0.2') plenum_package = ('indy-plenum', '0.0.3') node_package_with_version = '{}={}'.format(*node_package) plenum_package_with_version = '{}={}'.format(*plenum_package) anoncreds_package_with_version = '{}={}'.format(*anoncreds_package) mock_info = { node_package_with_version: '{}\nVersion: {}\nDepends:{} (= {}), {} (= {})\n'.format( randomText(100), node_package[1], *plenum_package, *anoncreds_package), plenum_package_with_version: '{}'.format(randomText(100)), anoncreds_package_with_version: '{}'.format(randomText(100)) } def mock_get_info_from_package_manager(package): return mock_info.get(package, None) monkeypatch.setattr(NodeControlUtil, 'update_package_cache', lambda *x: None) monkeypatch.setattr( NodeControlUtil, 'get_sys_holds', lambda *x: [node_package[0], anoncreds_package[0], plenum_package[0]]) monkeypatch.setattr(NodeControlUtil, '_get_info_from_package_manager', lambda x: mock_get_info_from_package_manager(x)) ret = nct._get_deps_list(node_package_with_version) nct.server.close() assert ret.split() == [ anoncreds_package_with_version, plenum_package_with_version, node_package_with_version ]
def testNodeControlResolvesDependencies(monkeypatch): nct = NodeControlTool() node_package = ('indy-node', '0.0.1') anoncreds_package = ('indy-anoncreds', '0.0.2') plenum_package = ('indy-plenum', '0.0.3') node_package_with_version = '{}={}'.format(*node_package) plenum_package_with_version = '{}={}'.format(*plenum_package) anoncreds_package_with_version = '{}={}'.format(*anoncreds_package) mock_info = { node_package_with_version: '{}{} (= {}){}{} (= {}){}'.format(randomText(100), *plenum_package, randomText(100), *anoncreds_package, randomText(100)), plenum_package_with_version: '{}'.format(randomText(100)), anoncreds_package_with_version: '{}'.format(randomText(100)) } def mock_get_info_from_package_manager(self, package): return mock_info.get(package, None) monkeypatch.setattr(nct.__class__, '_get_info_from_package_manager', mock_get_info_from_package_manager) monkeypatch.setattr(nct.__class__, '_update_package_cache', lambda *x: None) ret = nct._get_deps_list(node_package_with_version) assert ret.split() == [ anoncreds_package_with_version, plenum_package_with_version, node_package_with_version ]
def test_node_as_depend(monkeypatch, tconf): nct = NodeControlTool(config=tconf) top_level_package = (EXT_PKT_NAME, EXT_PKT_VERSION) plenum_package = ('indy-plenum', '0.0.3') top_level_package_with_version = '{}={}'.format(*top_level_package) top_level_package_dep1_with_version = '{}={}'.format(*EXT_TOP_PKT_DEPS[0]) top_level_package_dep2_with_version = '{}={}'.format(*EXT_TOP_PKT_DEPS[1]) node_package_with_version = '{}={}'.format(*node_package) plenum_package_with_version = '{}={}'.format(*plenum_package) mock_info = { top_level_package_with_version: "{}\nVersion:{}\nDepends:{} (= {}), {} (= {}), {} (= {})\n".format( randomText(100), top_level_package[1], *node_package, *EXT_TOP_PKT_DEPS[0], *EXT_TOP_PKT_DEPS[1]), node_package_with_version: '{}\nVersion:{}\nDepends:{} (= {})\n'.format(randomText(100), node_package[1], *plenum_package), plenum_package_with_version: '{}\nVersion:{}\nDepends:{} (= {})\n'.format(randomText(100), plenum_package[1], *plenum_package), top_level_package_dep1_with_version: '{}\nVersion:{}\nDepends:{} (= {})\n'.format(randomText(100), EXT_TOP_PKT_DEPS[0][1], *plenum_package), top_level_package_dep2_with_version: '{}\nVersion:{}\nDepends:{} (= {})\n'.format(randomText(100), EXT_TOP_PKT_DEPS[1][1], *node_package), } def mock_get_info_from_package_manager(*package): ret = "" for p in package: ret += mock_info.get(p, "") return ret monkeypatch.setattr(NodeControlUtil, 'update_package_cache', lambda *x: None) monkeypatch.setattr(NodeControlUtil, '_get_info_from_package_manager', lambda *x: mock_get_info_from_package_manager(*x)) monkeypatch.setattr( NodeControlUtil, 'get_sys_holds', lambda *x: [ top_level_package[0], plenum_package[0], node_package[0], EXT_TOP_PKT_DEPS[0][0], EXT_TOP_PKT_DEPS[1][0] ]) monkeypatch.setattr(NodeControlUtil, '_get_curr_info', lambda *x: PACKAGE_MNG_EXT_PTK_OUTPUT) ret = nct._get_deps_list(top_level_package_with_version) nct.server.close() assert sorted(ret.split()) == sorted([ plenum_package_with_version, node_package_with_version, top_level_package_dep2_with_version, top_level_package_dep1_with_version, top_level_package_with_version ])
def test_node_as_depend(monkeypatch, tconf): nct = NodeControlTool(config=tconf) top_level_package = (EXT_PKT_NAME, EXT_PKT_VERSION) anoncreds_package = ('indy-anoncreds', '0.0.2') plenum_package = ('indy-plenum', '0.0.3') top_level_package_with_version = '{}={}'.format(*top_level_package) top_level_package_dep1_with_version = '{}={}'.format(*EXT_TOP_PKT_DEPS[0]) top_level_package_dep2_with_version = '{}={}'.format(*EXT_TOP_PKT_DEPS[1]) node_package_with_version = '{}={}'.format(*node_package) plenum_package_with_version = '{}={}'.format(*plenum_package) anoncreds_package_with_version = '{}={}'.format(*anoncreds_package) mock_info = { top_level_package_with_version: "{}{} (= {}) {} (= {}), {} (= {})".format(randomText(100), *node_package, *EXT_TOP_PKT_DEPS[0], *EXT_TOP_PKT_DEPS[1]), node_package_with_version: '{}{} (= {}){}{} (= {}){}'.format(randomText(100), *plenum_package, randomText(100), *anoncreds_package, randomText(100)), plenum_package_with_version: '{}'.format(randomText(100)), anoncreds_package_with_version: '{}'.format(randomText(100)), top_level_package_dep1_with_version: '{}{} (= {})'.format(randomText(100), *plenum_package), top_level_package_dep2_with_version: '{}{} (= {})'.format(randomText(100), *node_package) } def mock_get_info_from_package_manager(self, package): return mock_info.get(package, None) monkeypatch.setattr(nct.__class__, '_get_ext_info', lambda *x: PACKAGE_MNG_EXT_PTK_OUTPUT) monkeypatch.setattr(nct.__class__, '_get_info_from_package_manager', mock_get_info_from_package_manager) monkeypatch.setattr(nct.__class__, '_update_package_cache', lambda *x: None) nct._ext_init() ret = nct._get_deps_list(top_level_package_with_version) nct.server.close() assert ret.split() == [ anoncreds_package_with_version, plenum_package_with_version, node_package_with_version, top_level_package_dep2_with_version, top_level_package_dep1_with_version, top_level_package_with_version ]
def __init__(self, transform=lambda tool: None): self.tool = NodeControlTool() transform(self.tool) self.p = multiprocessing.Process(target=self.tool.start) self.p.start()
def test_node_as_depend(monkeypatch, tconf): nct = NodeControlTool(config=tconf) top_level_package = (EXT_PKT_NAME, EXT_PKT_VERSION) anoncreds_package = ('indy-anoncreds', '0.0.2') plenum_package = ('indy-plenum', '0.0.3') python_crypto = ('python3-indy-crypto', '0.4.5') libindy_crypto = ('libindy-crypto', '0.4.5') top_level_package_with_version = '{}={}'.format(*top_level_package) top_level_package_dep1_with_version = '{}={}'.format(*EXT_TOP_PKT_DEPS[0]) top_level_package_dep2_with_version = '{}={}'.format(*EXT_TOP_PKT_DEPS[1]) node_package_with_version = '{}={}'.format(*node_package) plenum_package_with_version = '{}={}'.format(*plenum_package) anoncreds_package_with_version = '{}={}'.format(*anoncreds_package) python_crypto_with_version = '{}={}'.format(*python_crypto) libindy_crypto_with_version = '{}={}'.format(*libindy_crypto) mock_info = { top_level_package_with_version: "{}\nVersion:{}\nDepends:{} (= {}), {} (= {}), {} (= {})".format( randomText(100), top_level_package[1], *node_package, *EXT_TOP_PKT_DEPS[0], *EXT_TOP_PKT_DEPS[1]), node_package_with_version: '{}\nVersion:{}\nDepends:{} (= {}), {} (= {})'.format( randomText(100), node_package[1], *plenum_package, *anoncreds_package), plenum_package_with_version: '{}\nVersion:{}\nDepends:{} (= {})'.format(randomText(100), plenum_package[1], *python_crypto), anoncreds_package_with_version: '{}'.format(randomText(100)), top_level_package_dep1_with_version: '{}\nVersion:{}\nDepends:{} (= {})'.format(randomText(100), EXT_TOP_PKT_DEPS[0][1], *plenum_package), top_level_package_dep2_with_version: '{}\nVersion:{}\nDepends:{} (= {})'.format(randomText(100), EXT_TOP_PKT_DEPS[1][1], *node_package), python_crypto_with_version: '{}\nVersion:{}\nDepends:{} (= {})'.format(randomText(100), python_crypto[1], *libindy_crypto), libindy_crypto_with_version: '{}\nVersion:{}\nDepends: \n{}'.format(randomText(100), libindy_crypto[1], randomText(100)), } def mock_get_info_from_package_manager(package): return mock_info.get(package, None) monkeypatch.setattr(NodeControlUtil, 'update_package_cache', lambda *x: None) monkeypatch.setattr(NodeControlUtil, '_get_info_from_package_manager', lambda x: mock_get_info_from_package_manager(x)) monkeypatch.setattr( NodeControlUtil, 'get_sys_holds', lambda *x: [ top_level_package[0], anoncreds_package[0], plenum_package[0], node_package[0], EXT_TOP_PKT_DEPS[0][0], EXT_TOP_PKT_DEPS[1][ 0], python_crypto[0], libindy_crypto[0] ]) monkeypatch.setattr(NodeControlUtil, '_get_curr_info', lambda *x: PACKAGE_MNG_EXT_PTK_OUTPUT) ret = nct._get_deps_list(top_level_package_with_version) nct.server.close() assert ret.split() == [ anoncreds_package_with_version, libindy_crypto_with_version, python_crypto_with_version, plenum_package_with_version, node_package_with_version, top_level_package_dep2_with_version, top_level_package_dep1_with_version, top_level_package_with_version ]