Esempio n. 1
0
    def test_export_to_dicts(self):
        table = rows.import_from_dicts(self.data)
        result = rows.export_to_dicts(table)
        full_data = [
            {
                "name": "Álvaro",
                "ids": "123",
                "number": 3,
                "other": None
            },
            {
                "name": "Test",
                "ids": "456",
                "number": None,
                "other": None
            },
            {
                "name": "Python",
                "ids": "123, 456",
                "number": None,
                "other": 3.14
            },
        ]

        self.assertEqual(len(result), len(table))
        for expected, actual in zip(full_data, result):
            self.assertDictEqual(expected, actual)
Esempio n. 2
0
    def test_export_to_dicts(self):
        table = rows.import_from_dicts(self.data)
        result = rows.export_to_dicts(table)
        full_data = [
            {
                'name': 'Álvaro',
                'ids': '123',
                'number': 3,
                'other': None,
            },
            {
                'name': 'Test',
                'ids': '456',
                'number': None,
                'other': None,
            },
            {
                'name': 'Python',
                'ids': '123, 456',
                'number': None,
                'other': 3.14,
            },
        ]

        self.assertEqual(len(result), len(table))
        for expected, actual in zip(full_data, result):
            self.assertDictEqual(expected, actual)
Esempio n. 3
0
    def is_product_exist(self, product_page_url):
        '''
        判断这个产品是否已经存在
        '''
        db = self.sqlite_db
        sql = 'SELECT * FROM product_saved WHERE product_page_url = ?'
        row = import_from_sqlite(db, query=sql, query_args=(product_page_url,))
        product_list = export_to_dicts(row)

        return len(product_list) > 0
Esempio n. 4
0
    def test_export_to_dicts(self):
        table = rows.import_from_dicts(self.data)
        result = rows.export_to_dicts(table)
        full_data = [
            {"name": "Álvaro", "ids": "123", "number": 3, "other": None},
            {"name": "Test", "ids": "456", "number": None, "other": None},
            {"name": "Python", "ids": "123, 456", "number": None, "other": 3.14},
        ]

        self.assertEqual(len(result), len(table))
        for expected, actual in zip(full_data, result):
            self.assertDictEqual(expected, actual)
Esempio n. 5
0
    def test_export_to_dicts(self):
        table = rows.import_from_dicts(self.data)
        result = rows.export_to_dicts(table)
        full_data = [
                {'name': 'Álvaro',
                 'ids': '123',
                 'number': 3,
                 'other': None, },
                {'name': 'Test',
                 'ids': '456',
                 'number': None,
                 'other': None, },
                {'name': 'Python',
                 'ids': '123, 456',
                 'number': None,
                 'other': 3.14, },]

        self.assertEqual(len(result), len(table))
        for expected, actual in zip(full_data, result):
            self.assertDictEqual(expected, actual)
Esempio n. 6
0
 def parse(self, response):
     name = response.request.meta["name"]
     table = rows.import_from_csv(name, encoding='latin-1')
     yield from rows.export_to_dicts(table)