Ejemplo n.º 1
0
def test_ReqPackage__render_as_root():
    bar = mock.Mock(key='bar', project_name='bar', version='4.1.0')
    bar_req = mock.Mock(key='bar',
                        project_name='bar',
                        version='4.1.0',
                        specs=[('>=', '4.0')])
    rp = p.ReqPackage(bar_req, dist=bar)
    is_frozen = False
    assert 'bar==4.1.0' == rp.render_as_root(is_frozen)
Ejemplo n.º 2
0
def test_ReqPackage__render_as_branch():
    bar = mock.Mock(key='bar', project_name='bar', version='4.1.0')
    bar_req = mock.Mock(key='bar',
                        project_name='bar',
                        version='4.1.0',
                        specs=[('>=', '4.0')])
    rp = p.ReqPackage(bar_req, dist=bar)
    is_frozen = False
    assert 'bar [required: >=4.0, installed: 4.1.0]' == rp.render_as_branch(
        is_frozen)
Ejemplo n.º 3
0
def test_DistPackage__render_as_branch():
    foo = mock.Mock(key='foo', project_name='foo', version='20.4.1')
    bar = mock.Mock(key='bar', project_name='bar', version='4.1.0')
    bar_req = mock.Mock(key='bar',
                        project_name='bar',
                        version='4.1.0',
                        specs=[('>=', '4.0')])
    rp = p.ReqPackage(bar_req, dist=bar)
    dp = p.DistPackage(foo).as_parent_of(rp)
    is_frozen = False
    assert 'foo==20.4.1 [requires: bar>=4.0]' == dp.render_as_branch(is_frozen)
Ejemplo n.º 4
0
def test_ReqPackage__as_dict():
    bar = mock.Mock(key='bar', project_name='bar', version='4.1.0')
    bar_req = mock.Mock(key='bar',
                        project_name='bar',
                        version='4.1.0',
                        specs=[('>=', '4.0')])
    rp = p.ReqPackage(bar_req, dist=bar)
    result = rp.as_dict()
    expected = {
        'key': 'bar',
        'package_name': 'bar',
        'installed_version': '4.1.0',
        'required_version': '>=4.0'
    }
    assert expected == result
Ejemplo n.º 5
0
def test_DistPackage__as_parent_of():
    foo = mock.Mock(key='foo', project_name='foo', version='20.4.1')
    dp = p.DistPackage(foo)
    assert dp.req is None

    bar = mock.Mock(key='bar', project_name='bar', version='4.1.0')
    bar_req = mock.Mock(key='bar',
                        project_name='bar',
                        version='4.1.0',
                        specs=[('>=', '4.0')])
    rp = p.ReqPackage(bar_req, dist=bar)
    dp1 = dp.as_parent_of(rp)
    assert dp1._obj == dp._obj
    assert dp1.req is rp

    dp2 = dp.as_parent_of(None)
    assert dp2 is dp