def test_load_providers_to_update(self): """Test loading pending update events.""" test_matrix = [{'koku_uuid': faker.uuid4(), 'pending_update': False, 'pending_delete': False, 'expected_list_length': 0}, {'koku_uuid': faker.uuid4(), 'pending_update': True, 'pending_delete': False, 'expected_list_length': 1}, {'koku_uuid': None, 'pending_update': True, 'pending_delete': False, 'expected_list_length': 0}] test_source_id = 3 for test in test_matrix: aws_obj = Sources(source_id=test_source_id, auth_header=self.test_header, koku_uuid=test.get('koku_uuid'), pending_update=test.get('pending_update'), pending_delete=test.get('pending_delete'), offset=3, endpoint_id=4, source_type='AWS', name='Test AWS Source', billing_source={'bucket': 'test-bucket'}) aws_obj.save() response = storage.load_providers_to_update() self.assertEquals(len(response), test.get('expected_list_length')) test_source_id += 1 aws_obj.delete()
def test_load_providers_to_update(self): """Test loading pending update events.""" test_matrix = [ {"koku_uuid": faker.uuid4(), "pending_update": False, "pending_delete": False, "expected_list_length": 0}, {"koku_uuid": faker.uuid4(), "pending_update": True, "pending_delete": False, "expected_list_length": 1}, {"koku_uuid": None, "pending_update": True, "pending_delete": False, "expected_list_length": 0}, ] test_source_id = 3 for test in test_matrix: aws_obj = Sources( source_id=test_source_id, auth_header=self.test_header, koku_uuid=test.get("koku_uuid"), pending_update=test.get("pending_update"), pending_delete=test.get("pending_delete"), offset=3, source_type=Provider.PROVIDER_AWS, name="Test AWS Source", billing_source={"bucket": "test-bucket"}, ) aws_obj.save() response = storage.load_providers_to_update() self.assertEquals(len(response), test.get("expected_list_length")) test_source_id += 1 aws_obj.delete()
def _collect_pending_items(): """Gather all sources to create update, or delete.""" create_events = storage.load_providers_to_create() update_events = storage.load_providers_to_update() destroy_events = storage.load_providers_to_delete() pending_events = create_events + update_events + destroy_events return pending_events