def test_get_ext_tops_dependency_config_check(self): """ Test thin.get_ext_tops dependencies are importable :return: """ cfg = { "namespace": { "path": "/foo", "py-version": [2, 6], "dependencies": { "jinja2": "/jinja/foo.py", "yaml": "/yaml/", "tornado": "/tornado/wrong.rb", "msgpack": "msgpack.sh", }, } } with pytest.raises(salt.exceptions.SaltSystemExit) as err: thin.get_ext_tops(cfg) self.assertIn( "Missing dependencies for the alternative version in the " "external configuration", str(err.value), ) messages = {} for cl in thin.log.warning.mock_calls: messages[cl[1][1]] = cl[1][0] % (cl[1][1], cl[1][2]) for mod in ["tornado", "yaml", "msgpack"]: self.assertIn("not a Python importable module", messages[mod]) self.assertIn("configured with not a file or does not exist", messages["jinja2"])
def test_get_ext_tops_cfg_interpreter(self): """ Test thin.get_ext_tops interpreter configuration. :return: """ cfg = { "namespace": { "path": "/foo", "py-version": [2, 6], "dependencies": { "jinja2": "", "yaml": "", "tornado": "", "msgpack": "", }, } } with pytest.raises(salt.exceptions.SaltSystemExit): thin.get_ext_tops(cfg) assert len(thin.log.warning.mock_calls) == 4 assert sorted([x[1][1] for x in thin.log.warning.mock_calls]) == [ "jinja2", "msgpack", "tornado", "yaml", ] assert ( "Module test has missing configuration" == thin.log.warning.mock_calls[0][1][0] % "test" )
def test_get_ext_tops_dependency_config_check(self): ''' Test thin.get_ext_tops dependencies are importable :return: ''' cfg = {'namespace': {'path': '/foo', 'py-version': [2, 6], 'dependencies': {'jinja2': '/jinja/foo.py', 'yaml': '/yaml/', 'tornado': '/tornado/wrong.rb', 'msgpack': 'msgpack.sh'}}} with pytest.raises(salt.exceptions.SaltSystemExit) as err: thin.get_ext_tops(cfg) self.assertIn('Missing dependencies for the alternative version in the ' 'external configuration', str(err.value)) messages = {} for cl in thin.log.warning.mock_calls: messages[cl[1][1]] = cl[1][0] % (cl[1][1], cl[1][2]) for mod in ['tornado', 'yaml', 'msgpack']: self.assertIn('not a Python importable module', messages[mod]) self.assertIn('configured with not a file or does not exist', messages['jinja2'])
def test_get_ext_tops_cfg_interpreter(self): ''' Test thin.get_ext_tops interpreter configuration. :return: ''' cfg = { 'namespace': { 'path': '/foo', 'py-version': [2, 6], 'dependencies': { 'jinja2': '', 'yaml': '', 'tornado': '', 'msgpack': '' } } } with pytest.raises(salt.exceptions.SaltSystemExit): thin.get_ext_tops(cfg) assert len(thin.log.warning.mock_calls) == 4 assert sorted([x[1][1] for x in thin.log.warning.mock_calls ]) == ['jinja2', 'msgpack', 'tornado', 'yaml'] assert 'Module test has missing configuration' == thin.log.warning.mock_calls[ 0][1][0] % 'test'
def test_get_ext_tops_cfg_missing_interpreter(self): """ Test thin.get_ext_tops contains interpreter configuration. :return: """ cfg = {"namespace": {"path": "/foo", "dependencies": []}} with pytest.raises(salt.exceptions.SaltSystemExit) as err: thin.get_ext_tops(cfg) self.assertIn("missing specific locked Python version", str(err.value))
def test_get_ext_tops_cfg_missing_interpreter(self): ''' Test thin.get_ext_tops contains interpreter configuration. :return: ''' cfg = {'namespace': {'path': '/foo', 'dependencies': []}} with pytest.raises(salt.exceptions.SaltSystemExit) as err: thin.get_ext_tops(cfg) assert 'missing specific locked Python version' in str(err)
def test_get_ext_tops_cfg_wrong_interpreter(self): ''' Test thin.get_ext_tops contains correct interpreter configuration. :return: ''' cfg = {'namespace': {'path': '/foo', 'py-version': 2, 'dependencies': []}} with pytest.raises(salt.exceptions.SaltSystemExit) as err: thin.get_ext_tops(cfg) assert 'specific locked Python version should be a list of major/minor version' in str(err)
def test_get_ext_tops_cfg_wrong_interpreter(self): """ Test thin.get_ext_tops contains correct interpreter configuration. :return: """ cfg = {"namespace": {"path": "/foo", "py-version": 2, "dependencies": []}} with pytest.raises(salt.exceptions.SaltSystemExit) as err: thin.get_ext_tops(cfg) self.assertIn( "specific locked Python version should be a list of " "major/minor version", str(err.value), )
def test_get_ext_tops_cfg_missing_dependencies(self): """ Test thin.get_ext_tops contains all required dependencies. :return: """ cfg = {"namespace": {"py-version": [0, 0], "path": "/foo", "dependencies": []}} with pytest.raises(Exception) as err: thin.get_ext_tops(cfg) self.assertIn("Missing dependencies", str(err.value)) self.assertTrue(thin.log.error.called) self.assertIn("Missing dependencies", thin.log.error.call_args[0][0]) self.assertIn("jinja2, yaml, tornado, msgpack", thin.log.error.call_args[0][0])
def test_get_ext_tops_cfg_missing_dependencies(self): ''' Test thin.get_ext_tops contains all required dependencies. :return: ''' cfg = {'namespace': {'py-version': [0, 0], 'path': '/foo', 'dependencies': []}} with pytest.raises(Exception) as err: thin.get_ext_tops(cfg) assert 'Missing dependencies' in str(err) assert thin.log.error.called assert 'Missing dependencies' in thin.log.error.call_args[0][0] assert 'jinja2, yaml, tornado, msgpack' in thin.log.error.call_args[0][0]
def test_get_ext_tops_config_pass(self): """ Test thin.get_ext_tops configuration :return: """ cfg = { "namespace": { "path": "/foo", "py-version": [2, 6], "dependencies": { "jinja2": "/jinja/foo.py", "yaml": "/yaml/", "tornado": "/tornado/tornado.py", "msgpack": "msgpack.py", "distro": "distro.py", }, } } out = thin.get_ext_tops(cfg) assert out["namespace"]["py-version"] == cfg["namespace"]["py-version"] assert out["namespace"]["path"] == cfg["namespace"]["path"] assert sorted(out["namespace"]["dependencies"]) == sorted( [ "/tornado/tornado.py", "/jinja/foo.py", "/yaml/", "msgpack.py", "distro.py", ] )
def test_get_ext_tops_config_pass(self): ''' Test thin.get_ext_tops configuration :return: ''' cfg = {'namespace': {'path': '/foo', 'py-version': [2, 6], 'dependencies': {'jinja2': '/jinja/foo.py', 'yaml': '/yaml/', 'tornado': '/tornado/tornado.py', 'msgpack': 'msgpack.py'}}} out = thin.get_ext_tops(cfg) assert out['namespace']['py-version'] == cfg['namespace']['py-version'] assert out['namespace']['path'] == cfg['namespace']['path'] assert sorted(out['namespace']['dependencies']) == sorted(['/tornado/tornado.py', '/jinja/foo.py', '/yaml/', 'msgpack.py'])