mirror of
https://github.com/kennethreitz/tablib.git
synced 2026-06-05 15:00:19 +00:00
100% Row test coverage
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user