Beispiel #1
0
 def test_build_draft_registry_1(self):
     info = {
         'myapp': [
             {
                 'app_label': 'myapp',
                 'fields': ['img1', 'img2', 'img3'],
                 'specificity': 1,
                 'mapping': {
                     'SIZE': '100',
                     'DIMENSIONS': '100x100',
                 }
             },
             {
                 'app_label': 'myapp',
                 'fields': ['img1', 'img3'],
                 'specificity': 2,
                 'mapping': {
                     'FORMAT': 'png',
                 }
             },
             {
                 'app_label': 'myapp',
                 'fields': ['img3'],
                 'specificity': 3,
                 'mapping': {
                     'SIZE': '500',
                     'DIMENSIONS': '500x640',
                     'FORMAT': 'jpeg',
                 }
             },
         ],
     }
     expected_draft_registry = {
         'img1': {
             'SIZE': '100',
             'DIMENSIONS': '100x100',
             'FORMAT': 'png'
         },
         'img2': {
             'SIZE': '100',
             'DIMENSIONS': '100x100'
         },
         'img3': {
             'SIZE': '500',
             'DIMENSIONS': '500x640',
             'FORMAT': 'jpeg'
         },
     }
     draft_registry = VimageConfig.build_draft_registry(info)
     self.assertDictEqual(draft_registry, expected_draft_registry)
Beispiel #2
0
 def test_build_draft_registry_4(self):
     info = {
         'myapp1': [
             {
                 'app_label': 'myapp',
                 'fields': ['img1', 'img2', 'img3'],
                 'specificity': 1,
                 'mapping': {
                     'SIZE': '100',
                     'DIMENSIONS': '100x100',
                 }
             },
         ],
         'myapp2': [
             {
                 'app_label': 'myapp',
                 'fields': ['img4', 'img5', 'img6'],
                 'specificity': 1,
                 'mapping': {
                     'DIMENSIONS': '666x666',  # :)
                 }
             },
         ],
     }
     expected_draft_registry = {
         'img1': {
             'SIZE': '100',
             'DIMENSIONS': '100x100'
         },
         'img2': {
             'SIZE': '100',
             'DIMENSIONS': '100x100'
         },
         'img3': {
             'SIZE': '100',
             'DIMENSIONS': '100x100'
         },
         'img4': {
             'DIMENSIONS': '666x666'
         },
         'img5': {
             'DIMENSIONS': '666x666'
         },
         'img6': {
             'DIMENSIONS': '666x666'
         },
     }
     draft_registry = VimageConfig.build_draft_registry(info)
     self.assertDictEqual(draft_registry, expected_draft_registry)