Example #1
0
File: tests.py Project: 4i60r/ralph
 def test_get_services(self):
     service = utils.ServiceFactory()
     profit_center = utils.ProfitCenterFactory()
     utils.ServiceProfitCenterRelationFactory(
         parent=profit_center,
         child=service,
     )
     business_ownership = utils.ServiceOwnershipFactory.create_batch(
         2,
         ci=service,
         type=models_ci.CIOwnershipType.business,
     )
     technical_ownership = utils.ServiceOwnershipFactory.create_batch(
         3,
         ci=service,
         type=models_ci.CIOwnershipType.technical,
     )
     environments = utils.ServiceEnvironmentRelationFactory.create_batch(
         2,
         parent=service,
     )
     result = [a for a in api_scrooge.get_services()]
     service_dict = {
         'name': service.name,
         'ci_id': service.id,
         'ci_uid': service.uid,
         'symbol': None,
         'profit_center': profit_center.id,
         'business_owners': [bo.owner.id for bo in business_ownership],
         'technical_owners': [to.owner.id for to in technical_ownership],
         'environments': [e.child.id for e in environments],
     }
     self.assertEquals(result, [service_dict])
Example #2
0
 def test_get_services(self):
     service = utils.ServiceFactory()
     profit_center = utils.ProfitCenterFactory()
     utils.ServiceProfitCenterRelationFactory(
         parent=profit_center,
         child=service,
     )
     business_ownership = utils.ServiceOwnershipFactory.create_batch(
         2,
         ci=service,
         type=models_ci.CIOwnershipType.business,
     )
     technical_ownership = utils.ServiceOwnershipFactory.create_batch(
         3,
         ci=service,
         type=models_ci.CIOwnershipType.technical,
     )
     environments = utils.ServiceEnvironmentRelationFactory.create_batch(
         2,
         parent=service,
     )
     result = [a for a in api_scrooge.get_services()]
     service_dict = {
         'name': service.name,
         'ci_id': service.id,
         'ci_uid': service.uid,
         'symbol': None,
         'profit_center': profit_center.id,
         'business_owners': [bo.owner.id for bo in business_ownership],
         'technical_owners': [to.owner.id for to in technical_ownership],
         'environments': [e.child.id for e in environments],
     }
     self.assertEquals(result, [service_dict])
Example #3
0
 def test_get_services_without_profit_center(self):
     service = utils.ServiceFactory()
     result = [a for a in api_scrooge.get_services()]
     service_dict = {
         'name': service.name,
         'ci_id': service.id,
         'ci_uid': service.uid,
         'symbol': None,
         'profit_center': None,
         'technical_owners': [],
         'business_owners': [],
         'environments': [],
     }
     self.assertEquals(result, [service_dict])
Example #4
0
 def test_get_services_without_profit_center(self):
     service = utils.ServiceFactory()
     result = [a for a in api_scrooge.get_services()]
     service_dict = {
         "name": service.name,
         "ci_id": service.id,
         "ci_uid": service.uid,
         "symbol": None,
         "profit_center": None,
         "technical_owners": [],
         "business_owners": [],
         "environments": [],
     }
     self.assertEquals(result, [service_dict])
Example #5
0
File: tests.py Project: 4i60r/ralph
 def test_get_services_without_profit_center(self):
     service = utils.ServiceFactory()
     result = [a for a in api_scrooge.get_services()]
     service_dict = {
         'name': service.name,
         'ci_id': service.id,
         'ci_uid': service.uid,
         'symbol': None,
         'profit_center': None,
         'technical_owners': [],
         'business_owners': [],
         'environments': [],
     }
     self.assertEquals(result, [service_dict])
Example #6
0
def service(today, **kwargs):
    """
    Updates Services from CMDB
    """
    new_services = total = 0
    default_profit_center = ProfitCenter.objects.get(pk=1)
    for data in get_services():
        if update_service(data, today, default_profit_center):
            new_services += 1
        total += 1
    return True, '{} new service(s), {} updated, {} total'.format(
        new_services,
        total - new_services,
        total,
    )
Example #7
0
def service(today, **kwargs):
    """
    Updates Services from CMDB
    """
    new_services = total = 0
    default_profit_center = ProfitCenter.objects.get(pk=1)
    for data in get_services():
        if update_service(data, today, default_profit_center):
            new_services += 1
        total += 1
    return True, '{} new service(s), {} updated, {} total'.format(
        new_services,
        total - new_services,
        total,
    )
Example #8
0
 def test_get_services_calc_in_scrooge(self):
     service = utils.ServiceFactory()
     utils.ServiceFactory()  # service not calculated in scrooge
     calc_in_scrooge_attr = models_ci.CIAttribute.objects.get(pk=7)
     service.ciattributevalue_set.create(attribute=calc_in_scrooge_attr, value=True)
     result = [a for a in api_scrooge.get_services(True)]
     service_dict = {
         "name": service.name,
         "ci_id": service.id,
         "ci_uid": service.uid,
         "symbol": None,
         "profit_center": None,
         "technical_owners": [],
         "business_owners": [],
         "environments": [],
     }
     self.assertEquals(result, [service_dict])
Example #9
0
 def test_get_services_calc_in_scrooge(self):
     service = utils.ServiceFactory()
     utils.ServiceFactory()  # service not calculated in scrooge
     calc_in_scrooge_attr = models_ci.CIAttribute.objects.get(pk=7)
     service.ciattributevalue_set.create(attribute=calc_in_scrooge_attr,
                                         value=True)
     result = [a for a in api_scrooge.get_services(True)]
     service_dict = {
         'name': service.name,
         'ci_id': service.id,
         'ci_uid': service.uid,
         'symbol': None,
         'profit_center': None,
         'technical_owners': [],
         'business_owners': [],
         'environments': [],
     }
     self.assertEquals(result, [service_dict])