Esempio n. 1
0
    def test_api_bill_post(self):
        self.login(self.get_default_test_username(), self.get_default_test_password())
        benchmark = 0.015

        y = 100

        t0 = time.time()
        for x in range(0, y):
            self.apiCreateNewBill(testUtils.random_name_generator(), testUtils.random_number_generator())
        t1 = time.time()
        total1 = t1-t0

        t0 = time.time()
        for x in range(0, y):
            self.apiCreateNewBill(testUtils.random_name_generator(), testUtils.random_number_generator())
        t1 = time.time()
        total2 = t1-t0

        t0 = time.time()
        for x in range(0, y):
            self.apiCreateNewBill(testUtils.random_name_generator(), testUtils.random_number_generator())
        t1 = time.time()
        total3 = t1-t0

        average = ((total1/y)+(total2/y)+(total3/y))/3

        print("Bill Average: " + str(average))
        print("Bill Percent Variance: "+ str(testUtils.percent_difference(benchmark,average))+"%")

        assert testUtils.percent_difference(benchmark,average) < 10

        self.logout()
Esempio n. 2
0
 def apiCreateNewBill(self, name=None, total_due=None):
     due_date = datetime.utcnow() + timedelta(days=testUtils.random_number_generator(45))
     if total_due is None:
         total_due = testUtils.random_number_generator()
     return self.app.post('api/bill/', data=json.dumps(
         {'name':name,
          'total_due': total_due,
          'due_date': due_date.strftime("%Y-%m-%d")}), content_type='application/json')
Esempio n. 3
0
    def test_api_me_post_success(self):
        self.login(self.get_default_test_username(), self.get_default_test_password())

        self.pr = cProfile.Profile()
        self.pr.enable()

        #CREATING y BILLS
        for x in range(0, 100):
            self.apiCreateNewBill(testUtils.random_name_generator(), testUtils.random_number_generator())

        p = Stats (self.pr)
        p.strip_dirs()
        p.sort_stats ('cumtime')
        p.print_stats ()

        self.logout()