def test_parse_data_command_sub_service_upercase(pacu:Main):
    msg = pacu._parse_data_command_sub_service(service_data, 'LOWERCASE_KEY')
    assert '"lowercase_key_value"' == msg
    msg = pacu._parse_data_command_sub_service(service_data, 'UPERCASE_KEY')
    assert '"upercase_key_value"' == msg
    msg = pacu._parse_data_command_sub_service(service_data, 'MIXCASE_KEY')
    assert '"mixcase_key_value"' == msg
    msg = pacu._parse_data_command_sub_service(service_data, 'NO_DATA_KEY')
    assert '  No data found.' == msg
def test_parse_data_command_sub_service_lowercase(pacu:Main):
    msg = pacu._parse_data_command_sub_service(service_data, 'lowercase_key')
    assert '"lowercase_key_value"' == msg
    msg = pacu._parse_data_command_sub_service(service_data, 'upercase_key')
    assert '"upercase_key_value"' == msg
    msg = pacu._parse_data_command_sub_service(service_data, 'mixcase_key')
    assert '"mixcase_key_value"' == msg
    msg = pacu._parse_data_command_sub_service(service_data, 'no_data_key')
    assert '  No data found.' == msg
def test_parse_data_command_sub_service_mixcase(pacu:Main):
    msg = pacu._parse_data_command_sub_service(service_data, 'LowerCase_Key')
    assert '"lowercase_key_value"' == msg
    msg = pacu._parse_data_command_sub_service(service_data, 'UperCase_Key')
    assert '"upercase_key_value"' == msg
    msg = pacu._parse_data_command_sub_service(service_data, 'MixCase_Key')
    assert '"mixcase_key_value"' == msg
    msg = pacu._parse_data_command_sub_service(service_data, 'No_Data_Key')
    assert '  No data found.' == msg
Exemple #4
0
def main(args, pacu: Main):
    """Main module function, called from Pacu"""
    print = pacu.print
    session = pacu.get_active_session()
    snapshot_id = parser.parse_args(args).snapshot_id
    region = parser.parse_args(args).region

    if not snapshot_id:
        if not pacu.fetch_data(['EC2', 'Snapshots'],
                               'ebs__enum_volumes_snapshots', ''):
            print('Failed to fetch EBS snapshot data')
            return False

        try:
            s = snapshot_prompt(session.EC2['Snapshots'])
            snapshot_id = s['SnapshotId']
            region = s['Region']
        except UserWarning as e:
            print(*e.args)
            return False

    try:
        out_dir = get_dir(str(session.name))
        snap = snapshot.LocalSnapshot(str(out_dir), snapshot_id,
                                      pacu.get_boto_session(region=region),
                                      pacu.get_botocore_conf())
    except UserWarning as e:
        print(*e.args)
        return False

    snap.fetch()

    return SummaryData(
        out_dir=str(out_dir.relative_to('.')),
        snapshot_id=snapshot_id,
        snapshot_path=str(snap.path),
        vagrantfile=str(utils.init_vagrant(out_dir, True)),
    )
Exemple #5
0
def test_parse_data_command_returns_data_case_insensitive(
        pacu_with_data: Main, active_session: PacuSession):
    msg = pacu_with_data._parse_data_command(['data', 'cloudwatch'],
                                             active_session)
    assert 'test_key' in msg
    assert 'test_value' in msg
Exemple #6
0
def test_parse_data_command_returns_no_data_found_case_insensitive(
        pacu: Main, active_session: PacuSession):
    msg = pacu._parse_data_command(['data', 'cloudwatch'], active_session)
    assert 'No data found' in msg
Exemple #7
0
def test_parse_data_command_returns_help(pacu: Main,
                                         active_session: PacuSession):
    msg = pacu._parse_data_command(['data', 'non-existent-service'],
                                   active_session)
    assert 'Service not found. Please use the service name below.' in msg
    assert 'APIGateway	CloudTrail	CloudWatch	CodeBuild	Config' in msg
Exemple #8
0
def pacu(db):
    pacu = Main()
    pacu.database = db
    return pacu
def test_parse_data_command_sub_service_returns_help(pacu:Main):
    msg = pacu._parse_data_command_sub_service(service_data, 'non_existent_sub_service')
    assert 'Sub-service not found. Please use the sub-service name below.' in msg
    assert 'lowercase_key\tUPERCASE_KEY\tMixCase_Key\tno_data_key' in msg