Esempio n. 1
0
    def test_requires_path_exists_fails(self):
        with self.assertRaises(RequiredPathDoesNotExist) as raised:
            file_utils.requires_path_exists('foo').__enter__()

        self.assertIsInstance(raised.exception, SnapcraftError)
        self.assertEqual("Required path does not exist: 'foo'",
                         str(raised.exception))
Esempio n. 2
0
    def test_requires_path_exists_custom_error(self):
        raised = self.assertRaises(
            RequiredPathDoesNotExist,
            file_utils.requires_path_exists(
                'foo', error_fmt='what? {path!r}').__enter__)

        self.assertEqual("what? 'foo'", str(raised))
Esempio n. 3
0
    def test_requires_path_exists_fails(self):
        raised = self.assertRaises(
            RequiredPathDoesNotExist,
            file_utils.requires_path_exists('foo').__enter__)

        self.assertIsInstance(raised, SnapcraftError)
        self.assertEqual("Required path does not exist: 'foo'", str(raised))
Esempio n. 4
0
    def test_requires_path_exists_fails(self):
        raised = self.assertRaises(
            RequiredPathDoesNotExist, file_utils.requires_path_exists("foo").__enter__
        )

        self.assertIsInstance(raised, SnapcraftError)
        self.assertThat(str(raised), Equals("Required path does not exist: 'foo'"))
Esempio n. 5
0
    def test_requires_path_exists_custom_error(self):
        raised = self.assertRaises(
            RequiredPathDoesNotExist,
            file_utils.requires_path_exists(
                "foo", error_fmt="what? {path!r}").__enter__,
        )

        self.assertThat(str(raised), Equals("what? 'foo'"))
Esempio n. 6
0
    def test_requires_path_exists_custom_error(self):
        raised = self.assertRaises(
            RequiredPathDoesNotExist,
            file_utils.requires_path_exists(
                'foo', error_fmt='what? {path!r}'
            ).__enter__)

        self.assertEqual("what? 'foo'", str(raised))
Esempio n. 7
0
    def test_requires_path_exists_custom_error(self):
        raised = self.assertRaises(
            RequiredPathDoesNotExist,
            file_utils.requires_path_exists(
                "foo", error_fmt="what? {path!r}"
            ).__enter__,
        )

        self.assertThat(str(raised), Equals("what? 'foo'"))
Esempio n. 8
0
    def test_requires_path_exists_fails(self):
        raised = self.assertRaises(
            errors.RequiredPathDoesNotExist,
            file_utils.requires_path_exists("foo").__enter__,
        )

        self.assertIsInstance(raised, errors.SnapcraftError)
        self.assertThat(str(raised),
                        Equals("Required path does not exist: 'foo'"))
Esempio n. 9
0
def requires_travis_preconditions():
    """Verify all Travis CI integration preconditions."""
    required = (
        requires_command_success(
            "travis settings",
            not_found_fmt=(
                "Travis CLI (`{cmd_list[0]}`) is not available.\n"
                "Please install it before trying this command again:\n\n"
                "    $ sudo apt install ruby-dev ruby-ffi libffi-dev\n"
                "    $ sudo gem install travis\n"
            ),
            failure_fmt=(
                "Travis CLI (`{command}`) is not functional or you are not "
                "allowed to access this repository settings.\n"
                "Make sure it works correctly in your system before trying "
                "this command again."
            ),
        ),
        requires_command_success(
            "git status",
            not_found_fmt=(
                "Git (`{cmd_list[0]}`) is not available, this tool cannot "
                "verify its prerequisites.\n"
                "Please install it before trying this command again:\n\n"
                "    $ sudo apt install git\n"
            ),
            failure_fmt=(
                "The current directory is not a Git repository.\n"
                "Please switch to the desired project repository where "
                "Travis should be enabled."
            ),
        ),
        requires_path_exists(
            TRAVIS_CONFIG_FILENAME,
            error_fmt=(
                "Travis project is not initialized for the current "
                "directory.\n"
                "Please initialize Travis project (e.g. `travis init`) with "
                "appropriate parameters."
            ),
        ),
    )
    with ExitStack() as cm:
        [cm.enter_context(c) for c in required]
        yield
Esempio n. 10
0
 def test_requires_path_exists_works(self):
     file_utils.requires_path_exists('bar').__enter__()
Esempio n. 11
0
 def test_requires_path_exists_works(self):
     file_utils.requires_path_exists("bar").__enter__()
Esempio n. 12
0
    def test_requires_path_exists_custom_error(self):
        with self.assertRaises(RequiredPathDoesNotExist) as raised:
            file_utils.requires_path_exists(
                'foo', error_fmt='what? {path!r}').__enter__()

        self.assertEqual("what? 'foo'", str(raised.exception))