Esempio n. 1
0
def test_get_template_path_local_file(tmpdir):
    """Verify get_template_path finding a file relative to CWD."""

    template_path = tmpdir.join('cfn_template.json')
    template_path.ensure()

    with tmpdir.as_cwd():
        result = get_template_path('cfn_template.json')
        assert template_path.samefile(result)
Esempio n. 2
0
def test_get_template_path_local_file(tmpdir):
    """Verify get_template_path finding a file relative to CWD."""

    template_path = tmpdir.join('cfn_template.json')
    template_path.ensure()

    with tmpdir.as_cwd():
        result = get_template_path('cfn_template.json')
        assert template_path.samefile(result)
Esempio n. 3
0
def test_get_template_path_file_in_syspath(tmpdir, monkeypatch):
    """Verify get_template_path with a file in sys.path.

    This ensures templates are able to be retrieved from remote packages.

    """

    template_path = tmpdir.join('cfn_template.json')
    template_path.ensure()

    monkeypatch.syspath_prepend(tmpdir)
    result = get_template_path(template_path.basename)
    assert template_path.samefile(result)
Esempio n. 4
0
def test_get_template_path_file_in_syspath(tmpdir, monkeypatch):
    """Verify get_template_path with a file in sys.path.

    This ensures templates are able to be retrieved from remote packages.

    """

    template_path = tmpdir.join('cfn_template.json')
    template_path.ensure()

    monkeypatch.syspath_prepend(tmpdir)
    result = get_template_path(template_path.basename)
    assert template_path.samefile(result)
Esempio n. 5
0
    def test_get_template_path_file_in_syspath(self):  # noqa pylint: disable=invalid-name
        """Verify get_template_path with a file in sys.path.

        This ensures templates are able to be retreived from remote packages.

        """
        stacker_tests_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))  # noqa
        old_sys_path = list(sys.path)
        sys.path.append(stacker_tests_dir)
        try:
            self.assertEqual(get_template_path('fixtures/cfn_template.yaml'),
                             os.path.join(stacker_tests_dir,
                                          'fixtures/cfn_template.yaml'))
        finally:
            sys.path = old_sys_path
Esempio n. 6
0
    def test_get_template_path_file_in_syspath(self):  # noqa pylint: disable=invalid-name
        """Verify get_template_path with a file in sys.path.

        This ensures templates are able to be retreived from remote packages.

        """
        stacker_tests_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))  # noqa
        old_sys_path = list(sys.path)
        sys.path.append(stacker_tests_dir)
        try:
            self.assertEqual(get_template_path('fixtures/cfn_template.yaml'),
                             os.path.join(stacker_tests_dir,
                                          'fixtures/cfn_template.yaml'))
        finally:
            sys.path = old_sys_path
Esempio n. 7
0
def test_get_template_path_invalid_file(tmpdir):
    """Verify get_template_path with an invalid filename."""

    with tmpdir.as_cwd():
        assert get_template_path('cfn_template.json') is None
Esempio n. 8
0
 def test_get_template_path_invalid_file(self):  # noqa pylint: disable=invalid-name
     """Verify get_template_path with an invalid filename."""
     self.assertEqual(get_template_path('afilenamethatdoesnotexist.txt'),
                      None)
Esempio n. 9
0
 def test_get_template_path_local_file(self):  # noqa pylint: disable=invalid-name
     """Verify get_template_path finding a file relative to CWD."""
     self.assertEqual(get_template_path(RAW_YAML_TEMPLATE_PATH),
                      RAW_YAML_TEMPLATE_PATH)
Esempio n. 10
0
 def test_get_template_path_invalid_file(self):  # noqa pylint: disable=invalid-name
     """Verify get_template_path with an invalid filename."""
     self.assertEqual(get_template_path('afilenamethatdoesnotexist.txt'),
                      None)
Esempio n. 11
0
 def test_get_template_path_local_file(self):  # noqa pylint: disable=invalid-name
     """Verify get_template_path finding a file relative to CWD."""
     self.assertEqual(get_template_path(RAW_YAML_TEMPLATE_PATH),
                      RAW_YAML_TEMPLATE_PATH)
Esempio n. 12
0
def test_get_template_path_invalid_file(tmpdir):
    """Verify get_template_path with an invalid filename."""

    with tmpdir.as_cwd():
        assert get_template_path('cfn_template.json') is None