예제 #1
0
    def _init_data_row(self, start, end, **kwargs):  # noqa: C901
        """Create a row of data with placeholder for all headers."""
        if not (start and end):
            raise ValueError("start and end must be date objects.")
        if not isinstance(start, datetime.datetime):
            raise ValueError("start must be a date object.")
        if not isinstance(end, datetime.datetime):
            raise ValueError("end must be a date object.")

        bill_begin = start.replace(microsecond=0,
                                   second=0,
                                   minute=0,
                                   hour=0,
                                   day=1)
        bill_end = AbstractGenerator.next_month(bill_begin)
        row = {}
        COL_MAP = {
            "identity/LineItemId": self.fake.sha1(raw_output=False),
            "identity/TimeInterval": AWSGenerator.time_interval(start, end),
            "bill/BillingEntity": "AWS",
            "bill/BillType": "Anniversary",
            "bill/PayerAccountId": kwargs.get("config",
                                              {}).get("payer_account"),
            "bill/BillingPeriodStartDate": AWSGenerator.timestamp(bill_begin),
            "bill/BillingPeriodEndDate": AWSGenerator.timestamp(bill_end),
        }
        for column in self.AWS_COLUMNS:
            row[column] = ""
            if COL_MAP.get(column):
                row[column] = COL_MAP.get(column)

        return row
예제 #2
0
    def _init_data_row(self, start, end, **kwargs):  # noqa: C901
        """Create a row of data with placeholder for all headers."""
        if not start or not end:
            raise ValueError('start and end must be date objects.')
        if not isinstance(start, datetime.datetime):
            raise ValueError('start must be a date object.')
        if not isinstance(end, datetime.datetime):
            raise ValueError('end must be a date object.')

        bill_begin = start.replace(microsecond=0,
                                   second=0,
                                   minute=0,
                                   hour=0,
                                   day=1)
        bill_end = AbstractGenerator.next_month(bill_begin)
        row = {}
        for column in AWS_COLUMNS:
            row[column] = ''
            if column == 'identity/LineItemId':
                # pylint: disable=no-member
                row[column] = self.fake.sha1(raw_output=False)
            elif column == 'identity/TimeInterval':
                row[column] = AWSGenerator.time_interval(start, end)
            elif column == 'bill/BillingEntity':
                row[column] = 'AWS'
            elif column == 'bill/BillType':
                row[column] = 'Anniversary'
            elif column == 'bill/PayerAccountId':
                row[column] = self.payer_account
            elif column == 'bill/BillingPeriodStartDate':
                row[column] = AWSGenerator.timestamp(bill_begin)
            elif column == 'bill/BillingPeriodEndDate':
                row[column] = AWSGenerator.timestamp(bill_end)
        return row
예제 #3
0
    def _init_data_row(self, start, end, **kwargs):  # noqa: C901
        """Create a row of data with placeholder for all headers."""
        if not start or not end:
            raise ValueError('start and end must be date objects.')
        if not isinstance(start, datetime.datetime):
            raise ValueError('start must be a date object.')
        if not isinstance(end, datetime.datetime):
            raise ValueError('end must be a date object.')

        bill_begin = start.replace(microsecond=0, second=0, minute=0, hour=0, day=1)
        bill_end = AbstractGenerator.next_month(bill_begin)
        row = {}
        report_type = kwargs.get(REPORT_TYPE)
        for column in OCP_REPORT_TYPE_TO_COLS[report_type]:
            row[column] = ''
            if column == 'report_period_start':
                row[column] = OCPGenerator.timestamp(bill_begin)
            elif column == 'report_period_end':
                row[column] = OCPGenerator.timestamp(bill_end)
        return row