def test__sort_dictionary_should_sort_the_collection_by_weight_decending():
    dictionary= reproduction._build_dictionary(params)
    asserted_dictionary = reproduction._sort_dictionary(dictionary)
    asserted_values = reversed(list(map((lambda x: x['weight']),
                                        asserted_dictionary)))
    it = iter(asserted_values)
    it.next()
    is_sorted = all(b >= a for a, b in itertools.izip(asserted_values, it))
    assert is_sorted is True
def test__select_child():
    dictionary= reproduction._build_dictionary(params)
    total_fitness = reproduction._total_fitness(dictionary)
    asseted_child = reproduction._select_child(dictionary, total_fitness, params)
    assert isinstance(asseted_child, str)
def test__total_fitness():
    dictionary= reproduction._build_dictionary(params)
    asserted_total = reproduction._total_fitness(dictionary)
    assert not isinstance(asserted_total, str)
def test__build_dictionary_should_return_a_collection_of_dictionaries_with_key_weight():
    asserted_dictionary = reproduction._build_dictionary(params)
    for asserted in asserted_dictionary:
        assert not isinstance(asserted['weight'], str)
def test__build_dictionary_should_return_a_collection_of_dictionaries():
    asserted_dictionary = reproduction._build_dictionary(params)
    for asserted in asserted_dictionary:
        assert isinstance(asserted, dict)
def test__build_dictionary_should_return_a_collection_of_size_8():
    asserted_dictionary = reproduction._build_dictionary(params)
    assert len(asserted_dictionary) >= 2