예제 #1
0
 def test_default_cwd(self):
     init()
     context.cwd = '/tmp'
     task = Task()
     task.command('pwd')
     task.assert_that(task.lastcmd.stdout.content, contains_string('/tmp'))
     commit()
예제 #2
0
 def test_escape_linebreaks_on_log(self):
     task = Task()
     task.command(
         prego_cmd %
         '-v test/integration/cases.py:multiline_commands.test_writing_out')
     task.assert_that(task.lastcmd.stderr.content,
                      contains_string("hi\\nbye\\nagain"))
예제 #3
0
 def test_default_env(self):
     init()
     context.env = {'MY_ENV_VAR': '42'}
     task = Task()
     task.command('echo $MY_ENV_VAR')
     task.assert_that(task.lastcmd.stdout.content, contains_string('42'))
     commit()
예제 #4
0
 def test_for(self):
     task = Task()
     for i, retcode in [(0, 2), (1, 0), (2, 2)]:
         task.command('ls -%s' % i,
                      cwd='/tmp',
                      expected=retcode,
                      timeout=None)
예제 #5
0
 def test_env(self):
     init()
     context.env = {'PREGO_SAMPLE': 'hello'}
     task = Task()
     task.command('echo $PREGO_SAMPLE')
     task.assert_that(task.lastcmd.stdout.content, contains_string('hello'))
     commit()
예제 #6
0
 def test_old_config(self):
     ripio = Task()
     ripio.command(
         'bin/ripio --config test/fixtures/deprecated.conf create gh:ripio-test/foo',
         expected=1)
     ripio.assert_that(
         ripio.lastcmd.stdout.content,
         hamcrest.contains_string('AccessDenied: github:ripio-test/foo'))
예제 #7
0
파일: test.py 프로젝트: Rizoss/upper
    def run_server(self, prog):
        server = Task('server', detach=True)
        server.assert_that(localhost,
                           is_not(listen_port(context.port, proto='tcp')))
        server.command("./{0} $port".format(prog), expected=None)

        clients = self.run_clients()
        wait_clients(clients)
예제 #8
0
파일: test.py 프로젝트: Rizoss/upper
    def run_server(self, prog):
        server = Task(detach=True)
        server.assert_that(localhost,
                           is_not(listen_port(context.port, proto='udp')))
        server.command('./{0} $port'.format(prog), timeout=15, expected=None)

        clients = self.run_clients()
        wait_clients(clients)
예제 #9
0
    def test_print_outs_on_fail(self):
        task = Task()
        task.command(prego_cmd % '-peo examples/examples.py:Test.test_cmd_fail_with_outs', expected=1)
        task.assert_that(task.lastcmd.stderr.content,
                         contains_string("A.0.out| STDOUT"))

        task.assert_that(task.lastcmd.stderr.content,
                         contains_string("A.3.err| STDERR"))
예제 #10
0
 def test_bitbucket_private_no_creds(self):
     ripio = Task()
     ripio.command(
         'bin/ripio --config /dev/null clone bb:ripio-test/private',
         expected=1,
         timeout=10)
     ripio.assert_that(ripio.lastcmd.stdout.content,
                       hamcrest.contains_string('AccessDenied'))
예제 #11
0
    def test_default_timeout(self):
        init()
        context.timeout = 3
        task = Task()
        task.command('true')

        commit()
        self.assertEquals(task.lastcmd.timeout, 3)
예제 #12
0
파일: test.py 프로젝트: Rizoss/upper
    def test_help(self):
        for fname in glob.glob('*.py'):
            if 'stress' in fname or 'client' in fname:
                continue

            app = Task()
            app.command('./{}'.format(fname), expected=1)
            app.assert_that(
                app.lastcmd.stdout.content,
                contains_string('Usage: ./{} <port>'.format(fname)))
예제 #13
0
 def test_github_private_no_creds(self):
     ripio = Task()
     ripio.command(
         'bin/ripio --config /dev/null clone gh:ripio-test/private',
         expected=1,
         timeout=10)
     ripio.assert_that(
         ripio.lastcmd.stdout.content,
         hamcrest.contains_string(
             'RepositoryNotFound: github:ripio-test/private'))
예제 #14
0
    def make_client_server(self, client, server):
        servertask = Task('server', detach=True)
        server = servertask.command('{} --Ice.Config=Server.config'.format(server),
                                    cwd='$testdir', signal=2)
        servertask.assert_that(server.stdout.content, contains_string('Hello World!'))

        clientside = Task('client')
        clientside.wait_that(server, running())
        clientside.wait_that(server.stdout.content, contains_string('printer1'))
        clientside.command('{} "$(head -1 {})"'.format(client, server.stdout.path),
                           cwd='$testdir')
예제 #15
0
    def test_factorial(self):
        Task().command('make clean all')

        server = Task('server', detach=True)
        server.command('./factorial_server', expected=-15)

        client = Task('client')
        client.assert_that(server, running())
        client.command('./factorial_client localhost 8')
        client.assert_that(client.lastcmd.stdout.content,
                           hamcrest.contains_string('factorial(8): 40320'))
예제 #16
0
파일: test.py 프로젝트: DavidGB18/hello.ice
    def test_client_server(self):
        context.cwd = '$testdir'
        servertask = Task('server', detach=True)
        server = servertask.command('%s Server --Ice.Config=Server.config' % java,
                                    signal=2, expected=130)
        servertask.assert_that(server.stdout.content, contains_string('Hello World!'))

        clientside = Task('client')
        clientside.wait_that(server, running())
        clientside.wait_that(server.stdout.content, contains_string('printer1'))
        clientside.command('%s Client "$(head -1 %s)"' % (java, server.stdout.path))
예제 #17
0
    def test(self):
        with open(ctx.source, 'w') as s:
            s.write(code)

        gcc = Task('compile')
        gcc.command('gcc $source -o $bin')

        run = Task('run', detach=True)
        c = run.command('$bin', expected=None)

        check = Task('check')
        check.wait_that(c.stdout.content, contains_string('Hello!\n'))
예제 #18
0
    def run_with_config(self, mode, browser=None):
        write_config_file(mode, browser)

        server = Task(detach=True)
        server.command('python -m SimpleHTTPServer 8000', expected=-15, timeout=None)

        tester = Task()
        tester.wait_that(localhost, listen_port(8000))
        tester.command('nosetests -v test/tests.py', timeout=60)

        Task().command('killall chromedriver', expected=None, timeout=None)
        return tester
예제 #19
0
    def test_netcat(self):
        ctx.port = 2000
        server = Task(desc='netcat server', detach=True)
        server.assert_that(Package('nmap'), installed())
        server.assert_that(localhost, hamcrest.is_not(listen_port(ctx.port)))
        cmd = server.command('ncat -l -p $port')
        server.assert_that(cmd.stdout.content, hamcrest.contains_string('bye'))

        client = Task(desc='netcat client')
        client.wait_that(server, running())
        client.wait_that(localhost, listen_port(ctx.port))
        client.command('ncat -c "echo bye" localhost $port')
예제 #20
0
파일: test.py 프로젝트: Rizoss/upper
    def run_clients(self):
        Task().wait_that(localhost, listen_port(context.port, proto='tcp'))

        clients = []
        for i in range(10):
            req = 'hello-%s' % i
            client = Task('client', detach=True)
            client.command('echo %s | ./TCP_client.py localhost $port' % req)
            client.assert_that(client.lastcmd.stdout.content,
                               contains_string("Reply is '" + req.upper()))
            clients.append(client)

        return clients
예제 #21
0
    def test_pre_post(self):
        task = Task()
        task.assert_that(Variable('SHELL'), exists())
        task.assert_that(File('/etc/fstab'), exists())
        task.command('cp /etc/fstab /tmp/')
        task.generate_files('/tmp/fstab')

        task.command('ls / > /tmp/kk')  # shell=True)
        task.generate_files('/tmp/kk')

        task.assert_that(
            File('/tmp/kk').content,
            all_of(contains_string('sbin'), contains_string('home'),
                   contains_string('boot')))
예제 #22
0
 def test_set_read_var(self):
     init()
     context.port = 2030
     task = Task()
     cmd = task.command('echo $port')
     task.assert_that(cmd.stdout.content, contains_string('2030'))
     commit()
예제 #23
0
 def test_vv_implies_nocapture(self):
     task = Task()
     cmd = task.command(
         prego_cmd %
         '-vv test/fixtures/output.py:OutputFixture.test_print_text')
     task.assert_that(cmd.stdout.content,
                      contains_string('OutputFixture printed this'))
예제 #24
0
 def test_install(self):
     task = Task()
     task.assert_that(Package('python3-virtualenv'), installed())
     task.assert_that(Package('virtualenv'), installed())
     task.command('rm dist/*', expected=None)
     task.command('python setup.py sdist', timeout=20)
     task.command('virtualenv --clear venv', timeout=10)
     task.command(
         '. venv/bin/activate; pip install dist/prego*; echo y | pip uninstall prego; deactivate',
         timeout=50)
예제 #25
0
    def test_default_signal(self):
        init()
        context.signal = signal.SIGINT
        task = Task()
        cmd = task.command('sleep 5', timeout=1)

        try:
            commit()
            self.fail()
        except TestFailed:
            self.assertEquals(cmd.returncode, -signal.SIGINT)
예제 #26
0
 def test_no_detach_no_timeout(self):
     task = Task(detach=True)
     cmd = task.command(
         prego_cmd %
         '-v test/integration/advices.py:Timeout.test_no_detach_no_timeout',
         expected=None)
     task.wait_that(
         cmd.stderr.content,
         contains_string(
             "A.0 No timeout command in a non detached task could block forever!"
         ))
     Task().delay()
예제 #27
0
    def test_show_log_on_fail_command(self):
        task = Task(desc='fail')
        cmd = task.command(nose +
                           'examples/examples.py:Test.test_cmd_false_true',
                           expected=1)
        strings = [
            "TestFailed: assert that command A.0 expected returncode 0, but was 1",
            ">> begin captured logging <<", "[FAIL]   A   Task end - elapsed:"
        ]

        for s in strings:
            task.assert_that(cmd.stderr.content, contains_string(s))
예제 #28
0
    def test_keep_going_off(self):
        task = Task()
        cmd = task.command(
            prego_cmd % 'examples/examples.py:Test.test_cmd_wrong_true_and_ls',
            expected=1)

        strings = [
            "[ ok ]   A.0 Command 'wrong' code (0:127)",
            "assert that command A.0 expected returncode 0, but was 127",
            "[ -- ]   A.3 Command 'true'",
            "[ -- ]   A.5 assert that command A.3 returncode 0",
        ]

        for s in strings:
            task.assert_that(cmd.stderr.content, contains_string(s))
예제 #29
0
 def start_selenium_server(self):
     Se = Task(detach=True)
     Se.command('java -jar selenium-server-standalone-2.31.0.jar',
                expected=143, timeout=None)
     Task().wait_that(localhost, listen_port(4444))
예제 #30
0
파일: cases.py 프로젝트: davidvilla/prego3
 def test_writing_out(self):
     task = Task()
     task.command('echo -e "hi\nbye\nagain"')
예제 #31
0
 def test_make_printer(self):
     client = Task()
     client.command('./client.py --Ice.Config=locator.config factory', cwd='icegrid-factory')