Esempio n. 1
0
def test_getreleases_empty(monkeypatch):
    def read(path, recursive=True):
        assert path == "appr/packages/ant31/rocketchat/releases.json"
        data = {'channels': {}, "releases": {}}
        return MockEtcdResult(path, data)

    monkeypatch.setattr("appr.models.kv.etcd.etcd_client.read", read)
    assert Package.all_releases("ant31/rocketchat") == []
Esempio n. 2
0
def test_locked(monkeypatch, package_b64blob):
    def write(path, data, prevExist, ttl=None):
        raise etcd.EtcdAlreadyExist

    def read(path):
        assert path == ""
        return True

    monkeypatch.setattr(
        "appr.models.kv.models_index_base.ModelsIndexBase.get_lock.im_func.__defaults__",
        (3, 0.1))

    monkeypatch.setattr("appr.models.kv.etcd.etcd_client.read", read)
    monkeypatch.setattr("appr.models.kv.etcd.etcd_client.write", write)
    with pytest.raises(UnableToLockResource):
        p = Package('a/b', "1.0.1", 'kpm', Blob("a/b", package_b64blob))
        p.save()
Esempio n. 3
0
def test_getrelease_invalid(getreleases):
    with pytest.raises(InvalidRelease):
        str(Package.get_release("ant31/rocketchat", "==4.25a"))
Esempio n. 4
0
def test_getrelease_stable_none(getreleases):
    assert str(Package.get_release("ant31/rocketchat", None, True)) == "1.4.2"
Esempio n. 5
0
def test_getrelease_default(getreleases):
    assert str(Package.get_release("ant31/rocketchat",
                                   "default")) == "1.8.2-rc2"
Esempio n. 6
0
def test_getreleases(getreleases):
    assert sorted(Package.all_releases("ant31/rocketchat")) == sorted(
        ['1.3.0', '1.3.2-rc2', '1.8.2-rc2', '1.4.2', '1.0.0', '1.2.0'])
Esempio n. 7
0
def test_getrelease_prerelease(getreleases):
    str(Package.get_release("ant31/rocketchat", ">=0-")) == "1.8.2-rc2"
Esempio n. 8
0
def test_check_data_invalidrelease():
    with pytest.raises(InvalidRelease):
        assert Package.check_release("1.4.5a-alpha")
Esempio n. 9
0
def test_check_data_validrelease():
    assert Package.check_release("1.4.5-alpha") is None