Skip to content

Commit

Permalink
Add tests for validate_input_list method
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisgilmerproj committed Oct 11, 2016
1 parent c34e765 commit 506c403
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
3 changes: 2 additions & 1 deletion brew/styles.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ def __init__(self,
self.ibu = self._validate_input_list(ibu, (int, float), "IBU")
self.color = self._validate_input_list(color, (int, float), "Color")

def _validate_input_list(self, value_list, value_type, name):
@classmethod
def _validate_input_list(cls, value_list, value_type, name):
"""
Private class to validate inputs for class parameters
Expand Down
24 changes: 24 additions & 0 deletions tests/test_styles.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,30 @@ def setUp(self):
# Define Style
self.style = american_pale_ale_style

def test_validate_input_list_empty(self):
with self.assertRaises(Exception):
Style._validate_input_list(None, (int, float), 'OG')

def test_validate_input_list_type(self):
with self.assertRaises(Exception):
Style._validate_input_list({'a': 'b'}, (int, float), 'OG')

def test_validate_input_list_length_short(self):
with self.assertRaises(Exception):
Style._validate_input_list([1], (int, float), 'OG')

def test_validate_input_list_length_long(self):
with self.assertRaises(Exception):
Style._validate_input_list([1, 2, 3], (int, float), 'OG')

def test_validate_input_list_wrong_type(self):
with self.assertRaises(Exception):
Style._validate_input_list([1, '2'], (int, float), 'OG')

def test_validate_input_list_bad_order(self):
with self.assertRaises(Exception):
Style._validate_input_list([2, 1], (int, float), 'OG')

def test_str(self):
out = str(self.style)
self.assertEquals(out, '18B American Pale Ale')
Expand Down

0 comments on commit 506c403

Please sign in to comment.