diff options
| author | Hugo <hugovk@users.noreply.github.com> | 2019-10-19 21:55:01 +0300 |
|---|---|---|
| committer | Hugo <hugovk@users.noreply.github.com> | 2019-10-20 12:27:51 +0300 |
| commit | bf6e5c2e7845f13888abbf0d6362e4c2374471fb (patch) | |
| tree | f735b0243d1cc1ebc58800c23eb86c74a968f6f4 | |
| parent | 088b916bab9f34221a4a831df9683525538de728 (diff) | |
| download | tablib-bf6e5c2e7845f13888abbf0d6362e4c2374471fb.tar.gz | |
100% Row test coverage
| -rwxr-xr-x | tests/test_tablib.py | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/tests/test_tablib.py b/tests/test_tablib.py index b8049e8..5464a8d 100755 --- a/tests/test_tablib.py +++ b/tests/test_tablib.py @@ -4,6 +4,7 @@ import datetime import doctest import json +import pickle import unittest from uuid import uuid4 @@ -486,6 +487,87 @@ class TablibTestCase(BaseTestCase): self.founders.append(('First\nSecond', 'Name', 42)) self.founders.export('xlsx') + def test_row_repr(self): + """Row repr.""" + # Arrange + john = Row(self.john) + + # Act + output = str(john) + + # Assert + self.assertEqual(output, "['John', 'Adams', 90]") + + def test_row_pickle_unpickle(self): + """Row __setstate__ and __getstate__.""" + # Arrange + before_pickle = Row(self.john) + + # Act + output = pickle.loads(pickle.dumps(before_pickle)) + + # Assert + self.assertEqual(output[0], before_pickle[0]) + self.assertEqual(output[1], before_pickle[1]) + self.assertEqual(output[2], before_pickle[2]) + + def test_row_lpush(self): + """Row lpush.""" + # Arrange + john = Row(self.john) + george = Row(self.george) + + # Act + john.lpush(george) + + # Assert + self.assertEqual(john[-1], george) + + def test_row_append(self): + """Row append.""" + # Arrange + john = Row(self.john) + george = Row(self.george) + + # Act + john.append(george) + + # Assert + self.assertEqual(john[0], george) + + def test_row_contains(self): + """Row __contains__.""" + # Arrange + john = Row(self.john) + + # Act / Assert + self.assertIn("John", john) + + def test_row_no_tag(self): + """Row has_tag.""" + # Arrange + john = Row(self.john) + + # Act / Assert + self.assertFalse(john.has_tag("not found")) + self.assertFalse(john.has_tag(None)) + + def test_row_has_tag(self): + """Row has_tag.""" + # Arrange + john = Row(self.john, tags=["tag1"]) + + # Act / Assert + self.assertTrue(john.has_tag("tag1")) + + def test_row_has_tags(self): + """Row has_tag.""" + # Arrange + john = Row(self.john, tags=["tag1", "tag2"]) + + # Act / Assert + self.assertTrue(john.has_tag(["tag2", "tag1"])) + class HTMLTests(BaseTestCase): def test_html_export(self): |
