(self)
| 735 | |
| 736 | @coroutine_test |
| 737 | async def test_export_based_on_item_classes(self): |
| 738 | items = [ |
| 739 | self.MyItem({"foo": "bar1", "egg": "spam1"}), |
| 740 | self.MyItem2({"hello": "world2", "foo": "bar2"}), |
| 741 | {"hello": "world3", "egg": "spam3"}, |
| 742 | ] |
| 743 | |
| 744 | formats = { |
| 745 | "csv": b"baz,egg,foo\r\n,spam1,bar1\r\n", |
| 746 | "json": b'[\n{"hello": "world2", "foo": "bar2"}\n]', |
| 747 | "jsonlines": ( |
| 748 | b'{"foo": "bar1", "egg": "spam1"}\n{"hello": "world2", "foo": "bar2"}\n' |
| 749 | ), |
| 750 | "xml": ( |
| 751 | b'<?xml version="1.0" encoding="utf-8"?>\n<items>\n<item>' |
| 752 | b"<foo>bar1</foo><egg>spam1</egg></item>\n<item><hello>" |
| 753 | b"world2</hello><foo>bar2</foo></item>\n<item><hello>world3" |
| 754 | b"</hello><egg>spam3</egg></item>\n</items>" |
| 755 | ), |
| 756 | } |
| 757 | |
| 758 | settings = { |
| 759 | "FEEDS": { |
| 760 | self._random_temp_filename(): { |
| 761 | "format": "csv", |
| 762 | "item_classes": [self.MyItem], |
| 763 | }, |
| 764 | self._random_temp_filename(): { |
| 765 | "format": "json", |
| 766 | "item_classes": [self.MyItem2], |
| 767 | }, |
| 768 | self._random_temp_filename(): { |
| 769 | "format": "jsonlines", |
| 770 | "item_classes": [self.MyItem, self.MyItem2], |
| 771 | }, |
| 772 | self._random_temp_filename(): { |
| 773 | "format": "xml", |
| 774 | }, |
| 775 | }, |
| 776 | } |
| 777 | |
| 778 | data = await self.exported_data(items, settings) |
| 779 | for fmt, expected in formats.items(): |
| 780 | assert data[fmt] == expected |
| 781 | |
| 782 | @coroutine_test |
| 783 | async def test_export_based_on_custom_filters(self): |
nothing calls this directly
no test coverage detected