Skip to content

Commit

Permalink
Merge pull request #205 from iiasa/test_exercise_1
Browse files Browse the repository at this point in the history
Test utils.check_year and .pd_write
  • Loading branch information
khaeru authored Nov 19, 2019
2 parents b155643 + d631633 commit 7a9c52e
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,42 @@ def test_pd_io_xlsx_multi():
pdt.assert_frame_equal(_obs, _exp)


def test_pd_write(tmp_path):

fname = 'test.csv'
d = tmp_path / "sub"
d.mkdir()

data_frame = [1, 2, 3, 4]

with pytest.raises(ValueError):
assert utils.pd_write(data_frame, fname)


def test_check_year():

# If y is a string value, raise a Value Error.

y1 = "a"
s1 = "a"
with pytest.raises(ValueError):
assert utils.check_year(y1, s1)

# If y = None.

y2 = None
s2 = None

assert utils.check_year(y2, s2) is None

# If y is integer.

y3 = 4
s3 = 4

assert utils.check_year(y3, s3) is True


m_s = dict(model='m', scenario='s')

URLS = [
Expand Down

0 comments on commit 7a9c52e

Please sign in to comment.