Skip to content

Commit

Permalink
Added tests for the new validate_read() and validate_write() methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
austinhartzheim committed Aug 11, 2015
1 parent 5a1b519 commit f94b895
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions tests/test_rigidity.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,26 @@ def test_validate_no_rules(self):
data1 = [['a', 'b'], ['c', 'd']]
self.assertEqual(r.validate(data1), data1)

def test_validate_read_no_rules(self):
'''
Test that the validate_read() method does not change the data
if no rules are provided.
'''
r = rigidity.Rigidity(csv.reader(tempfile.TemporaryFile()), [[], []])

data1 = [['a', 'b'], ['c', 'd']]
self.assertEqual(r.validate_read(data1), data1)

def test_validate_write_no_rules(self):
'''
Test that the validate_write() method does not change the data
if no rules are provided.
'''
r = rigidity.Rigidity(csv.reader(tempfile.TemporaryFile()), [[], []])

data1 = [['a', 'b'], ['c', 'd']]
self.assertEqual(r.validate_write(data1), data1)

def test_validate_dict_no_rules(self):
'''
Test that the validate method works correctly on Dict rows when
Expand All @@ -41,6 +61,26 @@ def test_validate_dict_no_rules(self):
data1 = {'a': 'hello', 'b': 'world'}
self.assertDictEqual(r.validate(data1), data1)

def test_validate_dict_read_no_rules(self):
'''
Test that the validate_read() method works correctly on Dict
rows when the rules Dict is empty.
'''
r = rigidity.Rigidity(csv.reader(tempfile.TemporaryFile()),
{'a': [], 'b': []})
data1 = {'a': 'hello', 'b': 'world'}
self.assertDictEqual(r.validate_read(data1), data1)

def test_validate_dict_write_no_rules(self):
'''
Test that the validate_write() method works correctly on Dict
rows when the rules Dict is empty.
'''
r = rigidity.Rigidity(csv.reader(tempfile.TemporaryFile()),
{'a': [], 'b': []})
data1 = {'a': 'hello', 'b': 'world'}
self.assertDictEqual(r.validate_write(data1), data1)

def test_writeheader(self):
'''
Test that the writehader() method on a CSVWriter is called when
Expand Down

0 comments on commit f94b895

Please sign in to comment.