Exemplo n.º 1
0
 def test_get_tops_so_mods(self):
     """
     Test thin.get_tops to get extra-modules alongside the top directories, based on the interpreter.
     :return:
     """
     base_tops = [
         "/site-packages/distro",
         "/site-packages/salt",
         "/site-packages/jinja2",
         "/site-packages/yaml",
         "/site-packages/tornado",
         "/site-packages/msgpack",
         "/site-packages/certifi",
         "/site-packages/sdp",
         "/site-packages/sdp_hlp",
         "/site-packages/ssl_mh",
         "/site-packages/concurrent",
         "/site-packages/markupsafe",
         "/site-packages/backports_abc",
         "/custom/foo.so",
         "/custom/bar.so",
     ]
     builtins = sys.version_info.major == 3 and "builtins" or "__builtin__"
     with patch(
         "{}.__import__".format(builtins),
         MagicMock(
             side_effect=[
                 type(str("salt"), (), {"__file__": "/custom/foo.so"}),
                 type(str("salt"), (), {"__file__": "/custom/bar.so"}),
             ]
         ),
     ):
         tops = thin.get_tops(so_mods="foo,bar")
     assert len(tops) == len(base_tops)
     assert sorted(tops) == sorted(base_tops)
Exemplo n.º 2
0
 def test_get_tops_extra_mods(self):
     '''
     Test thin.get_tops to get extra-modules alongside the top directories, based on the interpreter.
     :return:
     '''
     base_tops = ['/site-packages/salt',
                  '/site-packages/jinja2',
                  '/site-packages/yaml',
                  '/site-packages/tornado',
                  '/site-packages/msgpack',
                  '/site-packages/certifi',
                  '/site-packages/sdp',
                  '/site-packages/sdp_hlp',
                  '/site-packages/ssl_mh',
                  '/site-packages/concurrent',
                  '/site-packages/markupsafe',
                  '/site-packages/backports_abc',
                  os.sep + os.path.join('custom', 'foo'),
                  os.sep + os.path.join('custom', 'bar.py')]
     builtins = sys.version_info.major == 3 and 'builtins' or '__builtin__'
     foo = {'__file__': os.sep + os.path.join('custom', 'foo', '__init__.py')}
     bar = {'__file__': os.sep + os.path.join('custom', 'bar')}
     with patch('{}.__import__'.format(builtins),
                MagicMock(side_effect=[type(str('foo'), (), foo),
                                       type(str('bar'), (), bar)])):
         tops = thin.get_tops(extra_mods='foo,bar')
     self.assertEqual(len(tops), len(base_tops))
     self.assertListEqual(sorted(tops), sorted(base_tops))
Exemplo n.º 3
0
 def test_get_tops_extra_mods(self):
     """
     Test thin.get_tops to get extra-modules alongside the top directories, based on the interpreter.
     :return:
     """
     base_tops = [
         "/site-packages/distro",
         "/site-packages/salt",
         "/site-packages/jinja2",
         "/site-packages/yaml",
         "/site-packages/tornado",
         "/site-packages/msgpack",
         "/site-packages/certifi",
         "/site-packages/sdp",
         "/site-packages/sdp_hlp",
         "/site-packages/ssl_mh",
         "/site-packages/concurrent",
         "/site-packages/markupsafe",
         "/site-packages/backports_abc",
         os.sep + os.path.join("custom", "foo"),
         os.sep + os.path.join("custom", "bar.py"),
     ]
     builtins = sys.version_info.major == 3 and "builtins" or "__builtin__"
     foo = {"__file__": os.sep + os.path.join("custom", "foo", "__init__.py")}
     bar = {"__file__": os.sep + os.path.join("custom", "bar")}
     with patch(
         "{}.__import__".format(builtins),
         MagicMock(
             side_effect=[type(str("foo"), (), foo), type(str("bar"), (), bar)]
         ),
     ):
         tops = thin.get_tops(extra_mods="foo,bar")
     self.assertEqual(len(tops), len(base_tops))
     self.assertListEqual(sorted(tops), sorted(base_tops))
Exemplo n.º 4
0
 def test_get_tops(self):
     """
     Test thin.get_tops to get top directories, based on the interpreter.
     :return:
     """
     base_tops = [
         "/site-packages/distro",
         "/site-packages/salt",
         "/site-packages/jinja2",
         "/site-packages/yaml",
         "/site-packages/tornado",
         "/site-packages/msgpack",
         "/site-packages/certifi",
         "/site-packages/sdp",
         "/site-packages/sdp_hlp",
         "/site-packages/ssl_mh",
         "/site-packages/markupsafe",
         "/site-packages/backports_abc",
         "/site-packages/concurrent",
         "/site-packages/contextvars",
     ]
     if salt.utils.thin.has_immutables:
         base_tops.extend(["/site-packages/immutables"])
     tops = thin.get_tops()
     assert len(tops) == len(base_tops)
     assert sorted(tops) == sorted(base_tops), sorted(tops)
Exemplo n.º 5
0
 def test_get_tops(self):
     """
     Test thin.get_tops to get top directories, based on the interpreter.
     :return:
     """
     base_tops = [
         "distro",
         "salt",
         "jinja2",
         "yaml",
         "tornado",
         "msgpack",
         "certifi",
         "sdp",
         "sdp_hlp",
         "ssl_mh",
         "markupsafe",
         "backports_abc",
         "concurrent",
         "contextvars",
     ]
     if salt.utils.thin.has_immutables:
         base_tops.extend(["immutables"])
     tops = []
     for top in thin.get_tops(extra_mods="foo,bar"):
         if top.find("/") != -1:
             spl = "/"
         else:
             spl = os.sep
         tops.append(top.rsplit(spl, 1)[-1])
     assert len(tops) == len(base_tops)
     assert sorted(tops) == sorted(base_tops), sorted(tops)
Exemplo n.º 6
0
    def test_get_tops(self):
        '''
        Test thin.get_tops to get top directories, based on the interpreter.
        :return:
        '''
        base_tops = ['/site-packages/salt', '/site-packages/jinja2', '/site-packages/yaml',
                     '/site-packages/tornado', '/site-packages/msgpack', '/site-packages/certifi',
                     '/site-packages/sdp', '/site-packages/sdp_hlp', '/site-packages/ssl_mh',
                     '/site-packages/markupsafe', '/site-packages/backports_abc', '/site-packages/concurrent']

        tops = thin.get_tops()
        assert len(tops) == len(base_tops)
        assert sorted(tops) == sorted(base_tops)
Exemplo n.º 7
0
 def test_get_tops_extra_mods(self):
     """
     Test thin.get_tops to get extra-modules alongside the top directories, based on the interpreter.
     :return:
     """
     base_tops = [
         "distro",
         "salt",
         "jinja2",
         "yaml",
         "tornado",
         "msgpack",
         "certifi",
         "sdp",
         "sdp_hlp",
         "ssl_mh",
         "concurrent",
         "markupsafe",
         "backports_abc",
         "contextvars",
         "foo",
         "bar.py",
     ]
     if salt.utils.thin.has_immutables:
         base_tops.extend(["immutables"])
     libs = salt.utils.thin.find_site_modules("contextvars")
     foo = {
         "__file__": os.sep + os.path.join("custom", "foo", "__init__.py")
     }
     bar = {"__file__": os.sep + os.path.join("custom", "bar")}
     with patch("salt.utils.thin.find_site_modules",
                MagicMock(side_effect=[libs])):
         with patch(
                 "builtins.__import__",
                 MagicMock(side_effect=[
                     type("foo", (
                     ), foo), type("bar", (), bar)
                 ]),
         ):
             tops = []
             for top in thin.get_tops(extra_mods="foo,bar"):
                 if top.find("/") != -1:
                     spl = "/"
                 else:
                     spl = os.sep
                 tops.append(top.rsplit(spl, 1)[-1])
     self.assertEqual(len(tops), len(base_tops))
     self.assertListEqual(sorted(tops), sorted(base_tops))
Exemplo n.º 8
0
 def test_get_tops_so_mods(self):
     '''
     Test thin.get_tops to get extra-modules alongside the top directories, based on the interpreter.
     :return:
     '''
     base_tops = ['/site-packages/salt', '/site-packages/jinja2', '/site-packages/yaml',
                  '/site-packages/tornado', '/site-packages/msgpack', '/site-packages/certifi',
                  '/site-packages/sdp', '/site-packages/sdp_hlp', '/site-packages/ssl_mh', '/site-packages/concurrent',
                  '/site-packages/markupsafe', '/site-packages/backports_abc', '/custom/foo.so', '/custom/bar.so']
     builtins = sys.version_info.major == 3 and 'builtins' or '__builtin__'
     with patch('{}.__import__'.format(builtins),
                MagicMock(side_effect=[type(str('salt'), (), {'__file__': '/custom/foo.so'}),
                                       type(str('salt'), (), {'__file__': '/custom/bar.so'})])):
         tops = thin.get_tops(so_mods='foo,bar')
     assert len(tops) == len(base_tops)
     assert sorted(tops) == sorted(base_tops)
Exemplo n.º 9
0
 def test_get_tops_so_mods(self):
     """
     Test thin.get_tops to get extra-modules alongside the top directories, based on the interpreter.
     :return:
     """
     base_tops = [
         "distro",
         "salt",
         "jinja2",
         "yaml",
         "tornado",
         "msgpack",
         "certifi",
         "sdp",
         "sdp_hlp",
         "ssl_mh",
         "concurrent",
         "markupsafe",
         "backports_abc",
         "contextvars",
         "foo.so",
         "bar.so",
     ]
     if salt.utils.thin.has_immutables:
         base_tops.extend(["immutables"])
     libs = salt.utils.thin.find_site_modules("contextvars")
     with patch("salt.utils.thin.find_site_modules", MagicMock(side_effect=[libs])):
         with patch(
             "builtins.__import__",
             MagicMock(
                 side_effect=[
                     type("salt", (), {"__file__": "/custom/foo.so"}),
                     type("salt", (), {"__file__": "/custom/bar.so"}),
                 ]
             ),
         ):
             tops = []
             for top in thin.get_tops(so_mods="foo,bar"):
                 if top.find("/") != -1:
                     spl = "/"
                 else:
                     spl = os.sep
                 tops.append(top.rsplit(spl, 1)[-1])
     assert len(tops) == len(base_tops)
     assert sorted(tops) == sorted(base_tops)
Exemplo n.º 10
0
    def test_get_tops(self):
        """
        Test thin.get_tops to get top directories, based on the interpreter.
        :return:
        """
        base_tops = [
            "/site-packages/salt",
            "/site-packages/jinja2",
            "/site-packages/yaml",
            "/site-packages/tornado",
            "/site-packages/msgpack",
            "/site-packages/certifi",
            "/site-packages/sdp",
            "/site-packages/sdp_hlp",
            "/site-packages/ssl_mh",
            "/site-packages/markupsafe",
            "/site-packages/backports_abc",
            "/site-packages/concurrent",
        ]

        tops = thin.get_tops()
        assert len(tops) == len(base_tops)
        assert sorted(tops) == sorted(base_tops)