Exemple #1
0
 def __init__(self, filename):
     self.log = LogParser()
     self.log.parse()
     self.noteNames = self.log.noteNames[:]
     self.noteNames.sort()
     self.notes = {}
     for name in self.noteNames:
         self.notes[name] = Note(name, Billing(), self.log)
     self.Update()
Exemple #2
0
def calc_phone_bill():
    terms_file = '../lab1/terms.csv'
    cdr_file = '../lab1/data.csv'
    phone_number = '915783624'
    obj_bill = Billing(terms_file, cdr_file, phone_number)
    bill = obj_bill.getBill()
    if obj_bill.getError() is not None:
        print(obj_bill.getError())
        sys.exit()
    return bill
Exemple #3
0
def main():
    if len(sys.argv) != 4:
        print('Wrong amount of arguments.')
        displayUsage()
        return -1
    terms_file, cdr_file, phone_number = sys.argv[1], sys.argv[2], sys.argv[3]
    obj_bill = Billing(terms_file, cdr_file, phone_number)
    data = obj_bill.getBill()
    if obj_bill.getError() != None:
        print(obj_bill.getError())
        return -1
    print('Bill: ' + str(data))
    return 0
Exemple #4
0
    def Update(self):
        self.log.parse()
        for name in set(self.log.noteNames).difference(set(self.noteNames)):
            self.notes[name] = Note(name, Billing(), self.log)

        for name in set(self.noteNames).difference(set(self.log.noteNames)):
            del self.notes[name]

        self.noteNames = self.log.noteNames[:]
        self.noteNames.sort()
        for noteName, note in self.notes.items():
            note.Update(self.log.notes[noteName])
            if debug:
                print self.log.notes[noteName]
Exemple #5
0
 def on_start(self):
     global modal_ctl
     modal_ctl = ModalCtl()
     netcheck.set_prompt(modal_ctl.ask_connect)
     b_key = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArYf73V3aCHtA1C7Kg3FO/ofDujXJj34YVlYMSvvQ2voKV6oKGXHKb+7F9MuYTbEIm1RK9q1K3qW7hXTZMZtE6BYpM6xpDejj7sd09LkFSsOI8DKls/xfwXSElZn7AgA0eI3dI73tqVfE8hXfXWhcHISeY41/XJcSJA74Vz9SdjDg6dedTYsMHfHBgsAxW3PkdOZBUTyYcTGrjb57GqUvtGE+ollJoaHB4Bg8VCyjA5n03qGAYXc/rdBPaMaLlIdrmmx95pa2PzSaHlZ5UHziHsd58RVf4hFKmxDN0KyAYXsceDPnRTy8d0jAIjLhhsAw0sEj7giM31ES0nbZHIsRCwIDAQAB'
     # these have to be provided ahead of time
     skus = [
         'test.mock.bs1',
         'test.mock.bs2',
         'test.mock.bs3',
         'android.test.purchased',
     ]
     global billing
     self.billing = billing = Billing(b_key, skus)
     billing.set_retry_prompt(modal_ctl.ask_retry_purchase)
def test_wrong_record_type():
    tariff = Tariff(
        monthly_fee=900,
        free_minutes=100,
        numbers_free_of_charge={'+420732563345', '+420707325673'},
        fee_for_minute_same_operator=Decimal(0),
        fee_for_minute_different_operator=Decimal(0),
        free_sms_count=0,
        fee_for_sms_same_operator=Decimal(0),
        fee_for_sms_different_operator=Decimal(0),
    )

    billing = Billing(tariff)
    with pytest.raises(WrongRecordType):
        billing.add_records_from_csv_file(
            'test_billing_csvs/test_wrong_record_type.csv')
def test_free_tariff():
    tariff = Tariff(
        monthly_fee=900,
        free_minutes=100,
        numbers_free_of_charge={'+420732563345', '+420707325673'},
        fee_for_minute_same_operator=Decimal(0),
        fee_for_minute_different_operator=Decimal(0),
        free_sms_count=0,
        fee_for_sms_same_operator=Decimal(0),
        fee_for_sms_different_operator=Decimal(0),
    )

    billing = Billing(tariff)
    billing.add_records_from_csv_file('test_billing_csvs/test_free_tariff.csv')
    print(billing)
    assert billing.charged_total == 0
    assert pytest.approx(billing.paid_minutes_same_operator, 39.32)
    assert billing.charged_for_minutes_same_operator == 0
    assert pytest.approx(billing.paid_minutes_different_operator, 79.78)
    assert billing.charged_for_minutes_different_operator == 0
    assert billing.paid_sms_count_same_operator == 13
    assert billing.paid_sms_count_different_operator == 15