Exemple #1
0
def test_from_dict_w_modifier():
    glass_mod = {
        "identifier": "test_glass_mod",
        "type": "glass",
        "r_transmissivity": 0.4,
        "g_transmissivity": 0.5,
        "b_transmissivity": 0.6,
        "refraction_index": None,
        "modifier": None,
        "dependencies": []
    }

    plastic_dict = {
        "identifier": "test_plastic",
        "type": "plastic",
        "r_reflectance": 0.1,
        "g_reflectance": 0.2,
        "b_reflectance": 0.3,
        "specularity": 0.01,
        "roughness": 0.02,
        "modifier": glass_mod,
        "dependencies": []
    }

    gg = Plastic.from_dict(plastic_dict)
    assert gg.to_radiance(minimal=True, include_modifier=False) == \
        'test_glass_mod plastic test_plastic 0 0 5 0.1 0.2 0.3 0.01 0.02'
    assert gg.modifier.to_radiance(minimal=True) == \
        'void glass test_glass_mod 0 0 3 0.4 0.5 0.6'
def test_objects_from_lib():
    """Test getting several objects from the library."""
    runner = CliRunner()

    result = runner.invoke(modifiers_by_id,
                           ['generic_wall_0.50', 'generic_floor_0.20'])
    assert result.exit_code == 0
    mat_dict = json.loads(result.output)
    assert isinstance(Plastic.from_dict(mat_dict[0]), Plastic)

    result = runner.invoke(modifier_sets_by_id,
                           ['Generic_Interior_Solar_Modifier_Set'])
    assert result.exit_code == 0
    con_dict = json.loads(result.output)
    assert isinstance(ModifierSet.from_dict(con_dict[0]), ModifierSet)
def test_object_from_lib():
    """Test getting an object from the library."""
    runner = CliRunner()

    result = runner.invoke(modifier_by_id, ['generic_wall_0.50'])
    assert result.exit_code == 0
    mat_dict = json.loads(result.output)
    assert isinstance(Plastic.from_dict(mat_dict), Plastic)

    result = runner.invoke(modifier_by_id,
                           ['generic_exterior_window_vis_0.64'])
    assert result.exit_code == 0
    mat_dict = json.loads(result.output)
    assert isinstance(Glass.from_dict(mat_dict), Glass)

    result = runner.invoke(modifier_set_by_id,
                           ['Generic_Interior_Solar_Modifier_Set'])
    assert result.exit_code == 0
    con_dict = json.loads(result.output)
    assert isinstance(ModifierSet.from_dict(con_dict), ModifierSet)