Ejemplo n.º 1
0
def test_status_channels_not_released_without_fallback(caplog, store_mock):
    """Support gaps in channel releases, nothing released in more stable ones."""
    caplog.set_level(logging.INFO, logger="charmcraft.commands")

    channel_map = [
        Release(revision=5, channel='latest/beta', expires_at=None),
        Release(revision=12, channel='latest/edge', expires_at=None),
    ]
    channels = _build_channels()
    revisions = [
        _build_revision(revno=5, version='5.1'),
        _build_revision(revno=12, version='almostready'),
    ]
    store_mock.list_releases.return_value = (channel_map, channels, revisions)

    args = Namespace(name='testcharm')
    StatusCommand('group').run(args)

    assert store_mock.mock_calls == [
        call.list_releases('testcharm'),
    ]

    expected = [
        "Track    Channel    Version      Revision",
        "latest   stable     -            -",
        "         candidate  -            -",
        "         beta       5.1          5",
        "         edge       almostready  12",
    ]
    assert expected == [rec.message for rec in caplog.records]
Ejemplo n.º 2
0
def test_status_channels_not_released_with_fallback(caplog, store_mock):
    """Support gaps in channel releases, having fallbacks."""
    caplog.set_level(logging.INFO, logger="charmcraft.commands")

    channel_map = [
        Release(revision=7, channel='latest/stable', expires_at=None),
        Release(revision=80, channel='latest/edge', expires_at=None),
    ]
    channels = _build_channels()
    revisions = [
        _build_revision(revno=7, version='v7'),
        _build_revision(revno=80, version='2.0'),
    ]
    store_mock.list_releases.return_value = (channel_map, channels, revisions)

    args = Namespace(name='testcharm')
    StatusCommand('group').run(args)

    assert store_mock.mock_calls == [
        call.list_releases('testcharm'),
    ]

    expected = [
        "Track    Channel    Version    Revision",
        "latest   stable     v7         7",
        "         candidate  ↑          ↑",
        "         beta       ↑          ↑",
        "         edge       2.0        80",
    ]
    assert expected == [rec.message for rec in caplog.records]
Ejemplo n.º 3
0
def test_status_simple_ok(caplog, store_mock):
    """Simple happy case of getting a status."""
    caplog.set_level(logging.INFO, logger="charmcraft.commands")

    channel_map = [
        Release(revision=7, channel='latest/stable', expires_at=None),
        Release(revision=7, channel='latest/candidate', expires_at=None),
        Release(revision=80, channel='latest/beta', expires_at=None),
        Release(revision=156, channel='latest/edge', expires_at=None),
    ]
    channels = _build_channels()
    revisions = [
        _build_revision(revno=7, version='v7'),
        _build_revision(revno=80, version='2.0'),
        _build_revision(revno=156, version='git-0db35ea1'),
    ]
    store_mock.list_releases.return_value = (channel_map, channels, revisions)

    args = Namespace(name='testcharm')
    StatusCommand('group').run(args)

    assert store_mock.mock_calls == [
        call.list_releases('testcharm'),
    ]

    expected = [
        "Track    Channel    Version       Revision",
        "latest   stable     v7            7",
        "         candidate  v7            7",
        "         beta       2.0           80",
        "         edge       git-0db35ea1  156",
    ]
    assert expected == [rec.message for rec in caplog.records]
Ejemplo n.º 4
0
def test_status_with_multiple_branches(caplog, store_mock):
    """Support having multiple branches."""
    caplog.set_level(logging.INFO, logger="charmcraft.commands")

    tstamp_with_timezone = parser.parse('2020-07-03T20:30:40Z')
    channel_map = [
        Release(revision=5, channel='latest/beta', expires_at=None),
        Release(revision=12,
                channel='latest/beta/branch-1',
                expires_at=tstamp_with_timezone),
        Release(revision=15,
                channel='latest/beta/branch-2',
                expires_at=tstamp_with_timezone),
    ]
    channels = _build_channels()
    channels.extend([
        Channel(name='latest/beta/branch-1',
                fallback='latest/beta',
                track='latest',
                risk='beta',
                branch='branch-1'),
        Channel(name='latest/beta/branch-2',
                fallback='latest/beta',
                track='latest',
                risk='beta',
                branch='branch-2'),
    ])
    revisions = [
        _build_revision(revno=5, version='5.1'),
        _build_revision(revno=12, version='ver.12'),
        _build_revision(revno=15, version='15.0.0'),
    ]
    store_mock.list_releases.return_value = (channel_map, channels, revisions)

    args = Namespace(name='testcharm')
    StatusCommand('group').run(args)

    assert store_mock.mock_calls == [
        call.list_releases('testcharm'),
    ]

    expected = [
        "Track    Channel        Version    Revision    Expires at",
        "latest   stable         -          -",
        "         candidate      -          -",
        "         beta           5.1        5",
        "         edge           ↑          ↑",
        "         beta/branch-1  ver.12     12          2020-07-03T20:30:40+00:00",
        "         beta/branch-2  15.0.0     15          2020-07-03T20:30:40+00:00",
    ]
    assert expected == [rec.message for rec in caplog.records]
Ejemplo n.º 5
0
def test_status_tracks_order(caplog, store_mock):
    """Respect the track ordering from the store."""
    caplog.set_level(logging.INFO, logger="charmcraft.commands")

    channel_map = [
        Release(revision=1, channel='latest/edge', expires_at=None),
        Release(revision=2, channel='aaa/edge', expires_at=None),
        Release(revision=3, channel='2.0/edge', expires_at=None),
        Release(revision=4, channel='zzz/edge', expires_at=None),
    ]
    channels_latest = _build_channels()
    channels_track_1 = _build_channels(track='zzz')
    channels_track_2 = _build_channels(track='2.0')
    channels_track_3 = _build_channels(track='aaa')
    channels = channels_latest + channels_track_1 + channels_track_2 + channels_track_3
    revisions = [
        _build_revision(revno=1, version='v1'),
        _build_revision(revno=2, version='v2'),
        _build_revision(revno=3, version='v3'),
        _build_revision(revno=4, version='v4'),
    ]
    store_mock.list_releases.return_value = (channel_map, channels, revisions)

    args = Namespace(name='testcharm')
    StatusCommand('group').run(args)

    assert store_mock.mock_calls == [
        call.list_releases('testcharm'),
    ]

    expected = [
        "Track    Channel    Version    Revision",
        "latest   stable     -          -",
        "         candidate  -          -",
        "         beta       -          -",
        "         edge       v1         1",
        "zzz      stable     -          -",
        "         candidate  -          -",
        "         beta       -          -",
        "         edge       v4         4",
        "2.0      stable     -          -",
        "         candidate  -          -",
        "         beta       -          -",
        "         edge       v3         3",
        "aaa      stable     -          -",
        "         candidate  -          -",
        "         beta       -          -",
        "         edge       v2         2",
    ]
    assert expected == [rec.message for rec in caplog.records]
Ejemplo n.º 6
0
def test_status_multiple_tracks(caplog, store_mock):
    """Support multiple tracks."""
    caplog.set_level(logging.INFO, logger="charmcraft.commands")

    channel_map = [
        Release(revision=503, channel='latest/stable', expires_at=None),
        Release(revision=1, channel='2.0/edge', expires_at=None),
    ]
    channels_latest = _build_channels()
    channels_track = _build_channels(track='2.0')
    channels = channels_latest + channels_track
    revisions = [
        _build_revision(revno=503, version='7.5.3'),
        _build_revision(revno=1, version='1'),
    ]
    store_mock.list_releases.return_value = (channel_map, channels, revisions)

    args = Namespace(name='testcharm')
    StatusCommand('group').run(args)

    assert store_mock.mock_calls == [
        call.list_releases('testcharm'),
    ]

    expected = [
        "Track    Channel    Version    Revision",
        "latest   stable     7.5.3      503",
        "         candidate  ↑          ↑",
        "         beta       ↑          ↑",
        "         edge       ↑          ↑",
        "2.0      stable     -          -",
        "         candidate  -          -",
        "         beta       -          -",
        "         edge       1          1",
    ]
    assert expected == [rec.message for rec in caplog.records]