Skip to content

Commit

Permalink
pep8 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ebridges committed Apr 3, 2019
1 parent 55e1600 commit 622ee24
Showing 1 changed file with 32 additions and 40 deletions.
72 changes: 32 additions & 40 deletions tests/test_util.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
'''
"""
Unit tests for util functions
'''
"""

from datetime import date
from unittest import TestCase, main
from accounting_reports import util


class TestUtil(TestCase):
'''
"""
Tests for misc. `accounting_reports.util` methods
'''
"""

def test_last_day_of_month_normal(self):
'''
"""
case: normal case
'''
"""
self.assertEqual(util.last_day_of_month(date(2017, 1, 1)), date(2017, 1, 31))
self.assertEqual(util.last_day_of_month(date(2017, 2, 1)), date(2017, 2, 28))
self.assertEqual(util.last_day_of_month(date(2017, 3, 1)), date(2017, 3, 31))
Expand All @@ -29,11 +29,10 @@ def test_last_day_of_month_normal(self):
self.assertEqual(util.last_day_of_month(date(2017, 11, 1)), date(2017, 11, 30))
self.assertEqual(util.last_day_of_month(date(2017, 12, 1)), date(2017, 12, 31))


def test_last_day_of_month_leap(self):
'''
"""
case: leap years
'''
"""
self.assertEqual(util.last_day_of_month(date(2016, 1, 1)), date(2016, 1, 31))
self.assertEqual(util.last_day_of_month(date(2016, 2, 1)), date(2016, 2, 29))
self.assertEqual(util.last_day_of_month(date(2016, 3, 1)), date(2016, 3, 31))
Expand All @@ -47,80 +46,73 @@ def test_last_day_of_month_leap(self):
self.assertEqual(util.last_day_of_month(date(2016, 11, 1)), date(2016, 11, 30))
self.assertEqual(util.last_day_of_month(date(2016, 12, 1)), date(2016, 12, 31))

'''
"""
case: exceptional leap years
'''
"""
self.assertEqual(util.last_day_of_month(date(1900, 2, 1)), date(1900, 2, 28))
self.assertEqual(util.last_day_of_month(date(2000, 2, 1)), date(2000, 2, 29))


def test_end_or_default_empty(self):
'''
"""
case: empty string as parameter
'''
"""
today = date.today()
last_day = util.last_day_of_month(today)
expected = date(today.year, today.month, last_day.day)
actual = util.end_or_default('')
self.assertEqual(expected, actual)


def test_end_or_default_none(self):
'''
"""
case: `None` as parameter
'''
"""
today = date.today()
last_day = util.last_day_of_month(today)
expected = date(today.year, today.month, last_day.day)
actual = util.end_or_default(None)
self.assertEqual(expected, actual)


def test_end_or_default_normal(self):
'''
"""
Normal case
'''
"""
test_case = '2018-06-30'
expected = date(2018, 6, 30)
actual = util.end_or_default(test_case)
self.assertEqual(expected, actual)


def test_begin_or_default_empty(self):
'''
"""
case: empty string as parameter
'''
"""
expected = date(date.today().year, 1, 1)
actual = util.begin_or_default('')
self.assertEqual(expected, actual)


def test_begin_or_default_none(self):
'''
"""
case: `None` as parameter
'''
"""
expected = date(date.today().year, 1, 1)
actual = util.begin_or_default(None)
self.assertEqual(expected, actual)


def test_begin_or_default_normal(self):
'''
"""
Normal case
'''
"""
test_case = '2018-06-30'
expected = date(2018, 6, 30)
actual = util.begin_or_default(test_case)
self.assertEqual(expected, actual)


def test_list_of_months_from_dec(self):
'''
"""
confirms that the list of months returned:
- handles YoY overlap
- handles leap years
- properly includes begin/end dates
'''
"""
begin = date(2015, 12, 1)
end = date(2017, 3, 1)

Expand All @@ -144,33 +136,33 @@ def test_list_of_months_from_dec(self):
self.assertEqual(actual[15], date(2017, 3, 31))

def test_csv_to_list_normal(self):
'''
"""
normal case
'''
"""
expected = ['a', 'b', 'c']
actual = util.csv_to_list('a,b,c')
self.assertSequenceEqual(expected, actual)

def test_csv_to_list_empty(self):
'''
"""
empty string case
'''
"""
expected = []
actual = util.csv_to_list('')
self.assertSequenceEqual(expected, actual)

def test_csv_to_list_none(self):
'''
"""
`None` string case
'''
"""
expected = []
actual = util.csv_to_list(None)
self.assertSequenceEqual(expected, actual)

def test_csv_to_list_one_comma(self):
'''
"""
String with one comma case
'''
"""
expected = ['', '']
actual = util.csv_to_list(',')
self.assertSequenceEqual(expected, actual)
Expand Down

0 comments on commit 622ee24

Please sign in to comment.