def when_action_command(ctx, desired_header): command = "dnf repoquery some-random-query-to-initiate-communication" s = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.ntohs(0x0003)) s.settimeout(2) ctx.cmd_result = command_utils.run(ctx, command) try: for x in range(1000): packet = s.recv(1024) if desired_header in str(packet): return raise AssertionError(desired_header + 'not found in last 1000 packets') except socket.timeout: raise AssertionError('"{}" not found in "{}" recieved packets and no new packets within 2 sec.' .format(desired_header, str(x)))
def when_action_command(ctx, desired_header): command = "dnf repoquery some-random-query-to-initiate-communication" s = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.ntohs(0x0003)) s.settimeout(2) ctx.cmd_result = command_utils.run(ctx, command) try: for x in range(1000): packet = s.recv(1024) if desired_header in str(packet): return raise AssertionError(desired_header + 'not found in last 1000 packets') except socket.timeout: raise AssertionError( '"{}" not found in "{}" recieved packets and no new packets within 2 sec.' .format(desired_header, str(x)))
def step_i_run_command(ctx, command): """ Run a ``{command}`` as subprocess, collect its output and returncode. """ ctx.cmd_result = command_utils.run(ctx, command)
def step_i_successfully_run_command_in_repository(ctx, command, repository): repo = repo_utils.get_repo_dir(repository) ctx.assertion.assertIsNotNone(repo, "repository does not exist") ctx.cmd_result = command_utils.run(ctx, command, cwd=repo) ctx.assertion.assertEqual(ctx.cmd_result.returncode, 0)
def step_the_command_stream_should_match_output_of(ctx, stream, command): cmd_result = command_utils.run(ctx, command) regexp = getattr(cmd_result, stream) text = getattr(ctx.cmd_result, stream) six.assertRegex(ctx.assertion, text, regexp)