Changeset - 3d85857ea1a1
[Not reviewed]
0 1 0
Lance Edgar (lance) - 4 years ago 2020-07-19 20:11:14
lance@edbob.org
Fix a test per recent importer change
1 file changed with 6 insertions and 1 deletions:
0 comments (0 inline, 0 general)
rattail/tests/importing/test_importers.py
Show inline comments
 
@@ -169,49 +169,54 @@ class TestImporter(TestCase):
 
            {'upc': '00074305001321', 'description': "Apple Cider Vinegar 32oz"},
 
        ]
 

	
 
        host_data = importer.normalize_host_data(host_objects=[])
 
        self.assertEqual(host_data, [])
 

	
 
        host_data = importer.normalize_host_data(host_objects=data)
 
        self.assertEqual(host_data, data)
 

	
 
        with patch.object(importer, 'get_host_objects', new=Mock(return_value=data)):
 
            host_data = importer.normalize_host_data()
 
        self.assertEqual(host_data, data)
 

	
 
    def test_get_deletion_keys(self):
 
        importer = importers.Importer()
 
        self.assertFalse(importer.caches_local_data)
 
        keys = importer.get_deletion_keys()
 
        self.assertEqual(keys, set())
 

	
 
        importer.caches_local_data = True
 
        self.assertIsNone(importer.cached_local_data)
 
        keys = importer.get_deletion_keys()
 
        self.assertEqual(keys, set())
 

	
 
        importer.cached_local_data = {'delete-me': object()}
 
        importer.cached_local_data = {
 
            'delete-me': {
 
                'object': object(),
 
                'data': {},
 
            },
 
        }
 
        keys = importer.get_deletion_keys()
 
        self.assertEqual(keys, set(['delete-me']))
 

	
 
    def test_model_name_attr(self):
 
        # default is None
 
        importer = importers.Importer()
 
        self.assertIsNone(importer.model_name)
 

	
 
        # but may be overridden via init kwarg
 
        importer = importers.Importer(model_name='Foo')
 
        self.assertEqual(importer.model_name, 'Foo')
 

	
 
        # or may inherit its value from 'model_class'
 
        class Foo:
 
            pass
 
        importer = importers.Importer(model_class=Foo)
 
        self.assertEqual(importer.model_name, 'Foo')
 

	
 
    def test_batch_size_attr(self):
 
        # default is 200
 
        importer = importers.Importer()
 
        self.assertEqual(importer.batch_size, 200)
 

	
 
        # but may be overridden via init kwarg
0 comments (0 inline, 0 general)