Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Profile tests #1079

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
1d8d4b7
Add two file arguments
orest77 Mar 2, 2020
ce0a988
Add method update page for profile
orest77 Mar 2, 2020
b3369bd
Add base keywords for profile
orest77 Mar 2, 2020
0a219d9
add methods for initial data
orest77 Mar 2, 2020
cd15840
add verification methods for profile
orest77 Mar 2, 2020
a04fccd
add prepare methods for profile
orest77 Mar 2, 2020
a5c1b06
add for profile
orest77 Mar 2, 2020
aeb3cdd
create methods
orest77 Mar 2, 2020
b886b93
create new methods for profile
orest77 Mar 2, 2020
7c57c7f
robot file for profile
orest77 Mar 2, 2020
40685a2
added space
orest77 Mar 3, 2020
bf86ed8
added what keyword return id
orest77 Mar 3, 2020
f26308b
remove commits
orest77 Mar 3, 2020
ee556cc
refactoring data id
orest77 Mar 3, 2020
ebc809e
refactoring remove one line
orest77 Mar 3, 2020
840e9fd
refactoring code and removed keywords
orest77 Mar 4, 2020
6ef3631
refactoring code
orest77 Mar 4, 2020
658cdb3
add user for negative tests
orest77 Mar 4, 2020
21e182c
change name keywords
orest77 Mar 7, 2020
995f0cf
refactored code
orest77 Mar 7, 2020
18a3f18
remove one line
orest77 Mar 7, 2020
d4529c9
change keywords
orest77 Mar 7, 2020
a36c244
add overload for data methods
orest77 Mar 11, 2020
ba1d3bc
remove one string
orest77 Mar 11, 2020
8a29a7c
change test for edit tax value
orest77 Mar 12, 2020
bb4e2c7
remove method for choose tax
orest77 Mar 12, 2020
bb0cb8a
change choice to sample in method choose_currency
orest77 Mar 16, 2020
d2660c5
Fix words and sentences
orest77 Mar 16, 2020
7e5773a
Fix users
orest77 Mar 16, 2020
46cb117
corrected the words in the tests
orest77 Mar 24, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 112 additions & 1 deletion op_robot_tests/tests_files/base_keywords.robot
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Resource resource.robot
${period_intervals}= compute_intrs ${BROKERS} ${used_brokers}
${accelerator}= Get Variable Value ${accelerator}
${accelerator}= Set Variable If '${accelerator}' != '${None}' ${accelerator} ${period_intervals.default.accelerator}
${monitoring_data}= tets_monitoring_data ${USERS.users['${dasu_user}'].tender_data.data.id} ${accelerator}
${monitoring_data}= test_monitoring_data ${USERS.users['${dasu_user}'].tender_data.data.id} ${accelerator}
Log ${monitoring_data}
${MNITORING_UAID}= Run As ${dasu_user} Створити об'єкт моніторингу ${monitoring_data}
${MONITORING}= Create Dictionary
Expand Down Expand Up @@ -1536,3 +1536,114 @@ Resource resource.robot
Неможливість змінити поле ${field_name} характеристики на значення ${field_value} для користувача ${username}
Require Failure ${username} Внести зміни в характеристику ${CRITERIA['CRITERIA_UAID']} ${field_name} ${field_value}


Можливість створити профіль
${profile_data}= test_profile_data ${CRITERIA['CRITERIA_UAID']} ${USERS.users['${e_admin}'].initial_data.dataType}
${profile_data}= munchify ${profile_data}
${profile_result}= Run As ${e_admin} Створити профіль ${profile_data}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

краще б було якби 'Створити профіль' повертало id, а не всю дані

${PROFILE}= Create Dictionary
Set Global Variable ${PROFILE}
Set To Dictionary ${USERS.users['${e_admin}']} initial_profile=${profile_data}
Log ${USERS.users['${e_admin}']}
Set To Dictionary ${PROFILE} PROFILE_UAID=${profile_result}
Log ${profile_result}


Звірити відображення поля ${field} профіля для усіх користувачів
:FOR ${username} IN ${viewer} ${e_admin}
\ Звірити відображення поля ${field} профіля для користувача ${username}


Звірити відображення поля ${field} профіля для користувача ${username}
Звірити поле профіля ${username} ${PROFILE['PROFILE_UAID']} ${USERS.users['${e_admin}'].initial_profile} ${field}


Можливість знайти профіль по ідентифікатору для усіх користувачів
:FOR ${username} IN ${e_admin} ${viewer}
\ Знайти профіль по ідентифікатору для користувача ${username}


Знайти профіль по ідентифікатору для користувача ${username}
Дочекатись синхронізації з майданчиком ${viewer} PROFILE
Run As ${username} Отримати профіль по ідентифікатору ${PROFILE['PROFILE_UAID']}


Можливість змінити поле ${field_name} профіля на ${field_value}
Run As ${e_admin} Внести зміни в профіль ${PROFILE['PROFILE_UAID']} ${field_name} ${field_value}
Set To Dictionary ${USERS.users['${e_admin}']} new_${field_name}=${field_value}


Можливість додати ${filed_name} до профіля ${value} по ключу ${key_id}
${profile_data}= Run As ${e_admin} Додати до профіля ${PROFILE['PROFILE_UAID']} ${filed_name} ${value} ${key_id}
Run Keyword If '${filed_name}' == 'criteria' Append To List ${USERS.users['${e_admin}'].initial_profile['criteria']} ${value}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не можу зрозуміти для чого ти два рази зберігаєш значення і в initial_data і в new_${filed_name}, одного разу мало б бути достатньо

Copy link
Contributor Author

@orest77 orest77 Mar 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

я записую в initial_profile , initial_data в мене використовується характеристикою,
я записую в кейводрі додати до профайла і для того щоб можна буро звірити додане, я ці дані записую в initial_profile

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не розумію логіку, чому тут треба двічі зберігати ці дані, щоб звірити поля достатньо використати new_${filed_name}

... ELSE IF '${filed_name}' == 'requirementGroups' Append To List ${USERS.users['${e_admin}'].initial_profile['criteria'][0]['requirementGroups']} ${value}
... ELSE IF '${filed_name}' == 'requirements' Append To List ${USERS.users['${e_admin}'].initial_profile['criteria'][0]['requirementGroups'][0]['requirements']} ${value}
Set To Dictionary ${USERS.users['${e_admin}']} new_${filed_name}=${value}


Звірити відображення поля ${field} критерія для користувача ${username} по ключу ${key_id}
Звірити поле характеристики в профілі ${username} ${PROFILE['PROFILE_UAID']} ${USERS.users['${e_admin}'].initial_profile} ${field} ${key_id}


Можливість змінити ${field_name} поле в характеристиці профіля на ${field_value} по ключу ${key_id}
Run As ${e_admin} Внести зміни у характеристику профіля ${PROFILE['PROFILE_UAID']} ${field_name} ${field_value} ${key_id}
Set To Dictionary ${USERS.users['${e_admin}']} new_${field_name}=${field_value}


Звірити відображення ${field} поля в характеристиці профіля із ${value} для користувача ${username} по ключу ${id_key}
Звірити поле характеристики в профілі із значенням ${username} ${PROFILE['PROFILE_UAID']} ${value} ${field} ${id_key}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут трошки не правильна побудова ключового слова, поправ так щоб назва була змістовна і змінні передавалися відповідно

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Звірити відображення поля (Якшо перемістити сюди, то появляється помилка про multy keywords) ${field} характеристики профіля із ${value} для користувача ${username} по ключу ${id_key}



Звірити відображення поля ${field} профіля із ${value} для користувача ${username}
Звірити поле профіля із значенням ${username} ${PROFILE['PROFILE_UAID']} ${value} ${field}


Можливість видалити з профіля по ключу ${key_id}
Run As ${e_admin} Видалити з профіля ${PROFILE['PROFILE_UAID']} ${key_id}


Неможливість знайти видаленні дані з характеристики по ключу ${key_id} для користувача ${username}
Require Failure ${username} Можливість отримати інформацію із профіля для характеристики по ключу ${PROFILE['PROFILE_UAID']} ${key_id}


Можливість видалити профіль
Run As ${e_admin} Видалити профіль ${PROFILE['PROFILE_UAID']}


Видалити дані з profile data
[Arguments] ${field} ${key_id}
${path} get_path_to_id_from_criteria ${USERS.users['${viewer}'].profile_data} ${key_id}
Remove From Dictionary ${USERS.users['${viewer}'].profile_data.${path['path']}[${path['index']}]} ${field}


Вибрати значення для вимоги
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

це також де використовуєш?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

для вимоги в requirements

[Arguments] ${requirement_data}
${value} choose_contain_key
... ${requirement_data}
... expectedValue
... minValue
... maxValue
[return] ${value}


Неможливість створити профіль для ${username}
${profile_data}= test_profile_data ${CRITERIA['CRITERIA_UAID']} ${USERS.users['${e_admin}'].initial_data.dataType}
${profile_data}= munchify ${profile_data}
Require Failure ${username} Створити профіль ${profile_data}


Неможливість видалити профіль для ${username}
Require Failure ${username} Видалити профіль ${PROFILE['PROFILE_UAID']}


Неможливість змінити ${field_name} поле характеристики профіля на ${field_value} по ключу ${key_id} для ${username}
Require Failure ${username} Внести зміни у характеристику профіля ${PROFILE['PROFILE_UAID']} ${field_name} ${field_value} ${key_id}


Неможливість змінити поле ${field_name} профіля на ${field_value} для ${username}
Require Failure ${username} Внести зміни в профіль ${PROFILE['PROFILE_UAID']} ${field_name} ${field_value}


Неможливість додати ${filed_name} до профіля ${value} по ключу ${key_id} для ${username}
Require Failure ${username} Додати до профіля ${PROFILE['PROFILE_UAID']} ${filed_name} ${value} ${key_id}
Set To Dictionary ${USERS.users['${e_admin}']} new_${filed_name}=${value}
130 changes: 130 additions & 0 deletions op_robot_tests/tests_files/brokers/openprocurement_client.robot
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,10 @@ Library openprocurement_client.utils
${dasu_api_wraper}= prepare_dasu_api_wrapper ${USERS.users['${username}'].dasu_api_key} ${DASU_RESOURCE} ${DASU_API_HOST_URL} ${DASU_API_VERSION} ${ds_config}
${agreement_wrapper}= prepare_agreement_api_wrapper ${USERS.users['${username}'].api_key} AGREEMENTS ${API_HOST_URL} ${API_VERSION} ${ds_config}
${criteria_wrapper}= prepare_criteria_api_wrapper ${API_HOST_URL} ${API_VERSION} ${auth_catalogues}
${profile_wrapper}= prepare_profile_api_wrapper ${API_HOST_URL} ${API_VERSION} ${auth_catalogues}
Set To Dictionary ${USERS.users['${username}']} client=${api_wrapper}
Set To Dictionary ${USERS.users['${username}']} criteria_client=${criteria_wrapper}
Set To Dictionary ${USERS.users['${username}']} profile_client=${profile_wrapper}
Set To Dictionary ${USERS.users['${username}']} agreement_client=${agreement_wrapper}
Set To Dictionary ${USERS.users['${username}']} dasu_client=${dasu_api_wraper}
Set To Dictionary ${USERS.users['${username}']} access_token=${EMPTY}
Expand Down Expand Up @@ -2189,3 +2191,131 @@ Library openprocurement_client.utils
[Arguments] ${username} ${criteria_uaid}
openprocurement_client.Пошук характеристики по ідентифікатору ${username} ${criteria_uaid}


Створити профіль
[Arguments] ${username} ${profile_data}
${profile}= Call Method ${USERS.users['${username}'].profile_client} create_profile ${profile_data}
Set To Dictionary ${USERS.users['${username}']} access=${profile.access}
[return] ${profile.data.id}


Отримати профіль по ідентифікатору
[Arguments] ${username} ${profile_id} ${save_key}=profile_data
${profile}= Call Method ${USERS.users['${username}'].profile_client} get_profile ${profile_id}
${profile}= munch_dict arg=${profile}
Set To Dictionary ${USERS.users['${username}']} ${save_key}=${profile}
Log ${USERS.users['${username}'].profile_data}
[return] ${profile}


Отримати інформацію із профіля
[Arguments] ${username} ${profile_uaid} ${field_name}
${profile_data}= openprocurement_client.Отримати профіль по ідентифікатору
... ${username}
... ${profile_uaid}
${profile_data}= munch_dict arg=${profile_data}
${status} ${field_value}= Run Keyword And Ignore Error
... Get From Object
... ${profile_data}
... ${field_name}
Run Keyword If '${status}' == 'PASS' Return From Keyword ${field_value}
Fail Field not found: ${field_name}


Отримати інформацію із профіля для характеристики
[Arguments] ${username} ${profile_uaid} ${field_name} ${id}
${profile_data}= openprocurement_client.Отримати профіль по ідентифікатору
... ${username}
... ${profile_uaid}
${path} get_path_to_id_from_criteria ${profile_data} ${id}
${profile_data} set variable ${profile_data.${path['path']}[${path['index']}]}
log ${profile_data}
${profile_data}= munch_dict arg=${profile_data}
${status} ${field_value}= Run Keyword And Ignore Error
... Get From Object
... ${profile_data}
... ${field_name}
Run Keyword If '${status}' == 'PASS' Return From Keyword ${field_value}
Fail Field not found: ${field_name}


Оновити сторінку з профілем
[Arguments] ${username} ${profile_uaid}
openprocurement_client.Отримати профіль по ідентифікатору ${username} ${profile_uaid}


Внести зміни в профіль
[Arguments] ${username} ${profile_id} ${fieldname} ${fieldvalue}
${profile}= openprocurement_client.Отримати профіль по ідентифікатору ${username} ${profile_id}
${profile} prepare_data_profile ${profile}
Set_To_Object ${profile} ${fieldname} ${fieldvalue}
${data}= Create Dictionary access=${USERS.users['${username}'].access} data=${profile}
${data} munch_dict ${data}
${profile_data}= Call Method ${USERS.users['${username}'].profile_client} patch_profile
... ${profile_id}
... ${data}


Внести зміни у характеристику профіля
[Arguments] ${username} ${profile_id} ${fieldname} ${fieldvalue} ${key_id}
${profile}= openprocurement_client.Отримати профіль по ідентифікатору ${username} ${profile_id}
${profile} prepare_data_profile ${profile}
${path} get_path_to_id_from_criteria ${profile} ${key_id}
Set_To_Object ${profile.${path['path']}[${path['index']}]} ${fieldname} ${fieldvalue}
${data}= Create Dictionary access=${USERS.users['${username}'].access} data=${profile}
${data} munch_dict ${data}
${profile_data}= Call Method ${USERS.users['${username}'].profile_client} patch_profile
... ${profile_id}
... ${data}


Додати до профіля
[Arguments] ${username} ${profile_id} ${fieldname} ${value} ${key_id}
${profile} openprocurement_client.Отримати профіль по ідентифікатору ${username} ${profile_id}
${profile} prepare_data_profile ${profile}
${path} get_path_to_id_from_criteria ${profile} ${key_id}
Run Keyword if '${fieldname}' == 'criteria' Append To List ${profile['criteria']} ${value}
... ELSE Append To List ${profile.${path['path']}[${path['index']}].${fieldname}} ${value}
${data}= Create Dictionary access=${USERS.users['${username}'].access} data=${profile}
${data} munch_dict ${data}
${profile_data}= Call Method ${USERS.users['${username}'].profile_client} patch_profile
... ${profile_id}
... ${data}


Видалити з профіля
[Arguments] ${username} ${profile_id} ${key_id}
${profile} openprocurement_client.Отримати профіль по ідентифікатору ${username} ${profile_id}
${profile} prepare_data_profile ${profile}
${path} get_path_to_id_from_criteria ${profile} ${key_id}
Remove From List ${profile.${path['path']}} ${path['index']}
${data}= Create Dictionary access=${USERS.users['${username}'].access} data=${profile}
${data} munch_dict ${data}
${profile_data}= Call Method ${USERS.users['${username}'].profile_client} patch_profile
... ${profile_id}
... ${data}


Можливість отримати інформацію із профіля для характеристики по ключу
[Arguments] ${username} ${profile_uaid} ${key_id}
${profile_data}= openprocurement_client.Отримати профіль по ідентифікатору
... ${username}
... ${profile_uaid}
${path} get_path_to_id_from_criteria
... ${profile_data}
... ${key_id}
${profile_data}= munch_dict arg=${profile_data}
${field_value}= Run Keyword
... Get From Object
... ${profile_data.${path['path']}[${path['index']}]}
... description
Return From Keyword ${field_value}


Видалити профіль
[Arguments] ${username} ${profile_id}
${data}= Create Dictionary access=${USERS.users['${username}'].access}
${data} munch_dict ${data}
log ${data}
${profile_data}= Call Method ${USERS.users['${username}'].profile_client} delete_profile ${profile_id} ${data}

Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
from openprocurement_client.resources.contracts import ContractingClient
from openprocurement_client.resources.contracts import ContractingClient
from openprocurement_client.resources.criteria import CriteriaServiceClient
from openprocurement_client.resources.profile import ProfileServiceClient
from restkit.errors import RequestFailed, BadStatusLine, ResourceError
from retrying import retry
from time import sleep
import os
import urllib


def retry_if_request_failed(exception):
status_code = getattr(exception, 'status_code', None)
print(status_code)
Expand All @@ -36,6 +38,17 @@ def request(self, *args, **kwargs):
return super(StableDsClient, self).request(*args, **kwargs)


class StableProfileClient(ProfileServiceClient):
@retry(stop_max_attempt_number=100, wait_random_min=500,
wait_random_max=4000, retry_on_exception=retry_if_request_failed)
def request(self, *args, **kwargs):
return super(ProfileServiceClient, self).request(*args, **kwargs)


def prepare_profile_api_wrapper(host_url, api_version, auth_profile):
return StableProfileClient(host_url, api_version, auth_profile)


class StableCriteriaClient(CriteriaServiceClient):
@retry(stop_max_attempt_number=100, wait_random_min=500,
wait_random_max=4000, retry_on_exception=retry_if_request_failed)
Expand Down Expand Up @@ -65,11 +78,12 @@ def prepare_criteria_api_wrapper(ds_host_url, api_version, auth_criteria):

def prepare_agreement_api_wrapper(key, resource, host_url, api_version, ds_config=None):
return StableAgreementClient(key, resource, host_url, api_version,
ds_config=ds_config)
ds_config=ds_config)


class ContractingStableClient(ContractingClient):
@retry(stop_max_attempt_number=100, wait_random_min=500, wait_random_max=4000, retry_on_exception=retry_if_request_failed)
@retry(stop_max_attempt_number=100, wait_random_min=500, wait_random_max=4000,
retry_on_exception=retry_if_request_failed)
def request(self, *args, **kwargs):
return super(ContractingStableClient, self).request(*args, **kwargs)

Expand Down Expand Up @@ -177,7 +191,8 @@ def download_file_from_url(url, path_to_save_file):


class StableClient_plan(PlansClient):
@retry(stop_max_attempt_number=100, wait_random_min=500, wait_random_max=4000, retry_on_exception=retry_if_request_failed)
@retry(stop_max_attempt_number=100, wait_random_min=500, wait_random_max=4000,
retry_on_exception=retry_if_request_failed)
def request(self, *args, **kwargs):
return super(StableClient_plan, self).request(*args, **kwargs)

Expand All @@ -195,4 +210,4 @@ def request(self, *args, **kwargs):

def prepare_dasu_api_wrapper(key, resource, host_url, api_version, ds_config=None):
return StableClient_dasu(key, resource, host_url, api_version,
ds_config=ds_config)
ds_config=ds_config)
1 change: 1 addition & 0 deletions op_robot_tests/tests_files/data/users.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ users:
monitorings: [test.quintagroup.com, test.quintagroup.com]
auctions: [test.quintagroup.com, bc698baa8b814908bc75405ed3d63548]
criteria: [test.quintagroup.com, test.quintagroup.com]
profile: [test.quintagroup.com, test.quintagroup.com]
api_key: ""
dasu_api_key: ""
broker: Quinta
Expand Down
Loading