Mercurial > wikked
annotate benchmarks/test_benchmark.py @ 449:ecc1c1e3e04c
web: Fix some other navigation menu issues.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 07 Jan 2018 11:07:23 -0800 |
parents | f7a741bc5770 |
children |
rev | line source |
---|---|
325 | 1 import re |
338
f7a741bc5770
Update benchmarks to Pyton 3.
Ludovic Chabant <ludovic@chabant.com>
parents:
325
diff
changeset
|
2 import urllib.parse |
325 | 3 import random |
4 import unittest | |
5 from funkload.FunkLoadTestCase import FunkLoadTestCase | |
6 | |
7 | |
8 class Benchmark(FunkLoadTestCase): | |
9 """This test uses a configuration file Benchmark.conf.""" | |
10 def setUp(self): | |
11 self.server_url = self.conf_get('main', 'url') | |
12 | |
13 def test_simple(self): | |
14 server_url = self.server_url | |
15 if not re.match('https?://', server_url): | |
16 raise Exception("The `server_url` setting doesn't have a scheme.") | |
17 | |
18 username = self.conf_get('test_benchmark', 'username', None) | |
19 password = self.conf_get('test_benchmark', 'password', None) | |
20 if username and password: | |
21 self.post(self.server_url + "/api/user/login", | |
22 params=[['username', username], | |
23 ['password', password]], | |
24 description="Login as %s" % username) | |
25 | |
26 nb_times = self.conf_getInt('test_benchmark', 'nb_times') | |
27 names = self.conf_get('test_benchmark', 'page_names').split(';') | |
28 for i in range(nb_times): | |
29 r = random.randint(0, len(names) - 1) | |
338
f7a741bc5770
Update benchmarks to Pyton 3.
Ludovic Chabant <ludovic@chabant.com>
parents:
325
diff
changeset
|
30 url = server_url + '/api/read/' + urllib.parse.quote(names[r]) |
325 | 31 self.get(url, description='Getting %s' % names[r]) |
32 | |
33 | |
34 if __name__ in ('main', '__main__'): | |
35 unittest.main() | |
36 |