<commit_before>from nose.tools import assert_is, assert_equal
from bmi_ilamb import BmiIlamb

def test_component_name():
    component = BmiIlamb()
    name = component.get_component_name()
    assert_equal(name, 'ILAMB')
    assert_is(component.get_component_name(), name)


def test_start_time():
    component = BmiIlamb()
    assert_equal(component.get_start_time(), 0.0)


def test_end_time():
    component = BmiIlamb()
    assert_equal(component.get_end_time(), 1.0)


def test_current_time():
    component = BmiIlamb()
    assert_equal(component.get_current_time(), 0.0)


def test_time_step():
    component = BmiIlamb()
    assert_equal(component.get_time_step(), 1.0)


def test_time_units():
    component = BmiIlamb()
    assert_equal(component.get_time_units(), 's')


def test_get_input_var_names():
    component = BmiIlamb()
    assert_equal(component.get_input_var_names(), ())


def test_get_output_var_names():
    component = BmiIlamb()
    assert_equal(component.get_output_var_names(), ())


# Todo: test initialize, update, update_until, finalize.<commit_msg>Add unit tests for IRF methods<commit_after>"""Unit tests for the ILAMB BMI."""

import os
from nose.tools import raises, assert_is, assert_equal, assert_true
from bmi_ilamb import BmiIlamb
from .. import data_dir


bmi_ilamb_config = os.path.join(data_dir, 'bmi_ilamb.yaml')


def test_component_name():
    component = BmiIlamb()
    name = component.get_component_name()
    assert_equal(name, 'ILAMB')
    assert_is(component.get_component_name(), name)


def test_start_time():
    component = BmiIlamb()
    assert_equal(component.get_start_time(), 0.0)


def test_end_time():
    component = BmiIlamb()
    assert_equal(component.get_end_time(), 1.0)


def test_current_time():
    component = BmiIlamb()
    assert_equal(component.get_current_time(), 0.0)


def test_time_step():
    component = BmiIlamb()
    assert_equal(component.get_time_step(), 1.0)


def test_time_units():
    component = BmiIlamb()
    assert_equal(component.get_time_units(), 's')


def test_get_input_var_names():
    component = BmiIlamb()
    assert_equal(component.get_input_var_names(), ())


def test_get_output_var_names():
    component = BmiIlamb()
    assert_equal(component.get_output_var_names(), ())


@raises(TypeError)
def test_initialize_no_argument():
    component = BmiIlamb()
    component.initialize()


def test_initialize():
    component = BmiIlamb()
    component.initialize(bmi_ilamb_config)


def test_initialize_n_arguments():
    component = BmiIlamb()
    component.initialize(bmi_ilamb_config)
    assert_equal(len(component.args), 7)


def test_initialize_sets_env_vars():
    component = BmiIlamb()
    component.initialize(bmi_ilamb_config)
    assert_true(os.environ.has_key('ILAMB_ROOT'))
    assert_true(os.environ.has_key('MPLBACKEND'))


def test_finalize():
    component = BmiIlamb()
    component.finalize()


def test_update():
    component = BmiIlamb()
    component.initialize(bmi_ilamb_config)
    component.update()
    component.finalize()


def test_update_until():
    component = BmiIlamb()
    component.initialize(bmi_ilamb_config)
    component.update_until(10.0)
    component.finalize()
{'fraction_non_alphanumeric': 0.11425902864259029, 'fraction_numerical': 0.0062266500622665, 'mean_word_length': 4.841818181818182, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2615350', 'n_tokens_mistral': 1121, 'n_tokens_neox': 1086, 'n_words': 188}