Exemple #1
0
def test_invalid_assignment():
    opts = RtraceOptions()
    with pytest.raises(AttributeError):
        opts.mm = 20

    with pytest.raises(TypeError):
        opts.ab = 'ambient bounces'  # must be a numeric value
Exemple #2
0
def test_from_string():
    opt = RtraceOptions()
    opt_str = '-I -u- -h+ -lw 2e-06 -fa'
    opt.update_from_string(opt_str)
    assert opt.I == True
    assert opt.u == False
    assert opt.h == True
    assert opt.lw == 2e-06
    assert opt.fio == 'a'
Exemple #3
0
def test_reassignment():
    options = RtraceOptions()
    options.ab = 5
    assert options.ab == 5
    assert options.to_radiance() == '-ab 5'
    # remove assigned values
    options.ab = None
    assert options.ab == None
    assert options.to_radiance() == ''
Exemple #4
0
def test_assignment():
    options = RtraceOptions()
    options.ab = 5
    assert options.ab == 5
    assert options.to_radiance() == '-ab 5'
    # handle wrong value type like a boss
    options.ab = 3.2
    assert options.ab == 3
    assert options.to_radiance() == '-ab 3'
    'point-in-time-image': 'rpict',
    'rpict': 'rpict',
    '2': 'rfluxmtx',
    'annual': 'rfluxmtx',
    'rfluxmtx': 'rfluxmtx',
}

DETAIL_LEVELS = {'0': 0, 'low': 0, '1': 1, 'medium': 1, '2': 2, 'high': 2}

if all_required_inputs(ghenv.Component):
    # process the recipe type and level of detail
    _detail_level_ = DETAIL_LEVELS[_detail_level_.lower()] \
        if _detail_level_ is not None else 0
    command_name = RECIPE_TYPES[_recipe_type.lower()]
    if command_name == 'rtrace':
        option_dict = RTRACE
        option_obj = RtraceOptions()
    elif command_name == 'rpict':
        option_dict = RPICT
        option_obj = RpictOptions()
    elif command_name == 'rfluxmtx':
        option_dict = RFLUXMTX
        option_obj = RfluxmtxOptions()

    # assign the defualts to the object and output the string
    for opt_name, opt_val in option_dict.items():
        setattr(option_obj, opt_name, opt_val[_detail_level_])
    if additional_par_:
        option_obj.update_from_string(additional_par_)
    rad_par = option_obj.to_radiance()
Exemple #6
0
def test_from_string_non_standard():
    opt = RtraceOptions()
    opt_str = '-g 200'
    opt.update_from_string(opt_str)
    assert '-g 200' in opt.to_radiance()
Exemple #7
0
def test_exclusives_ae():
    opt = RtraceOptions()
    opt.ae = 'modifier_1'
    with pytest.raises(AssertionError):
        # i and I cannot be used together
        opt.ai = 'modifier_2'
Exemple #8
0
def test_exclusives_i():
    opt = RtraceOptions()
    opt.i = True
    with pytest.raises(AssertionError):
        # i and I cannot be used together
        opt.I = True
Exemple #9
0
def test_default():
    options = RtraceOptions()
    assert options.to_radiance() == ''
Exemple #10
0
def test_boolean_assignment():
    options = RtraceOptions()
    options.w = False
    options.h = True
    assert '-w-' in options.to_radiance()
    assert '-h' in options.to_radiance()
Exemple #11
0
def test_multiple_assignment():
    options = RtraceOptions()
    options.ab = 2
    options.ad = 546
    assert '-ab 2' in options.to_radiance()
    assert 'ad 546' in options.to_radiance()