Commit 6b5a14d9132d8e96191aca5599b31e19011d7e97

Authored by selurvedu
1 parent e2270c41

Update broker and user data preparation

... ... @@ -54,36 +54,75 @@ Set Suite Variable With Default Value
54 54 Завантажуємо дані про користувачів і майданчики
55 55 Log ${broker}
56 56 Log ${role}
  57 + Log Many @{used_roles}
57 58
  59 + # Load brokers data
58 60 ${file_path}= Get Variable Value ${BROKERS_FILE} brokers.yaml
59 61 ${BROKERS}= load_initial_data_from ${file_path}
60 62 Log ${BROKERS}
61 63 Set Suite Variable ${BROKERS}
  64 + # List of currently used brokers
  65 + ${used_brokers}= Create List
62 66
  67 + # Load users data
63 68 ${file_path}= Get Variable Value ${USERS_FILE} users.yaml
64 69 ${USERS}= load_initial_data_from ${file_path}
65   - Set Global Variable ${USERS}
66   -
67   - Set Suite Variable With Default Value ${role} ${BROKERS['${broker}'].roles.${role}}
68   - Set Suite Variable With Default Value tender_owner Tender_Owner
69   - Set Suite Variable With Default Value provider Tender_User
70   - Set Suite Variable With Default Value provider1 Tender_User1
71   - Set Suite Variable With Default Value viewer Tender_Viewer
72   - ${active_users}= Create Dictionary tender_owner=${tender_owner} provider=${provider} provider1=${provider1} viewer=${viewer}
73   -
74   - ${users_list}= Get Dictionary Items ${USERS.users}
75   - :FOR ${username} ${user_data} IN @{users_list}
76   - \ Log ${active_users}
77   - \ Log ${username}
  70 + Log ${USERS.users}
  71 + Set Suite Variable ${USERS}
  72 + # List of currently used users
  73 + ${used_users}= Create List
  74 +
  75 + # Handle `-v role:something`
  76 + Run Keyword Unless '${role}' in @{used_roles}
  77 + ... Log
  78 + ... Role ${role} is not used in this test suite.
  79 + ... WARN
  80 + Set Suite Variable With Default Value
  81 + ... ${role}
  82 + ... ${BROKERS['${broker}'].roles.${role}}
  83 +
  84 + # Set default value for each role if it is not set yet;
  85 + # fill `used_users`;
  86 + # fill `used_brokers`.
  87 + #
  88 + # Don't even ask how this works!
  89 + :FOR ${tmp_role} IN @{used_roles}
  90 + \ Set Suite Variable With Default Value
  91 + \ ... ${tmp_role}
  92 + \ ... ${BROKERS['Quinta'].roles.${tmp_role}}
  93 + \ Append To List ${used_users} ${${tmp_role}}
  94 + \ Append To List ${used_brokers} ${USERS.users.${${tmp_role}}.broker}
  95 + ${used_brokers}= Remove Duplicates ${used_brokers}
  96 + # We need to create two lists since Robot Framework doesn't support
  97 + # dicts in `:FOR` loops.
  98 + Log Many @{used_users}
  99 + Log Many @{used_brokers}
  100 +
  101 + # A list of all users in users file
  102 + ${known_users}= Get Dictionary Keys ${USERS.users}
  103 +
  104 + # Check whether users file contains an entry for each
  105 + # selected user before preparing any clients
  106 + :FOR ${username} IN @{used_users}
  107 + \ List Should Contain Value
  108 + \ ... ${known_users}
  109 + \ ... ${username}
  110 + \ ... msg=User ${username} not found in users file!
  111 +
  112 + # Prepare a client for each user
  113 + :FOR ${username} IN @{used_users}
78 114 \ ${munch_dict}= munch_dict data=${True}
79   - \ Log Many ${munch_dict}
80   - \ ${status}= Run Keyword And Return Status Dictionary Should Contain Value ${active_users} ${username}
81   - \ ${keywords_file}= Get Broker Property By Username ${username} keywords_file
82   - \ Run Keyword If ${status} Завантажуємо бібліотеку з реалізацією для майданчика ${keywords_file}
83   - \ Run Keyword If ${status} Викликати для учасника ${username} Підготувати клієнт для користувача
84   - \ Run Keyword If ${status} Set To Dictionary ${USERS.users['${username}']} tender_data=${munch_dict}
  115 + \ ${keywords_file}= Get Broker Property ${USERS.users.${username}.broker} keywords_file
  116 + \ Завантажуємо бібліотеку з реалізацією для майданчика ${keywords_file}
  117 + \ Run As ${username} Підготувати клієнт для користувача
85 118 \ ${LAST_REFRESH_DATE}= Get Current TZdate
86   - \ Set To Dictionary ${USERS.users['${username}']} LAST_REFRESH_DATE ${LAST_REFRESH_DATE}
  119 + \ Set To Dictionary ${USERS} ${username}=${USERS.users.${username}}
  120 + \ Set To Dictionary ${USERS.${username}} tender_data=${munch_dict}
  121 + \ Set To Dictionary ${USERS.${username}} LAST_REFRESH_DATE ${LAST_REFRESH_DATE}
  122 +
  123 + # Drop all unused users
  124 + Keep In Dictionary ${USERS.users} @{used_users}
  125 + Log Many @{USERS}
87 126
88 127
89 128 Get Broker Property
... ...
Please register or login to post a comment