Source code for bed.tests.test_config

# Import libraries
import pytest
import bed
import os


def test_class():
    """
    test class
    :return:
    """
    downloaded_data_path = bed.get_data()
    example_config = os.path.join(downloaded_data_path, 'example_config.yml')
    c = bed.Bed(example_config)  # Coming from Model.py
    assert c.degree_hours == 1
    assert c.demand_heat == 0
    assert c.config == {'path_example_data_set': 'example_data.csv'}


[docs]def test_demand(): """ test demand function :return: """ val = bed.demand() assert val == 0
[docs]def test_temperature_to_degree_hours(): """ test temperature_to_degree_hours function :return: """ val = bed.temperature_to_degree_hours() assert val == 1
[docs]def test_get_data(): """ test clean_up function :return: """ assert os.path.abspath(bed.get_data()) == os.path.abspath(os.path.join(os.getcwd(), 'downloaded_data/examples'))
[docs]def test_read_config(): """ test read_config :return: """ downloaded_data_path = bed.get_data() example_config = os.path.join(downloaded_data_path, 'example_config.yml') assert bed.read_config(example_config) == {'path_example_data_set': 'example_data.csv'}
[docs]def test_read_data(): """ test method :return: """ downloaded_data_path = bed.get_data() example_config = os.path.join(downloaded_data_path, 'example_config.yml') config = bed.read_config(example_config) example_key = list(config.keys())[0] example_value = os.path.join(downloaded_data_path, list(config.values())[0]) updated_config = config updated_config[example_key] = example_value df = (bed.Data(updated_config)).example_data_set assert list(df.name) == ['a', 'b', 'c'] assert list(df.value) == [1, 2, 3]
[docs]def test_method(): """ test method :return: """ assert bed.demand(2, 2) == 1 assert bed.temperature_to_degree_hours(2, 3) == 1
[docs]def test_write_outputs(): """ test diagnostics function :return: """ assert bed.write_outputs() == 'outputs'
[docs]def test_diagnostics(): """ test diagnostics function :return: """ assert bed.diagnostics() == 'diagnostics'
[docs]def test_clean_up(): """ test clean_up function :return: """ assert bed.clean_up() == 'clean up'
[docs]def test_class(): """ test class :return: """ assert bed.Bed().config == 'config' assert bed.Bed().degree_hours == 1 assert bed.Bed().demand_heat == 0