-
Notifications
You must be signed in to change notification settings - Fork 4
/
adlibre_dms_test_data.py
executable file
·65 lines (46 loc) · 1.47 KB
/
adlibre_dms_test_data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python
#
# Script which generates test data for Adlibre DMS scalability testing
#
# https://redmine.adlibre.net/issues/701
#
import os
import random
from random import shuffle
from name_generator import parse_data, generate_names
from name_generator.wc import WeightedChoice
from name_generator.settings import DATA_PATH
# Config
NUM_FEM=1
NUM_MALE=1
DOCS_MIN=1
DOCS_MAX=2
DOC_PREFIX='ADL-'
def main():
file_path = lambda x: os.path.join(DATA_PATH, x)
fem_data = parse_data(file_path('dist.female.first'))
male_data = parse_data(file_path('dist.male.first'))
last_data = parse_data(file_path('dist.all.last'))
# Create Objects
fem_wc = WeightedChoice(fem_data);
male_wc = WeightedChoice(male_data);
last_wc = WeightedChoice(last_data);
# Generate Female Names
output_fem = generate_names(fem_wc, last_wc, NUM_FEM, False)
# Generate Male Names
output_male = generate_names(male_wc, last_wc, NUM_MALE, False)
output = output_fem + output_male
# Generate a result containing: employee_id, employee name, document
employee_id = 0
doc_id = 0
result = []
for employee in output:
employee_id = employee_id + 1
for doc in range(0, random.randint(DOCS_MIN, DOCS_MAX)):
doc_id = doc_id + 1
result.append((employee_id, employee, '%s%s' % (DOC_PREFIX, doc_id)))
# Randomly shuffle the output
shuffle(result)
print result
if __name__ == '__main__':
main()