Exemple #1
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 #2
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
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')
Exemple #4
0
    def setUp(self):
        self.driver = webdriver.Chrome('/Users/User1/Downloads/chromedriver')
        self.driver.get('http://store.23andme.com/en-us/')
        time.sleep(5)

        formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')

        # debug log
        self.debugLogger = logging.getLogger('debuglogger')
        debug_handler = logging.FileHandler('debug.log')
        debug_handler.setFormatter(formatter)
        self.debugLogger.addHandler(debug_handler)

        # info log
        self.infoLogger = logging.getLogger('infologger')
        info_handler = logging.FileHandler('info.log')
        info_handler.setFormatter(formatter)
        self.infoLogger.addHandler(info_handler)

        # error log
        self.errLogger = logging.getLogger('errlogger')
        err_handler = logging.FileHandler('err.log')
        err_handler.setFormatter(formatter)
        self.errLogger.addHandler(err_handler)

        self.cartInst = Cart(self.driver)
        self.billInst = Billing(self.driver)
        self.shipInst = Shipping(self.driver)
        self.verifyAddyInst = VerifyAddy(self.driver)
        self.driver.save_screenshot('setup.png')
Exemple #5
0
class Test:
    def __init__(self):
        self.controller = Controller("root", 'root', "cmpe2811")
        self.bill = Billing("root", 'root', "cmpe2811")


    def host(self):
#        host = Host('user@host_ip', '/path/.ssh/id_rsa', '/Applications/Genymotion.app/Contents/MacOS/player')
        host = self.controller.get_host("lan@localhost")

        print host.get_instances()
        print host.get_instance_status('LG Optimus L3 II - 4.1.1 - API 16 - 240x320')
        print host.get_running_instances()

    def controller_add_instances(self):
        host = self.controller.get_host("[email protected]")
        self.controller.add_instances(host)

    def controller_get_instance_category(self):
        print self.controller.get_instance_category()

    def controller_order(self, vm_name):
        print self.controller.get_idle_instances(vm_name)
        vm = self.controller.get_idle_instances(vm_name)[0]
        self.controller.order_instance(vm, 1, 0, 0.11)

    def controller_poweroff(self, vm_id):
        self.controller.poweroff_instance(vm_id)
        print self.controller.get_instance_status(vm_id)

    def controller_launch(self, vm_id):
        self.controller.launch_instance(vm_id)

    def controller_terminate(self, vm_id):
        self.controller.terminate_instance(vm_id)
        print self.controller.get_instance_status(vm_id)

    def controller_get_instances_by_user(self, user_id):
        print self.controller.get_instance_by_user(user_id)

    def calc_bill(self, user_id):
        print self.bill.calc_bill_by_user(user_id)

    def generate_reports(self):
        self.bill.generate_reports()

    def get_bill_history(self, user_id):
        print self.bill.get_bill_history(user_id)

    def get_instance_by_id(self, vm_id):
        print self.controller.get_instance_by_id(vm_id)

    def pay_bill(self, bill_id):
        self.bill.pay_bill(bill_id)

    def get_log(self, user_id):
        print self.controller.get_log_by_user(user_id)
Exemple #6
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()
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
Exemple #8
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 #9
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)
Exemple #10
0
 def __init__(self):
     self.controller = Controller("root", 'root', "cmpe2811")
     self.bill = Billing("root", 'root', "cmpe2811")
 def __init__(self, session):
     Billing.__init__(self, session)
Exemple #12
0
class Test23andMeWebsite(unittest.TestCase):
    @classmethod
    def setUp(self):
        self.driver = webdriver.Chrome('/Users/User1/Downloads/chromedriver')
        self.driver.get('http://store.23andme.com/en-us/')
        time.sleep(5)

        formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')

        # debug log
        self.debugLogger = logging.getLogger('debuglogger')
        debug_handler = logging.FileHandler('debug.log')
        debug_handler.setFormatter(formatter)
        self.debugLogger.addHandler(debug_handler)

        # info log
        self.infoLogger = logging.getLogger('infologger')
        info_handler = logging.FileHandler('info.log')
        info_handler.setFormatter(formatter)
        self.infoLogger.addHandler(info_handler)

        # error log
        self.errLogger = logging.getLogger('errlogger')
        err_handler = logging.FileHandler('err.log')
        err_handler.setFormatter(formatter)
        self.errLogger.addHandler(err_handler)

        self.cartInst = Cart(self.driver)
        self.billInst = Billing(self.driver)
        self.shipInst = Shipping(self.driver)
        self.verifyAddyInst = VerifyAddy(self.driver)
        self.driver.save_screenshot('setup.png')

    """ Check if the cart is empty or not """
    def testWebsiteFunc(self):
        print('testwebsitefunc')
        try:
            WebDriverWait(self.driver, 10).until(ec.visibility_of_element_located((By.LINK_TEXT, 'Add a kit.')))
            addkitlink = self.driver.find_element_by_link_text('Add a kit.')
            if addkitlink:
                print('CART EMPTY')
                addkitlink.click()
                self.cartInst.additemstocart(5)
                self.cartInst.sendkitnames()
                self.cartInst.verifysubtotal()
                self.cartInst.verifysavings()
                self.cartInst.verifygrandtotal()
                self.cartInst.verifycontbtn()
                self.shipInst.fillOutForm()
                assert 'verifyaddress' in self.driver.current_url
                self.verifyAddyInst.verifyContent()
                assert 'payment' in self.driver.current_url
                self.billInst.verifyContent()
            else:
                print('CART NOT EMPTY')
                self.cartInst.sendkitnames()
                self.cartInst.verifysubtotal()
                self.cartInst.verifysavings()
                self.cartInst.verifygrandtotal()
                self.cartInst.verifycontbtn()
                self.shipInst.fillOutForm()
                assert 'verifyaddress' in self.driver.current_url
                self.verifyAddyInst.verifyContent()
                assert 'payment' in self.driver.current_url
                self.billInst.verifyContent()
        except TimeoutException as te:
            self.errLogger.error(te.message)
            self.errLogger.error(te.stacktrace)
        except ElementNotVisibleException as enve:
            self.errLogger.error(enve.message)
            self.errLogger.error(enve.stacktrace)
        finally:
            self.debugLogger.debug(self.driver.session_id)
            self.driver.save_screenshot('testwebsitefunc.png')

    @classmethod
    def tearDown(self):
        self.driver.save_screenshot('teardown.png')
        self.driver.quit()