Example #1
0
def test_parse_arguments_no_mount_point(capsys):
    with pytest.raises(SystemExit) as ex:
        mount_efs.parse_arguments(['mount', 'fs-deadbeef'])

    assert 0 != ex.value.code

    out, err = capsys.readouterr()
    assert 'Usage:' in err
Example #2
0
def test_parse_arguments_invalid_fs_id(capsys):
    with pytest.raises(SystemExit) as ex:
        mount_efs.parse_arguments(['mount', 'not-a-file-system-id', '/dir'])

    assert 0 != ex.value.code

    out, err = capsys.readouterr()
    assert 'Invalid file system name' in err
Example #3
0
def _test_parse_arguments_help(capsys, help):
    with pytest.raises(SystemExit) as ex:
        mount_efs.parse_arguments(['mount', 'foo', 'bar', help])

    assert 0 == ex.value.code

    out, err = capsys.readouterr()
    assert 'Usage:' in out
Example #4
0
def test_parse_arguments_version(capsys):
    with pytest.raises(SystemExit) as ex:
        mount_efs.parse_arguments(['mount', 'foo', 'bar', '--version'])

    assert 0 == ex.value.code

    out, err = capsys.readouterr()
    assert 'Version: %.1f' % mount_efs.VERSION in out
def test_parse_arguments_no_fs_id(capsys):
    with pytest.raises(SystemExit) as ex:
        mount_efs.parse_arguments(None, ['mount'])

    assert 0 != ex.value.code

    out, err = capsys.readouterr()
    assert 'Usage:' in err
Example #6
0
def test_parse_arguments_no_mount_point(capsys):
    with pytest.raises(SystemExit) as ex:
        mount_efs.parse_arguments(None, ["mount", "fs-deadbeef"])

    assert 0 != ex.value.code

    out, err = capsys.readouterr()
    assert "Usage:" in err
Example #7
0
def test_parse_arguments():
    fsid, path, mountpoint, options = mount_efs.parse_arguments(
        ['mount', 'fs-deadbeef:/home', '/dir', '-o', 'foo,bar=baz,quux'])

    assert 'fs-deadbeef' == fsid
    assert '/home' == path
    assert '/dir' == mountpoint
    assert {'foo': None, 'bar': 'baz', 'quux': None} == options
Example #8
0
def test_parse_arguments_custom_path():
    fsid, path, mountpoint, options = mount_efs.parse_arguments(
        ['mount', 'fs-deadbeef:/home', '/dir'])

    assert 'fs-deadbeef' == fsid
    assert '/home' == path
    assert '/dir' == mountpoint
    assert {} == options
Example #9
0
def test_parse_arguments():
    fsid, path, mountpoint, options = mount_efs.parse_arguments(
        None, ["mount", "fs-deadbeef:/home", "/dir", "-o", "foo,bar=baz,quux"])

    assert "fs-deadbeef" == fsid
    assert "/home" == path
    assert "/dir" == mountpoint
    assert {"foo": None, "bar": "baz", "quux": None} == options
Example #10
0
def test_parse_arguments_custom_path():
    fsid, path, mountpoint, options = mount_efs.parse_arguments(
        None, ["mount", "fs-deadbeef:/home", "/dir"])

    assert "fs-deadbeef" == fsid
    assert "/home" == path
    assert "/dir" == mountpoint
    assert {} == options
Example #11
0
def test_parse_arguments_default_path():
    fsid, path, mountpoint, options = mount_efs.parse_arguments(
        None, ['mount', 'fs-deadbeef', '/dir'])

    assert 'fs-deadbeef' == fsid
    assert '/' == path
    assert '/dir' == mountpoint
    assert {} == options
Example #12
0
def test_parse_arguments_macos(mocker):
    mocker.patch('mount_efs.check_if_platform_is_mac', return_value=True)
    fsid, path, mountpoint, options = mount_efs.parse_arguments(
        None, [
            'mount', '-o', 'foo', '-o', 'bar=baz', '-o', 'quux',
            'fs-deadbeef:/home', '/dir'
        ])

    assert 'fs-deadbeef' == fsid
    assert '/home' == path
    assert '/dir' == mountpoint
    assert {'foo': None, 'bar': 'baz', 'quux': None} == options
Example #13
0
def test_parse_arguments_with_az_dns_name_mount_az_not_in_option(mocker):
    # When dns_name is provided for mounting, if the az is not provided in the mount option, also dns_name contains az
    # info, verify that the az info is present in the options
    dns_name = "us-east-1a.fs-deadbeef.efs.us-east-1.amazonaws.com"
    mocker.patch("mount_efs.match_device",
                 return_value=("fs-deadbeef", "/", "us-east-1a"))
    fsid, path, mountpoint, options = mount_efs.parse_arguments(
        None, ["mount", dns_name, "/dir", "-o", "foo,bar=baz,quux"])

    assert "fs-deadbeef" == fsid
    assert "/" == path
    assert "/dir" == mountpoint
    assert {
        "foo": None,
        "bar": "baz",
        "quux": None,
        "az": "us-east-1a"
    } == options
Example #14
0
def test_parse_arguments_with_az_dns_name_mount_az_not_in_option(mocker):
    # When dns_name is provided for mounting, if the az is not provided in the mount option, also dns_name contains az
    # info, verify that the az info is present in the options
    dns_name = 'us-east-1a.fs-deadbeef.efs.us-east-1.amazonaws.com'
    mocker.patch('mount_efs.match_device',
                 return_value=('fs-deadbeef', '/', 'us-east-1a'))
    fsid, path, mountpoint, options = mount_efs.parse_arguments(
        None, ['mount', dns_name, '/dir', '-o', 'foo,bar=baz,quux'])

    assert 'fs-deadbeef' == fsid
    assert '/' == path
    assert '/dir' == mountpoint
    assert {
        'foo': None,
        'bar': 'baz',
        'quux': None,
        'az': 'us-east-1a'
    } == options
Example #15
0
def test_parse_arguments_macos(mocker):
    mocker.patch("mount_efs.check_if_platform_is_mac", return_value=True)
    fsid, path, mountpoint, options = mount_efs.parse_arguments(
        None,
        [
            "mount",
            "-o",
            "foo",
            "-o",
            "bar=baz",
            "-o",
            "quux",
            "fs-deadbeef:/home",
            "/dir",
        ],
    )

    assert "fs-deadbeef" == fsid
    assert "/home" == path
    assert "/dir" == mountpoint
    assert {"foo": None, "bar": "baz", "quux": None} == options