예제 #1
0
파일: examples.py 프로젝트: Yelp/pgctl
    def it_can_recover_from_a_git_clean(self, in_example_dir, service_name):
        def assert_status():
            assert_command(
                ('pgctl', 'status'),
                '''\
 ● sleep: down
 ● tail: ready
   └─ pid: {PID}, {TIME} seconds
''',
                '',
                0,
                norm=norm.pgctl,
            )

        check_call(('pgctl', 'start', 'tail'))
        assert_status()

        # simulate a git-clean: blow everything away, create a fresh copy
        parent_dir = in_example_dir.join('..')
        with parent_dir.as_cwd():
            in_example_dir.remove(rec=True)
            from testing import copy_example
            copy_example(service_name, parent_dir)

        assert_status()
예제 #2
0
파일: examples.py 프로젝트: kentwills/pgctl
    def it_can_recover_from_a_git_clean(self, in_example_dir, service_name):
        def assert_status():
            assert_command(
                ("pgctl-2015", "status"),
                """\
sleep: down
tail: ready (pid {PID}) {TIME} seconds
""",
                "",
                0,
                norm=norm.pgctl,
            )

        check_call(("pgctl-2015", "start", "tail"))
        assert_status()

        # simulate a git-clean: blow everything away, create a fresh copy
        parent_dir = in_example_dir.join("..")
        with parent_dir.as_cwd():
            in_example_dir.remove(rec=True)
            from testing import copy_example

            copy_example(service_name, parent_dir)

        assert_status()
예제 #3
0
    def it_can_recover_from_a_git_clean(self, in_example_dir, service_name):
        def assert_status():
            assert_command(
                ('pgctl', 'status'),
                '''\
 ● sleep: down
 ● tail: ready
   └─ pid: {PID}, {TIME} seconds
''',
                '',
                0,
                norm=norm.pgctl,
            )

        check_call(('pgctl', 'start', 'tail'))
        assert_status()

        # simulate a git-clean: blow everything away, create a fresh copy
        parent_dir = in_example_dir.join('..')
        with parent_dir.as_cwd():
            in_example_dir.remove(rec=True)
            from testing import copy_example
            copy_example(service_name, parent_dir)

        assert_status()
예제 #4
0
def in_example_dir(tmpdir, homedir, service_name):
    os.environ['HOME'] = homedir.strpath
    os.environ.pop('XDG_RUNTIME_DIR', None)

    example_dir = copy_example(service_name, tmpdir)

    with example_dir.as_cwd():
        try:
            yield example_dir
        finally:
            #  pytest does a chdir before calling cleanup handlers
            with example_dir.as_cwd():
                # XXX: this is imported here so the blanking of
                # XDG_RUNTIME_DIR above affects this call
                from pgctl.cli import PgctlApp
                PgctlApp().stop()
예제 #5
0
파일: conftest.py 프로젝트: Yelp/pgctl
def in_example_dir(tmpdir, homedir, service_name):
    os.environ['HOME'] = homedir.strpath

    # Also done by pytest.ini on session start, but is also done
    # here to prevent test pollution
    os.environ.pop('XDG_RUNTIME_DIR', None)

    example_dir = copy_example(service_name, tmpdir)

    with example_dir.as_cwd():
        try:
            yield example_dir
        finally:
            #  pytest does a chdir before calling cleanup handlers
            with example_dir.as_cwd():
                PgctlApp().stop()
예제 #6
0
파일: conftest.py 프로젝트: kentwills/pgctl
def in_example_dir(tmpdir, homedir, service_name):
    os.environ['HOME'] = homedir.strpath
    os.environ.pop('XDG_RUNTIME_DIR', None)

    example_dir = copy_example(service_name, tmpdir)

    with example_dir.as_cwd():
        try:
            yield example_dir
        finally:
            #  pytest does a chdir before calling cleanup handlers
            with example_dir.as_cwd():
                # XXX: this is imported here so the blanking of
                # XDG_RUNTIME_DIR above affects this call
                from pgctl.cli import PgctlApp
                PgctlApp().stop()