Exemple #1
0
 def create_product_usage(
     splice_server, facts, cdate, consumer="consumer01", instance="ident01", products=["69"], save=True
 ):
     pu = ProductUsage(
         consumer=consumer,
         splice_server=splice_server.uuid,
         instance_identifier=instance,
         allowed_product_info=products,
         facts=facts,
         date=cdate,
     )
     if save:
         pu.save(cascade=True)
     return pu
Exemple #2
0
 def create_product_usage(
     splice_server, facts, cdate, consumer='consumer01',
         instance='ident01', products=['69'], save=True):
     pu = ProductUsage(
         consumer=consumer,
         splice_server=splice_server.uuid,
         instance_identifier=instance,
         allowed_product_info=products,
         facts=facts,
         date=cdate
     )
     if save:
         pu.save(cascade=True)
         #pu.save()
     return pu
def main():
    SpliceServer.drop_collection()
    ProductUsage.drop_collection()
    ReportData.drop_collection()
    ss1 = TestData.create_splice_server("test01", "east")
    
    uuid_rhel_jboss = products_dict[RHEL][1]
    prod_rhel = products_dict[RHEL][0]
    prod_jboss = products_dict[JBoss][0]
    
    uuid_ha = products_dict[HA][1]
    prod_ha = products_dict[HA][0]
    
    uuid_edu = products_dict[EDU][1]
    prod_edu = products_dict[EDU][0]
    
    now = datetime.now()
    delta_day = timedelta(days=4)
    delta_hour = timedelta(days=3)
    
    
    for i in range(1, 10):
        this_time = now - (delta_hour * i)
        create_set_of_usage(
            prod_rhel, uuid_rhel_jboss, get_times(this_time), ss1, 7)
    
    for i in range(1, 10):
        this_time = now - (delta_hour * i)
        create_set_of_usage(
            prod_jboss, uuid_rhel_jboss, get_times(this_time), ss1, 4)
    
    for i in range(1, 4):
        this_time = now - (delta_hour * i)
        create_set_of_usage(prod_ha, uuid_ha, get_times(this_time), ss1, 7)
    
    for i in range(5, 10):
        this_time = now - (delta_hour * i)
        create_set_of_usage(
            prod_edu, uuid_edu, get_times(this_time), ss1, 5)
    # run import
    results = import_data(force_import=True)
    
    # verify 1 items in db
    lookup = ReportData.objects.all()
Exemple #4
0
 def drop_product_usage(self):
     ProductUsage.drop_collection()