Esempio n. 1
0
 def testImageRangeAndSiteSelectionIsInvalid(self):
     captures = OrderedDict([('1.JPG', {
         'site': 'a',
         'roll': '1'
     }), ('3.JPG', {
         'site': 'a',
         'roll': '2'
     }), ('4.JPG', {
         'site': 'b',
         'roll': '1'
     }), ('6.JPG', {
         'site': 'b',
         'roll': '1'
     })])
     action_list = {
         0: {
             'action_roll': '',
             'action_site': 'a',
             'datetime_current': '',
             'datetime_new': '',
             'action_from_image': '3.JPG',
             'action_to_image': '4.JPG',
             'action_to_take': 'delete',
             'action_to_take_reason': 'lala'
         }
     }
     with self.assertRaises(ImportError):
         generate_actions(action_list, captures)
Esempio n. 2
0
 def testMultipleTimechanges(self):
     """ RaiseError for Multiple Timechanges """
     captures = {'1.JPG': {'site': 'a'}, '2.JPG': {'site': 'a'}}
     action = {k: v for k, v in self.dummy_action.items()}
     action['action_to_take'] = 'timechange'
     action['datetime_current'] = '2000-01-01 00:00:00'
     action['datetime_new'] = '2000-01-01 00:01:00'
     action_list = {0: action, 1: action}
     with self.assertRaises(ValueError):
         generate_actions(action_list, captures)
Esempio n. 3
0
 def testMultipleActions(self):
     """ Multiple Actions Possible """
     captures = {'1.JPG': {'site': 'a'}, '2.JPG': {'site': 'a'}}
     action_list = {0: self.dummy_action, 1: self.dummy_action}
     actions = generate_actions(action_list, captures)
     self.assertEqual(len(actions), 2)
     self.assertEqual([x for x in actions[0]], [x for x in actions[1]])
Esempio n. 4
0
 def testImageRangeSelection(self):
     captures = OrderedDict([('1.JPG', {
         'site': 'a',
         'roll': '1'
     }), ('3.JPG', {
         'site': 'a',
         'roll': '2'
     }), ('5.JPG', {
         'site': 'a',
         'roll': '1'
     }), ('4.JPG', {
         'site': 'b',
         'roll': '1'
     }), ('6.JPG', {
         'site': 'b',
         'roll': '1'
     })])
     action_list = {
         0: {
             'action_roll': '',
             'action_site': '',
             'datetime_current': '',
             'datetime_new': '',
             'action_from_image': '3.JPG',
             'action_to_image': '4.JPG',
             'action_to_take': 'delete',
             'action_to_take_reason': 'lala'
         }
     }
     actions = generate_actions(action_list, captures)
     expected_in = ['3.JPG', '5.JPG', '4.JPG']
     actual = [a.image for a in actions]
     self.assertEqual(set(actual), set(expected_in))
Esempio n. 5
0
 def testSiteSelection(self):
     captures = {
         '1.JPG': {
             'site': 'a',
             'roll': '1'
         },
         '2.JPG': {
             'site': 'a',
             'roll': '2'
         },
         '3.JPG': {
             'site': 'a',
             'roll': '1'
         },
         '4.JPG': {
             'site': 'b',
             'roll': '1'
         }
     }
     action_list = {
         0: {
             'action_roll': '',
             'action_site': 'a',
             'datetime_current': '',
             'datetime_new': '',
             'action_from_image': '',
             'action_to_image': '',
             'action_to_take': 'delete',
             'action_to_take_reason': 'lala'
         }
     }
     actions = generate_actions(action_list, captures)
     expected_in = ['1.JPG', '2.JPG', '3.JPG']
     actual = [a.image for a in actions]
     self.assertEqual(set(actual), set(expected_in))
Esempio n. 6
0
 def testTimechangeNegative(self):
     captures = {'1.JPG': {'site': 'a'}}
     action = {k: v for k, v in self.dummy_action.items()}
     action['action_to_take'] = 'timechange'
     action['datetime_current'] = '2000-01-01 00:01:00'
     action['datetime_new'] = '2000-01-01 00:00:00'
     action_list = {0: action}
     actions = generate_actions(action_list, captures)
     self.assertEqual(actions[0].shift_time_by_seconds, int(-60))
Esempio n. 7
0
 def testTimechangePositive(self):
     captures = {'1.JPG': {'site': 'a'}}
     action = {k: v for k, v in self.dummy_action.items()}
     action['action_to_take'] = 'timechange'
     action['datetime_current'] = '2017-10-26 10:38:31'
     action['datetime_new'] = '2017-10-27 10:38:31'
     action_list = {0: action}
     actions = generate_actions(action_list, captures)
     self.assertEqual(actions[0].shift_time_by_seconds, int(86400))
Esempio n. 8
0
    def testInvalidAction(self):
        """ Invalid Action """
        captures = {'1.JPG': {'site': 'a'}}
        action_list = {
            0: {
                'action_roll': '1',
                'action_site': 'a',
                'datetime_current': '',
                'datetime_new': '',
                'action_from_image': '',
                'action_to_image': '',
                'action_to_take': 'dummy',
                'action_to_take_reason': 'lala'
            }
        }

        with self.assertRaises(ImportError):
            generate_actions(action_list, captures)
Esempio n. 9
0
    def testSimpleAction(self):
        """ Test Normal Action """
        captures = {'1.JPG': {'site': 'a'}}
        action_list = {
            0: {
                'action_roll': '',
                'action_site': 'a',
                'datetime_current': '',
                'datetime_new': '',
                'action_from_image': '',
                'action_to_image': '',
                'action_to_take': 'mark_no_upload',
                'action_to_take_reason': 'lala'
            }
        }

        actions = generate_actions(action_list, captures)
        self.assertEqual(actions[0].action, 'mark_no_upload')
    def setUp(self):
        # test files
        file_inventory = './test/files/test_inventory.csv'
        file = './test/files/test_action_list.csv'
        self.inventory = read_image_inventory(file_inventory)
        time_deltas = calculate_time_deltas(self.inventory, flags)
        update_inventory_with_capture_data(self.inventory, time_deltas)
        image_to_capture = group_images_into_captures(self.inventory, flags)
        update_inventory_with_capture_data(self.inventory, image_to_capture)
        update_inventory_with_capture_id(self.inventory)
        update_inventory_with_image_names(self.inventory)
        self.action_list = read_image_inventory(file, unique_id=None)
        self.captures = OrderedDict()
        for v in self.inventory.values():
            self.captures[v['image_name']] = v
        self.actions = generate_actions(self.action_list, self.captures)

        @patch('pre_processing.actions.os.remove')
        def mock_apply_action(image_data, action_dict, flags, mock_remove):
            apply_action(image_data, action_dict, flags)

        for action_obj in self.actions:
            mock_apply_action(self.captures[action_obj.image], action_obj,
                              flags)

        self.captures_updated = select_valid_images(self.captures)

        # re-calculate time_deltas
        time_deltas = calculate_time_deltas(self.captures_updated, flags)
        update_inventory_with_capture_data(self.captures_updated, time_deltas)

        # update image to capture association
        image_to_capture = group_images_into_captures(self.captures_updated,
                                                      flags)
        update_inventory_with_capture_data(self.captures_updated,
                                           image_to_capture)

        update_inventory_with_capture_id(self.captures_updated)

        update_time_checks_inventory(self.captures_updated, flags)