Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
uvchik committed Dec 10, 2019
1 parent 54feb0b commit 726c618
Showing 1 changed file with 30 additions and 9 deletions.
39 changes: 30 additions & 9 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,35 @@
import shutil
import pandas as pd
from oemof import solph
from deflex import main, config as cfg, scenario_tools
from deflex import main, config as cfg
from nose.tools import assert_raises_regexp


def test_main():
date_time_index = pd.date_range('1/1/2014', periods=30, freq='H')
es = solph.EnergySystem(timeindex=date_time_index)
base_path = os.path.join(os.path.dirname(__file__), 'data')
cfg.tmp_set('paths', 'scenario', base_path)
main.main_secure(2014, 'de22')
main.main_secure(2014, 'de21', es=es)
shutil.rmtree(os.path.join(base_path, 'deflex', '2014', 'results_cbc'))
class TestMain:
@classmethod
def setUpClass(cls):
date_time_index = pd.date_range('1/1/2014', periods=30, freq='H')
cls.es = solph.EnergySystem(timeindex=date_time_index)
base_path = os.path.join(os.path.dirname(__file__), 'data')
cfg.tmp_set('paths', 'scenario', base_path)

@classmethod
def tearDownClass(cls):
base_path = os.path.join(os.path.dirname(__file__), 'data')
shutil.rmtree(os.path.join(
base_path, 'deflex', '2014', 'results_cbc'))

def test_main_secure(self):
main.main_secure(2014, 'de22')

def test_main_secure_with_es(self):
main.main_secure(2014, 'de21', es=self.es)

def test_main_secure_with_xls_file(self):
main.main_secure(2014, 'de02', csv=False, es=self.es)


def test_duplicate_input():
msg = "It is not allowed to define more than one input."
with assert_raises_regexp(ValueError, msg):
main.model_scenario(xls_file='something', csv_path='something')

0 comments on commit 726c618

Please sign in to comment.