Changeset - d4ce9177ea54
[Not reviewed]
0 1 0
Lance Edgar (lance) - 4 years ago 2020-06-16 17:10:42
lance@edbob.org
Use OrderedDict in some importer tests, for consistency

otherwise python2 can bite us sometimes
1 file changed with 6 insertions and 5 deletions:
0 comments (0 inline, 0 general)
rattail/tests/importing/test_importers.py
Show inline comments
 
# -*- coding: utf-8; -*-
 

	
 
from __future__ import unicode_literals, absolute_import
 

	
 
from unittest import TestCase
 

	
 
from mock import Mock, patch, call
 

	
 
from rattail.db import model
 
from rattail.db.util import QuerySequence
 
from rattail.importing import importers
 
from rattail.util import OrderedDict
 
from rattail.tests import NullProgress, RattailTestCase
 
from rattail.tests.importing import ImporterTester
 

	
 

	
 
class ImporterBattery(ImporterTester):
 
    """
 
    Battery of tests which can hopefully be ran for any non-bulk importer.
 
    """
 

	
 
    def test_import_data_empty(self):
 
        importer = self.make_importer()
 
        result = importer.import_data()
 
@@ -351,29 +352,29 @@ class MockImporter(importers.Importer):
 
    session = Mock()
 

	
 
    def normalize_local_object(self, obj):
 
        return obj
 

	
 
    def update_object(self, obj, host_data, local_data=None):
 
        return host_data
 

	
 

	
 
class TestMockImporter(ImporterTester, TestCase):
 
    importer_class = MockImporter
 

	
 
    sample_data = {
 
        '16oz': {'upc': '00074305001161', 'description': "Apple Cider Vinegar 16oz"},
 
        '32oz': {'upc': '00074305001321', 'description': "Apple Cider Vinegar 32oz"},
 
        '1gal': {'upc': '00074305011283', 'description': "Apple Cider Vinegar 1gal"},
 
    }
 
    sample_data = OrderedDict([
 
        ('16oz', {'upc': '00074305001161', 'description': "Apple Cider Vinegar 16oz"}),
 
        ('32oz', {'upc': '00074305001321', 'description': "Apple Cider Vinegar 32oz"}),
 
        ('1gal', {'upc': '00074305011283', 'description': "Apple Cider Vinegar 1gal"}),
 
    ])
 

	
 
    def setUp(self):
 
        self.importer = self.make_importer()
 
        self.importer.handler = Mock(local_title="Nevermind")
 

	
 
    def test_create(self):
 
        local = self.copy_data()
 
        del local['32oz']
 
        self.import_data(local_data=local)
 
        self.assert_import_created('32oz')
 
        self.assert_import_updated()
 
        self.assert_import_deleted()
0 comments (0 inline, 0 general)