コード例 #1
0
ファイル: test_env_spec.py プロジェクト: irfanalamt/JSnoobie
def test_to_json():
    # the stuff from this parent env spec should NOT end up in the JSON
    hi = EnvSpec(
        name="hi",
        conda_packages=['q', 'r'],
        pip_packages=['zoo', 'boo'],
        channels=['x1', 'y1'],
        inherit_from_names=(),
        inherit_from=())
    spec = EnvSpec(
        name="foo",
        description="The Foo Spec",
        conda_packages=['a', 'b'],
        pip_packages=['c', 'd'],
        channels=['x', 'y'],
        inherit_from_names=('hi', ),
        inherit_from=(hi, ))
    json = spec.to_json()

    assert {
        'description': "The Foo Spec",
        'channels': ['x', 'y'],
        'inherit_from': 'hi',
        'packages': ['a', 'b', {
            'pip': ['c', 'd']
        }]
    } == json
コード例 #2
0
def test_to_json_no_description_no_pip_no_inherit():
    # should be able to jsonify a spec with no description
    spec = EnvSpec(name="foo",
                   conda_packages=['a', 'b'],
                   pip_packages=[],
                   channels=['x', 'y'],
                   inherit_from_names=(),
                   inherit_from=())
    json = spec.to_json()

    assert {'channels': ['x', 'y'], 'packages': ['a', 'b']} == json
コード例 #3
0
def test_to_json_multiple_inheritance():
    spec = EnvSpec(name="foo",
                   conda_packages=['a', 'b'],
                   pip_packages=['c', 'd'],
                   channels=['x', 'y'],
                   inherit_from_names=('hi', 'hello'))
    json = spec.to_json()

    assert {
        'channels': ['x', 'y'],
        'inherit_from': ['hi', 'hello'],
        'packages': ['a', 'b', {
            'pip': ['c', 'd']
        }]
    } == json