<commit_before>#!/usr/bin/env python
#
# Tests for dakota.dakota_utils module.
#
# Call with:
#   $ nosetests -sv
#
# <NAME> (<EMAIL>)

import os
from nose.tools import *
from dakota.dakota_utils import *
from . import start_dir, data_dir

# Global variables
parameters_file = os.path.join(data_dir, 'vector_parameter_study_params.in')
response_labels = ['Qs_median']
model = 'hydrotrend'
output_file = 'HYDROASCII.QS'
response_statistic = 'median'

# Fixtures -------------------------------------------------------------

def setup_module():
    """Called before any tests are performed."""
    print('\n*** ' + __name__)

def teardown_module():
    """Called after all tests have completed."""
    pass

# Tests ----------------------------------------------------------------

def test_is_dakota_installed():
    """Test whether Dakota is installed."""
    assert_true(is_dakota_installed())

def test_get_response_descriptors():
    """Test the get_response_descriptors function."""
    assert_equal(response_labels, get_response_descriptors(parameters_file))

def test_get_response_descriptors_unknown_file():
    """Test get_response_descriptors when parameters file not found."""
    assert_is_none(get_response_descriptors('foo.in'))

def test_get_analysis_components():
    """Test the get_analysis_components function."""
    ac = get_analysis_components(parameters_file)
    assert_equal(model, ac.pop(0))
    response = ac.pop(0)
    assert_equal(response['file'], output_file)
    assert_equal(response['statistic'], response_statistic)

def test_get_analysis_components_unknown_file():
    """Test get_analysis_components when parameters file not found."""
    assert_is_none(get_analysis_components('foo.in'))<commit_msg>is_dakota_installed() should return False on Travis<commit_after>#!/usr/bin/env python
#
# Tests for dakota.dakota_utils module.
#
# Call with:
#   $ nosetests -sv
#
# <NAME> (<EMAIL>)

import os
from nose.tools import *
from dakota.dakota_utils import *
from . import start_dir, data_dir

# Global variables
parameters_file = os.path.join(data_dir, 'vector_parameter_study_params.in')
response_labels = ['Qs_median']
model = 'hydrotrend'
output_file = 'HYDROASCII.QS'
response_statistic = 'median'

# Fixtures -------------------------------------------------------------

def setup_module():
    """Called before any tests are performed."""
    print('\n*** ' + __name__)

def teardown_module():
    """Called after all tests have completed."""
    pass

# Tests ----------------------------------------------------------------

def test_is_dakota_installed():
    """Test whether Dakota is installed."""
    r = is_dakota_installed()
    if os.environ.has_key('TRAVIS'):
        assert_false(r)

def test_get_response_descriptors():
    """Test the get_response_descriptors function."""
    assert_equal(response_labels, get_response_descriptors(parameters_file))

def test_get_response_descriptors_unknown_file():
    """Test get_response_descriptors when parameters file not found."""
    assert_is_none(get_response_descriptors('foo.in'))

def test_get_analysis_components():
    """Test the get_analysis_components function."""
    ac = get_analysis_components(parameters_file)
    assert_equal(model, ac.pop(0))
    response = ac.pop(0)
    assert_equal(response['file'], output_file)
    assert_equal(response['statistic'], response_statistic)

def test_get_analysis_components_unknown_file():
    """Test get_analysis_components when parameters file not found."""
    assert_is_none(get_analysis_components('foo.in'))
{'fraction_non_alphanumeric': 0.17845117845117844, 'fraction_numerical': 0.001122334455667789, 'mean_word_length': 3.672346002621232, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '798725', 'n_tokens_mistral': 1056, 'n_tokens_neox': 1054, 'n_words': 228}