Exemple #1
0
    def test_sls_path_generation(self):
        """test generation of sls paths"""
        with patch.dict(
            saltcheck.__salt__,
            {"config.get": MagicMock(return_value="saltcheck-tests")},
        ):
            testLoader = saltcheck.StateTestLoader()

            state_name = "teststate"
            expected_return = [
                "salt://teststate/saltcheck-tests",
                "salt:///saltcheck-tests",
            ]
            ret = testLoader._generate_sls_path(state_name)
            self.assertEqual(ret, expected_return)

            state_name = "teststate.long.path"
            expected_return = [
                "salt://teststate/long/path/saltcheck-tests",
                "salt://teststate/long/saltcheck-tests",
                "salt://teststate/saltcheck-tests",
            ]
            ret = testLoader._generate_sls_path(state_name)
            self.assertEqual(ret, expected_return)

            state_name = "teststate.really.long.path"
            expected_return = [
                "salt://teststate/really/long/path/saltcheck-tests",
                "salt://teststate/really/long/saltcheck-tests",
                "salt://teststate/saltcheck-tests",
            ]
            ret = testLoader._generate_sls_path(state_name)
            self.assertEqual(ret, expected_return)
Exemple #2
0
    def test_sls_path_generation(self):
        '''test generation of sls paths'''
        with patch.dict(saltcheck.__salt__, {'config.get': MagicMock(return_value='saltcheck-tests')}):
            testLoader = saltcheck.StateTestLoader()

            state_name = 'teststate'
            expected_return = ['salt://teststate/saltcheck-tests',
                               'salt:///saltcheck-tests']
            ret = testLoader._generate_sls_path(state_name)
            self.assertEqual(ret, expected_return)

            state_name = 'teststate.long.path'
            expected_return = ['salt://teststate/long/path/saltcheck-tests',
                               'salt://teststate/long/saltcheck-tests',
                               'salt://teststate/saltcheck-tests']
            ret = testLoader._generate_sls_path(state_name)
            self.assertEqual(ret, expected_return)

            state_name = 'teststate.really.long.path'
            expected_return = ['salt://teststate/really/long/path/saltcheck-tests',
                               'salt://teststate/really/long/saltcheck-tests',
                               'salt://teststate/saltcheck-tests']
            ret = testLoader._generate_sls_path(state_name)
            self.assertEqual(ret, expected_return)