From 93c93226f2aad8f636043336f039da55afc76c34 Mon Sep 17 00:00:00 2001 From: Vitaliy Gulevatiy Date: Sun, 25 Jan 2026 19:18:08 +0300 Subject: [PATCH 1/4] =?UTF-8?q?=D0=97=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5?= =?UTF-8?q?=202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 2_task/.idea/.gitignore | 5 + 2_task/.idea/2_task.iml | 8 ++ .../inspectionProfiles/profiles_settings.xml | 6 ++ 2_task/.idea/misc.xml | 7 ++ 2_task/.idea/modules.xml | 8 ++ 2_task/data/__init__.py | 0 .../data/__pycache__/__init__.cpython-314.pyc | Bin 0 -> 156 bytes .../__pycache__/user_data.cpython-314.pyc | Bin 0 -> 483 bytes 2_task/data/user_data.py | 9 ++ 2_task/requirements.txt | 3 + .../test_orders.cpython-314-pytest-9.0.2.pyc | Bin 0 -> 9137 bytes ...t_user_create.cpython-314-pytest-9.0.2.pyc | Bin 0 -> 5451 bytes ...st_user_login.cpython-314-pytest-9.0.2.pyc | Bin 0 -> 4676 bytes 2_task/tests/test_orders.py | 93 ++++++++++++++++++ 2_task/tests/test_user_create.py | 36 +++++++ 2_task/tests/test_user_login.py | 27 +++++ 2_task/utils/__init__.py | 0 .../__pycache__/__init__.cpython-314.pyc | Bin 0 -> 157 bytes .../utils/__pycache__/helpers.cpython-314.pyc | Bin 0 -> 2172 bytes 2_task/utils/helpers.py | 40 ++++++++ 20 files changed, 242 insertions(+) create mode 100644 2_task/.idea/.gitignore create mode 100644 2_task/.idea/2_task.iml create mode 100644 2_task/.idea/inspectionProfiles/profiles_settings.xml create mode 100644 2_task/.idea/misc.xml create mode 100644 2_task/.idea/modules.xml create mode 100644 2_task/data/__init__.py create mode 100644 2_task/data/__pycache__/__init__.cpython-314.pyc create mode 100644 2_task/data/__pycache__/user_data.cpython-314.pyc create mode 100644 2_task/data/user_data.py create mode 100644 2_task/requirements.txt create mode 100644 2_task/tests/__pycache__/test_orders.cpython-314-pytest-9.0.2.pyc create mode 100644 2_task/tests/__pycache__/test_user_create.cpython-314-pytest-9.0.2.pyc create mode 100644 2_task/tests/__pycache__/test_user_login.cpython-314-pytest-9.0.2.pyc create mode 100644 2_task/tests/test_orders.py create mode 100644 2_task/tests/test_user_create.py create mode 100644 2_task/tests/test_user_login.py create mode 100644 2_task/utils/__init__.py create mode 100644 2_task/utils/__pycache__/__init__.cpython-314.pyc create mode 100644 2_task/utils/__pycache__/helpers.cpython-314.pyc create mode 100644 2_task/utils/helpers.py diff --git a/2_task/.idea/.gitignore b/2_task/.idea/.gitignore new file mode 100644 index 000000000..b58b603fe --- /dev/null +++ b/2_task/.idea/.gitignore @@ -0,0 +1,5 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/2_task/.idea/2_task.iml b/2_task/.idea/2_task.iml new file mode 100644 index 000000000..c03f621ae --- /dev/null +++ b/2_task/.idea/2_task.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/2_task/.idea/inspectionProfiles/profiles_settings.xml b/2_task/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 000000000..105ce2da2 --- /dev/null +++ b/2_task/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/2_task/.idea/misc.xml b/2_task/.idea/misc.xml new file mode 100644 index 000000000..590a59e60 --- /dev/null +++ b/2_task/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/2_task/.idea/modules.xml b/2_task/.idea/modules.xml new file mode 100644 index 000000000..9d4118fd4 --- /dev/null +++ b/2_task/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/2_task/data/__init__.py b/2_task/data/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/2_task/data/__pycache__/__init__.cpython-314.pyc b/2_task/data/__pycache__/__init__.cpython-314.pyc new file mode 100644 index 0000000000000000000000000000000000000000..93ecb48a136f8ce075b58ef27b75ef211520a2b7 GIT binary patch literal 156 zcmdPq>P{wCAAftgHh(Vb_lhJP_LlF~@{~08C%hK5@CbT%U zs5mAmKR-J$rZO=vCAA`;C^5MtCMB~VCqFmFD83}II6EdKu_Q4jK0Y%qvm`!Vub}c4 fhfQvNN@-52T@fqLB#>RjAjT(VMn=XWW*`dyXWS*d literal 0 HcmV?d00001 diff --git a/2_task/data/__pycache__/user_data.cpython-314.pyc b/2_task/data/__pycache__/user_data.cpython-314.pyc new file mode 100644 index 0000000000000000000000000000000000000000..25fd21a7ba268bd7bd59510e5bc4b344a9be9232 GIT binary patch literal 483 zcmZ8d%}T>S5Z=uuX|PQc5xj_s;-Lr?#8VLu+C#ml1oX5R)+T6Z(uCcu+FReDeTlw= z?;u{vUMhIFcTL3~U>@n_4NL9PF}BUp$iYrcZBoNdBT4lPD#21TlVQKz>e;(|V8 zS)0+G-aUG~;jATT80Sfr(&Iof(WW7jjCQp&09MO;%6p7t@XV4p3?R=v-O$u7_B8a- zr?WcT8f=f9_2Ko$#=+R}hUI}fEtwU2icHJq6)n4}TFULpI1#m{D9QCA99nRA61M@M oD=!0pp1T^9bDCyhH;K;pnhxQc1du7g7*9~+9W{Pz3(qI~0%~M!a{vGU literal 0 HcmV?d00001 diff --git a/2_task/data/user_data.py b/2_task/data/user_data.py new file mode 100644 index 000000000..eb86b8e88 --- /dev/null +++ b/2_task/data/user_data.py @@ -0,0 +1,9 @@ +from utils.helpers import random_email, random_password, random_name + + +def get_valid_user(): + return { + "email": random_email(), + "password": random_password(), + "name": random_name() + } diff --git a/2_task/requirements.txt b/2_task/requirements.txt new file mode 100644 index 000000000..1cb991a0c --- /dev/null +++ b/2_task/requirements.txt @@ -0,0 +1,3 @@ +pytest +requests +allure-pytest \ No newline at end of file diff --git a/2_task/tests/__pycache__/test_orders.cpython-314-pytest-9.0.2.pyc b/2_task/tests/__pycache__/test_orders.cpython-314-pytest-9.0.2.pyc new file mode 100644 index 0000000000000000000000000000000000000000..64558a01c95c4462def637d07a22ce56cd9d4dde GIT binary patch literal 9137 zcmds6U2GiH6`q-${hi(Qza2=xYtjT3l67J`Km525LWuK2x*C#6rEaqt?1{aw*&W}R zZEz|oLxHC708&Mj_9>OBDy~#1O^I+RiTXw#$93F9Q>6BR7gPy3O{7Znp*?42@15CY z;HwQoPo?m>wWmcJ+ts~22z(6Ua_t&%tA3dTX-GStlu~I6a34e zPj77z(VvC7%{gZA(*nm4zCiuXDV)r0@p%mLygxqz`grMrBILtv+ApamWx-!d4;7+R zi)!eiBA#e?mmKoffzpOIHsW*RI%qHGy>36SA^EqQ1`NB) z4r`~>QrV8_s$rb2k_lT<$Hz6pI9h!{tJtApX~ItJshLw%QaYoWrE0~Nd~o)eG^pyO zL8zw@BP-bA^9E={r!*BG*dcvpn;j#Xp;s%0hS?z$J3dRp+caWkHa(!v?8-WdyN=jV zqvpOFmA0c8Y0%v1YVMrlKNChr=lC%!SBwN zd@ryQPv|oyXcSdqcNE9fa=Az}os3sc=_=9eBor5)tCh-TsbbiXauqZTdtK3(s@BRA zj%snTTzyV07c1&1&5joh^`wR^*y%lvrNHp}2&odgt9Y_XPN`;5dr>c|6~`snPCJf~ zr#PXSs?8Vev>Sn#;ln0+lOQtMY0rJ&T!XaX!>F##l&k6l>2QXI-E}>*-Ilz}h(9yz zX58NF^k;Va)wcOFLw>a#{>&}|r(foCmp!`ok-{+;n^AbKT75w+%&3(K?ZrG%$IZe- zNiSDV6^4qYYP?WD`x}ldy5D0?pRw0FUKuBvYHIG|;^~q(RaD`VCXc}@CHNbf!-GEV z%KYT9|L`K?RIZL|A6 z?i^U`+&FvaM(@D+fp;qBk1h2+bm2Sm9ltp-zi(;llUC2(*(1vlF23$u&vHm;i_Gp{ zPH^$ww|`L2-HvhX>)v|ljh8->y3RiM_8}{lxsmF=(cX7EDz-;v$Ci^^virK!zaaHn z;^y++Td!*RVaNqdy*f^YL>J zFG-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Uz?7NEY z30KZN7lQMs9MMjbk_o3(?2#R*^qa; zM`~fSWR^AOSjO2CbJj~vbS3DcInIeTu9IVrovKdM%Gx){vrq(% z%KfnIuUzV1LYNnBaUho4IU)9=4XC#j_?boi$W0;24`Sorg4&Q=?qB7YJacZw(Ze`3-Z)qeqgCSX|r literal 0 HcmV?d00001 diff --git a/2_task/tests/__pycache__/test_user_create.cpython-314-pytest-9.0.2.pyc b/2_task/tests/__pycache__/test_user_create.cpython-314-pytest-9.0.2.pyc new file mode 100644 index 0000000000000000000000000000000000000000..79bb276bdf6492645de31b13ffdfc2aeea00f2c4 GIT binary patch literal 5451 zcmd5=U5p#m6}~ebdu-3H_cu+_E?IBWgj!AP{Yy3>Y#Tx;3uz)VfT>i&bYf37Q@r-< zy)%$a6=~TZ1!&bEwGTX1t<(qh4QSJ#Rt>zhkF)HiK?7BJ$O~_q<}DHu=gfG1Z0v3t z1u0k7x#!+%uGKo7Qf+d8unvE7N$9GEXTK#>88o->FS>d z{KbfWZ&&|h;Gc^4XJl?S$)!KX=bg-PPG(*+m6z0-UR5ln(R2IGn5MxVDioNh)oLm| zWzl(!vbifa#CB34tJhiN&u#5c%`>K7#{ef~))$CjPee zE6}gnf3mM;?GHe~i7U{*XTP(yVqb>wrIxU#U_%W3t)GEhCgo;`NDv@{lzFhbtq4hL zZ)2pK@aKAnOeXmfq;96U#^6d^G3ndG-r!&O=i+23c4&@}#UDP{G|c~lkP%XLeBusH~|8u*i`03_}WL}PyGrmu;-`B!^Ecix;VRHU~wkHjSp1w9lN}Qik z|Af`;ZR>`8@34=qJHg2@S%`e2&i=gr967$FZ_M{C#P$V|hnFfYCuFe{FK{ihi87qn zYmuFI_;X9kxI$Ea;B7Oi(mTxh+o=2 zh2J;hCqn#Qm6HGiL$?PDs-YKD%REz{+Pn@gJzeD-;pePTcVfoUxRazBGa7ZK;cybg zf!i6C0SK7cJ>NB!W^xQCXHGgIvnl`!>=_(SpqOs)Jm`5IT;*=_v$Lz*xhY&f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u5Hr;fw;$9Y4XyzUG3Pc@ayJaohbZOv;Jlt{XA1)G#2YMgb)MMB#Ll(dS4co@_fOlQ+O~%x-#Om_!<+6i@#Pv<*A(SkpZy zFmV*?PVu)d#ahyDfsoS3Q5LFr54eJ9ST@D?nZge#Lcfio2So-&FN*J=IE3Q6C=R2* z&?M1~o9a^8P)mMn5_-Omq94T(6ay%-C~_zUQ4E2wa1Wt7jN-v^4~6caMctlL^vciG zvR+bVs8-S{whnhbeGZVgL+jrlR>@Y3B-`KVd6ejQ=i*j0(iU4i`>zyf?|ysb*DD_; zZZ6;Iah@Lgb9}vR@|$uuWpC|u1QcR+Q>cH|gsgWrp}7&#*AWXen+}7AYE19TIs5-m#yraRyKiBGzgn_ zP~51k+hxsT1zs&~6E6>P{wCAAftgHh(Vb_lhJP_LlF~@{~08C%gWg*CbT%U zs5mAmKR-J$rZO=vCAA`;C^5MtCMB~VCqFmFD83}II6J1aBr~TtCO$qhFS8^*Uaz3? g7Kcr4eoARhs$CH)&?t~)#UREfW=2NFB4!{90H!-8VE_OC literal 0 HcmV?d00001 diff --git a/2_task/utils/__pycache__/helpers.cpython-314.pyc b/2_task/utils/__pycache__/helpers.cpython-314.pyc new file mode 100644 index 0000000000000000000000000000000000000000..275035e1eb2fe00add000e42325789ac7ccdc926 GIT binary patch literal 2172 zcmcIkK~Eb;6rNeH?S;h{8B&@SQZNdt35g||;zBVcX#!MDiL+JcWrek|S7yO@w=?4= zSc&9QrO*SkK@F;ql0z;?{Q;>|wK?Xv5kx`T9wPPB8-o0Rz8SA6&@@%0_R0Qs=FOWo z^S*iSoobFWB9Qw(QENMZ&~JQF7s(&&jl-adW{`$ILag@142!wMBu!!gEzpjbtjT~u zEeIIWLV#f{45(-dV1tHxP@>^??sTfsKg*ayhm%Rl%wo|X*UF?|5_-nWmvaWQ?9yp! zk}s^BNzagS&cBHGD1dNNw8sFdNP}Btuvj?+dj0k&BOh82lWwGk>e>wVctmCtO-lJ5 z&idY)kQNvSKn$`MWF}=<4{cx%&sUVO1;Z-BJrhAsp0llz7a~R}Z!dV^+^o%G@IsUk zt5oo!2F+PkwrF2BNzS0=2HN8%dqW=%>sKLSs$aA1c|%`>{pO7fF>*}LTTanl&2 zp!0f}Sw*VPnnj1x-PG5q^}&0i-;I9X`>b#5 zN#EF`b6anYZ?;ajvB}4Zt6p*CE2J4V93nal3PJR@!j*>pdzueCf=EL+=z#DL>N3-) z;iC`IgEk}*1Pj97G7%y?aMHkmdm}1<7x5W483V$+P~Iw7jFJd9;31PJw~G2CItHcJ zZIUO)K-&a=dI|t|R3po&+o{#TyQANXKInZGAAAxY{PDG)JAdeW8Xtcg-)jA2Q=M|< zsaMcg6rTPM8fQW;BZtJ`z(nw6tdLe%I?93Sb5JrCOwtYpJeO!3;BVr8*uB*{vZ_AU9&II-G#o2wl-X>Om<0=Z5`of|=crwRwBkI7gb=KF3Nb$~L;X`v zc5KQ#<@~u%FJ`Z5mlBc}c8tZMZREKTb?g!~Deod(U9~ie)V*iRQ0$}!mfGM?&jVD^ zb0xakap%Og5?j5z*>-YUXw&UXaTD*mogWHH~6xjhBUHx(x4#M`S;5aX;t67a&Ngvk~6?nI)btd4m~19gocm6igLHlxEl8(Npsx6@yJ zur~Nqjk|JOP?Bh@^+nziYwyy*H%V-4>r7+)4Rx~qh7=WbgNU&Jq3B-|tJ^atM#jrITl literal 0 HcmV?d00001 diff --git a/2_task/utils/helpers.py b/2_task/utils/helpers.py new file mode 100644 index 000000000..9b96cb567 --- /dev/null +++ b/2_task/utils/helpers.py @@ -0,0 +1,40 @@ +import random +import string +import requests + +BASE_URL = "https://stellarburgers.education-services.ru" + + +def random_email(): + return f"test_{''.join(random.choices(string.ascii_lowercase, k=8))}@mail.ru" + + +def random_password(): + return ''.join(random.choices(string.ascii_letters + string.digits, k=10)) + + +def random_name(): + return ''.join(random.choices(string.ascii_letters, k=6)) + + +def register_user(): + payload = { + "email": random_email(), + "password": random_password(), + "name": random_name() + } + response = requests.post(f"{BASE_URL}/api/auth/register", json=payload) + return payload, response + + +def login_user(email, password): + payload = { + "email": email, + "password": password + } + return requests.post(f"{BASE_URL}/api/auth/login", json=payload) + + +def get_ingredients(): + response = requests.get(f"{BASE_URL}/api/ingredients") + return response.json()["data"] From 2951f71762aa7f68c85ad0be852e82f701a07c10 Mon Sep 17 00:00:00 2001 From: Vitaliy Gulevatiy Date: Sat, 7 Feb 2026 16:32:38 +0300 Subject: [PATCH 2/4] Remove IDE and pycache files from task 2 --- 2_task/.idea/.gitignore | 5 ----- 2_task/.idea/2_task.iml | 8 -------- .../inspectionProfiles/profiles_settings.xml | 6 ------ 2_task/.idea/misc.xml | 7 ------- 2_task/.idea/modules.xml | 8 -------- 2_task/data/__pycache__/__init__.cpython-314.pyc | Bin 156 -> 0 bytes .../data/__pycache__/user_data.cpython-314.pyc | Bin 483 -> 0 bytes .../test_orders.cpython-314-pytest-9.0.2.pyc | Bin 9137 -> 0 bytes ...test_user_create.cpython-314-pytest-9.0.2.pyc | Bin 5451 -> 0 bytes .../test_user_login.cpython-314-pytest-9.0.2.pyc | Bin 4676 -> 0 bytes .../utils/__pycache__/__init__.cpython-314.pyc | Bin 157 -> 0 bytes 2_task/utils/__pycache__/helpers.cpython-314.pyc | Bin 2172 -> 0 bytes 12 files changed, 34 deletions(-) delete mode 100644 2_task/.idea/.gitignore delete mode 100644 2_task/.idea/2_task.iml delete mode 100644 2_task/.idea/inspectionProfiles/profiles_settings.xml delete mode 100644 2_task/.idea/misc.xml delete mode 100644 2_task/.idea/modules.xml delete mode 100644 2_task/data/__pycache__/__init__.cpython-314.pyc delete mode 100644 2_task/data/__pycache__/user_data.cpython-314.pyc delete mode 100644 2_task/tests/__pycache__/test_orders.cpython-314-pytest-9.0.2.pyc delete mode 100644 2_task/tests/__pycache__/test_user_create.cpython-314-pytest-9.0.2.pyc delete mode 100644 2_task/tests/__pycache__/test_user_login.cpython-314-pytest-9.0.2.pyc delete mode 100644 2_task/utils/__pycache__/__init__.cpython-314.pyc delete mode 100644 2_task/utils/__pycache__/helpers.cpython-314.pyc diff --git a/2_task/.idea/.gitignore b/2_task/.idea/.gitignore deleted file mode 100644 index b58b603fe..000000000 --- a/2_task/.idea/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ diff --git a/2_task/.idea/2_task.iml b/2_task/.idea/2_task.iml deleted file mode 100644 index c03f621ae..000000000 --- a/2_task/.idea/2_task.iml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/2_task/.idea/inspectionProfiles/profiles_settings.xml b/2_task/.idea/inspectionProfiles/profiles_settings.xml deleted file mode 100644 index 105ce2da2..000000000 --- a/2_task/.idea/inspectionProfiles/profiles_settings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/2_task/.idea/misc.xml b/2_task/.idea/misc.xml deleted file mode 100644 index 590a59e60..000000000 --- a/2_task/.idea/misc.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/2_task/.idea/modules.xml b/2_task/.idea/modules.xml deleted file mode 100644 index 9d4118fd4..000000000 --- a/2_task/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/2_task/data/__pycache__/__init__.cpython-314.pyc b/2_task/data/__pycache__/__init__.cpython-314.pyc deleted file mode 100644 index 93ecb48a136f8ce075b58ef27b75ef211520a2b7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 156 zcmdPq>P{wCAAftgHh(Vb_lhJP_LlF~@{~08C%hK5@CbT%U zs5mAmKR-J$rZO=vCAA`;C^5MtCMB~VCqFmFD83}II6EdKu_Q4jK0Y%qvm`!Vub}c4 fhfQvNN@-52T@fqLB#>RjAjT(VMn=XWW*`dyXWS*d diff --git a/2_task/data/__pycache__/user_data.cpython-314.pyc b/2_task/data/__pycache__/user_data.cpython-314.pyc deleted file mode 100644 index 25fd21a7ba268bd7bd59510e5bc4b344a9be9232..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 483 zcmZ8d%}T>S5Z=uuX|PQc5xj_s;-Lr?#8VLu+C#ml1oX5R)+T6Z(uCcu+FReDeTlw= z?;u{vUMhIFcTL3~U>@n_4NL9PF}BUp$iYrcZBoNdBT4lPD#21TlVQKz>e;(|V8 zS)0+G-aUG~;jATT80Sfr(&Iof(WW7jjCQp&09MO;%6p7t@XV4p3?R=v-O$u7_B8a- zr?WcT8f=f9_2Ko$#=+R}hUI}fEtwU2icHJq6)n4}TFULpI1#m{D9QCA99nRA61M@M oD=!0pp1T^9bDCyhH;K;pnhxQc1du7g7*9~+9W{Pz3(qI~0%~M!a{vGU diff --git a/2_task/tests/__pycache__/test_orders.cpython-314-pytest-9.0.2.pyc b/2_task/tests/__pycache__/test_orders.cpython-314-pytest-9.0.2.pyc deleted file mode 100644 index 64558a01c95c4462def637d07a22ce56cd9d4dde..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 9137 zcmds6U2GiH6`q-${hi(Qza2=xYtjT3l67J`Km525LWuK2x*C#6rEaqt?1{aw*&W}R zZEz|oLxHC708&Mj_9>OBDy~#1O^I+RiTXw#$93F9Q>6BR7gPy3O{7Znp*?42@15CY z;HwQoPo?m>wWmcJ+ts~22z(6Ua_t&%tA3dTX-GStlu~I6a34e zPj77z(VvC7%{gZA(*nm4zCiuXDV)r0@p%mLygxqz`grMrBILtv+ApamWx-!d4;7+R zi)!eiBA#e?mmKoffzpOIHsW*RI%qHGy>36SA^EqQ1`NB) z4r`~>QrV8_s$rb2k_lT<$Hz6pI9h!{tJtApX~ItJshLw%QaYoWrE0~Nd~o)eG^pyO zL8zw@BP-bA^9E={r!*BG*dcvpn;j#Xp;s%0hS?z$J3dRp+caWkHa(!v?8-WdyN=jV zqvpOFmA0c8Y0%v1YVMrlKNChr=lC%!SBwN zd@ryQPv|oyXcSdqcNE9fa=Az}os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5P`p>z3K4%}5$7>d!}09FGp)p@|0A@C!z$)<~O`$Pk` zkI2&WP9+3beVSUXj@91iSVZ=kbk=QACk~JMe4F(3JlKAWugj^Hx-2d>ar>B@mfMtA zll|grupe7tG}$i#_A}%-aQkkD%o7CXPu>P3TMa@#y=p$6`tnph@dda$I?_XR7t=Qd zV>%LdZx_uV`=RPS_#2;snB_i?-l;YU+=>5>4V~PD9!o?a<*tkM-=dgvHgqt%ZMD?rFES(kyHUs-t5`XICL8f4DG!w-Uq`yByYaR6NgfX?Bz z4Of8IyVok99jG`QcZC?V^9mmb?Xa~oJ*0#jXn%@L{|_A+-g^3r&h+2toBl|{*+#%u z2JH-TX%ANk?W|s%hI=Clh9(BrK*L+97|RlcW|OB2N@)tK_oo*>G7rD#u{h8DBZ7u|5d-FpwT zGcIc9f>9eF+Z~e!-R|%XLL+(j8@$8Hal^j%T-xfpf5lz;uQj4)yX+V}uX6Uz?7NEY z30KZN7lQMs9MMjbk_o3(?2#R*^qa; zM`~fSWR^AOSjO2CbJj~vbS3DcInIeTu9IVrovKdM%Gx){vrq(% z%KfnIuUzV1LYNnBaUho4IU)9=4XC#j_?boi$W0;24`Sorg4&Q=?qB7YJacZw(Ze`3-Z)qeqgCSX|r diff --git a/2_task/tests/__pycache__/test_user_create.cpython-314-pytest-9.0.2.pyc b/2_task/tests/__pycache__/test_user_create.cpython-314-pytest-9.0.2.pyc deleted file mode 100644 index 79bb276bdf6492645de31b13ffdfc2aeea00f2c4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5451 zcmd5=U5p#m6}~ebdu-3H_cu+_E?IBWgj!AP{Yy3>Y#Tx;3uz)VfT>i&bYf37Q@r-< zy)%$a6=~TZ1!&bEwGTX1t<(qh4QSJ#Rt>zhkF)HiK?7BJ$O~_q<}DHu=gfG1Z0v3t z1u0k7x#!+%uGKo7Qf+d8unvE7N$9GEXTK#>88o->FS>d z{KbfWZ&&|h;Gc^4XJl?S$)!KX=bg-PPG(*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a/2_task/utils/__pycache__/helpers.cpython-314.pyc b/2_task/utils/__pycache__/helpers.cpython-314.pyc deleted file mode 100644 index 275035e1eb2fe00add000e42325789ac7ccdc926..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2172 zcmcIkK~Eb;6rNeH?S;h{8B&@SQZNdt35g||;zBVcX#!MDiL+JcWrek|S7yO@w=?4= zSc&9QrO*SkK@F;ql0z;?{Q;>|wK?Xv5kx`T9wPPB8-o0Rz8SA6&@@%0_R0Qs=FOWo z^S*iSoobFWB9Qw(QENMZ&~JQF7s(&&jl-adW{`$ILag@142!wMBu!!gEzpjbtjT~u zEeIIWLV#f{45(-dV1tHxP@>^??sTfsKg*ayhm%Rl%wo|X*UF?|5_-nWmvaWQ?9yp! zk}s^BNzagS&cBHGD1dNNw8sFdNP}Btuvj?+dj0k&BOh82lWwGk>e>wVctmCtO-lJ5 z&idY)kQNvSKn$`MWF}=<4{cx%&sUVO1;Z-BJrhAsp0llz7a~R}Z!dV^+^o%G@IsUk zt5oo!2F+PkwrF2BNzS0=2HN8%dqW=%>sKLSs$aA1c|%`>{pO7fF>*}LTTanl&2 zp!0f}Sw*VPnnj1x-PG5q^}&0i-;I9X`>b#5 zN#EF`b6anYZ?;ajvB}4Zt6p*CE2J4V93nal3PJR@!j*>pdzueCf=EL+=z#DL>N3-) z;iC`IgEk}*1Pj97G7%y?aMHkmdm}1<7x5W483V$+P~Iw7jFJd9;31PJw~G2CItHcJ zZIUO)K-&a=dI|t|R3po&+o{#TyQANXKInZGAAAxY{PDG)JAdeW8Xtcg-)jA2Q=M|< zsaMcg6rTPM8fQW;BZtJ`z(nw6tdLe%I?93Sb5JrCOwtYpJeO!3;BVr8*uB*{vZ_AU9&II-G#o2wl-X>Om<0=Z5`of|=crwRwBkI7gb=KF3Nb$~L;X`v zc5KQ#<@~u%FJ`Z5mlBc}c8tZMZREKTb?g!~Deod(U9~ie)V*iRQ0$}!mfGM?&jVD^ zb0xakap%Og5?j5z*>-YUXw&UXaTD*mogWHH~6xjhBUHx(x4#M`S;5aX;t67a&Ngvk~6?nI)btd4m~19gocm6igLHlxEl8(Npsx6@yJ zur~Nqjk|JOP?Bh@^+nziYwyy*H%V-4>r7+)4Rx~qh7=WbgNU&Jq3B-|tJ^atM#jrITl From 2ed1f7aac8494ee58d745e1f621264c7f14f9a3c Mon Sep 17 00:00:00 2001 From: Vitaliy Gulevatiy Date: Sat, 7 Feb 2026 17:02:55 +0300 Subject: [PATCH 3/4] fix: task 2 api tests structure, fixtures, urls and allure --- .gitignore | 8 ++ 2_task/conftest.py | 30 ++++++ 2_task/tests/test_orders.py | 165 ++++++++++++++----------------- 2_task/tests/test_user_create.py | 51 ++++++---- 2_task/tests/test_user_login.py | 73 ++++++++++---- 2_task/utils/helpers.py | 3 +- 2_task/utils/urls.py | 1 + 7 files changed, 200 insertions(+), 131 deletions(-) create mode 100644 .gitignore create mode 100644 2_task/conftest.py create mode 100644 2_task/utils/urls.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..f8cfb7ea1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +.idea/ +__pycache__/ +*.py[cod] + +.pytest_cache/ +.coverage +htmlcov/ +allure-results/ diff --git a/2_task/conftest.py b/2_task/conftest.py new file mode 100644 index 000000000..3d60537f1 --- /dev/null +++ b/2_task/conftest.py @@ -0,0 +1,30 @@ +import pytest +from utils.helpers import register_user, login_user, get_ingredients + + +@pytest.fixture +def auth_user(): + user_data, _ = register_user() + login_response = login_user( + user_data["email"], + user_data["password"] + ) + token = login_response.json()["accessToken"] + return token + +@pytest.fixture +def registered_user(): + user_data, response = register_user() + return user_data + +@pytest.fixture +def auth_token(): + user_data, _ = register_user() + response = login_user(user_data["email"], user_data["password"]) + return response.json()["accessToken"] + + +@pytest.fixture +def ingredient_ids(): + ingredients = get_ingredients() + return [ingredients[0]["_id"], ingredients[1]["_id"]] \ No newline at end of file diff --git a/2_task/tests/test_orders.py b/2_task/tests/test_orders.py index 12fc21b07..32232fee7 100644 --- a/2_task/tests/test_orders.py +++ b/2_task/tests/test_orders.py @@ -1,93 +1,76 @@ import requests import allure -from utils.helpers import ( - register_user, - login_user, - get_ingredients, - BASE_URL -) - - -@allure.title("Создание заказа с авторизацией") -def test_create_order_with_auth(): - user_data, _ = register_user() - login_response = login_user(user_data["email"], user_data["password"]) - token = login_response.json()["accessToken"] - - ingredients = get_ingredients() - ingredient_ids = [ingredients[0]["_id"], ingredients[1]["_id"]] - - headers = { - "Authorization": token - } - - payload = { - "ingredients": ingredient_ids - } - - response = requests.post( - f"{BASE_URL}/api/orders", - json=payload, - headers=headers - ) - - assert response.status_code == 200 - assert response.json()["success"] is True - - -@allure.title("Создание заказа без авторизации") -def test_create_order_without_auth(): - ingredients = get_ingredients() - ingredient_ids = [ingredients[0]["_id"]] - - payload = { - "ingredients": ingredient_ids - } - - response = requests.post(f"{BASE_URL}/api/orders", json=payload) - - assert response.status_code == 200 - assert response.json()["success"] is True - - - -@allure.title("Создание заказа с ингредиентами") -def test_create_order_with_ingredients(): - ingredients = get_ingredients() - ingredient_ids = [ingredients[0]["_id"]] - - response = requests.post( - f"{BASE_URL}/api/orders", - json={"ingredients": ingredient_ids} - ) - - # API допускает заказ без авторизации, но с ингредиентами - assert response.status_code == 200 - assert response.json()["success"] is True - - -@allure.title("Создание заказа без ингредиентов") -def test_create_order_without_ingredients(): - response = requests.post( - f"{BASE_URL}/api/orders", - json={} - ) - - assert response.status_code == 400 - assert response.json()["success"] is False - - -@allure.title("Создание заказа с неверным хешем ингредиентов") -def test_create_order_with_invalid_ingredient_hash(): - payload = { - "ingredients": ["invalid_hash"] - } - - response = requests.post( - f"{BASE_URL}/api/orders", - json=payload - ) - - assert response.status_code == 400 - assert response.json()["success"] is False - +from utils.urls import BASE_URL + + +@allure.suite("Заказы") +class TestOrders: + + @allure.title("Создание заказа с авторизацией") + def test_create_order_with_auth(self, auth_token, ingredient_ids): + headers = { + "Authorization": auth_token + } + payload = { + "ingredients": ingredient_ids + } + + with allure.step("Создание заказа авторизованным пользователем"): + response = requests.post( + f"{BASE_URL}/api/orders", + json=payload, + headers=headers + ) + + body = response.json() + + assert response.status_code == 200 + assert body["order"]["ingredients"] + assert body["order"]["number"] > 0 + + @allure.title("Создание заказа без авторизации") + def test_create_order_without_auth(self, ingredient_ids): + payload = { + "ingredients": ingredient_ids + } + + with allure.step("Создание заказа без авторизации"): + response = requests.post( + f"{BASE_URL}/api/orders", + json=payload + ) + + body = response.json() + + assert response.status_code == 200 + assert body["order"]["number"] > 0 + + @allure.title("Создание заказа без ингредиентов") + def test_create_order_without_ingredients(self): + with allure.step("Создание заказа без ингредиентов"): + response = requests.post( + f"{BASE_URL}/api/orders", + json={} + ) + + body = response.json() + + assert response.status_code == 400 + assert body["message"] == "Ingredient ids must be provided" + + @allure.title("Создание заказа с некорректным id ингредиента") + def test_create_order_with_invalid_ingredient_hash(self): + payload = { + "ingredients": ["invalid_hash"] + } + + with allure.step("Создание заказа с неверным ингредиентом"): + response = requests.post( + f"{BASE_URL}/api/orders", + json=payload + ) + + body = response.json() + + assert response.status_code == 400 + assert body["message"] == "One or more ids provided are incorrect" diff --git a/2_task/tests/test_user_create.py b/2_task/tests/test_user_create.py index 878395ced..a9f1da398 100644 --- a/2_task/tests/test_user_create.py +++ b/2_task/tests/test_user_create.py @@ -1,36 +1,45 @@ +import pytest import requests import allure from data.user_data import get_valid_user +from utils.urls import BASE_URL -BASE_URL = "https://stellarburgers.education-services.ru" +@allure.feature("Создание пользователя") +class TestUserCreate: -@allure.title("Создание уникального пользователя") -def test_create_unique_user(): - payload = get_valid_user() - response = requests.post(f"{BASE_URL}/api/auth/register", json=payload) + @allure.title("Создание уникального пользователя") + def test_create_unique_user(self): + payload = get_valid_user() - assert response.status_code == 200 - assert response.json()["success"] is True + with allure.step("Отправка запроса на регистрацию пользователя"): + response = requests.post(f"{BASE_URL}/api/auth/register", json=payload) + assert response.status_code == 200 + assert "accessToken" in response.json() + assert "refreshToken" in response.json() + assert "user" in response.json() -@allure.title("Создание уже существующего пользователя") -def test_create_existing_user(): - payload = get_valid_user() + @allure.title("Создание уже существующего пользователя") + def test_create_existing_user(self): + payload = get_valid_user() - requests.post(f"{BASE_URL}/api/auth/register", json=payload) - response = requests.post(f"{BASE_URL}/api/auth/register", json=payload) + requests.post(f"{BASE_URL}/api/auth/register", json=payload) - assert response.status_code == 403 - assert response.json()["success"] is False + with allure.step("Повторная регистрация пользователя"): + response = requests.post(f"{BASE_URL}/api/auth/register", json=payload) + assert response.status_code == 403 + assert response.json()["message"] == "User already exists" -@allure.title("Создание пользователя без обязательного поля") -def test_create_user_without_required_field(): - payload = get_valid_user() - payload.pop("email") + @allure.title("Создание пользователя без обязательных полей") + @pytest.mark.parametrize("missing_field", ["email", "password", "name"]) + def test_create_user_without_required_field(self, missing_field): + payload = get_valid_user() + payload.pop(missing_field) - response = requests.post(f"{BASE_URL}/api/auth/register", json=payload) + with allure.step(f"Регистрация без поля {missing_field}"): + response = requests.post(f"{BASE_URL}/api/auth/register", json=payload) - assert response.status_code == 403 - assert response.json()["success"] is False + assert response.status_code == 403 + assert response.json()["message"] == "Email, password and name are required fields" diff --git a/2_task/tests/test_user_login.py b/2_task/tests/test_user_login.py index e42a12025..877a4904e 100644 --- a/2_task/tests/test_user_login.py +++ b/2_task/tests/test_user_login.py @@ -1,27 +1,66 @@ import requests import allure -from utils.helpers import register_user, login_user, BASE_URL +import pytest +from utils.urls import BASE_URL -@allure.title("Логин под существующим пользователем") -def test_login_existing_user(): - user_data, _ = register_user() +@allure.suite("Логин пользователя") +class TestUserLogin: - response = login_user(user_data["email"], user_data["password"]) + @allure.title("Логин под существующим пользователем") + def test_login_existing_user(self, registered_user): + payload = { + "email": registered_user["email"], + "password": registered_user["password"] + } - assert response.status_code == 200 - assert response.json()["success"] is True - assert "accessToken" in response.json() + with allure.step("Отправка запроса на логин"): + response = requests.post( + f"{BASE_URL}/api/auth/login", + json=payload + ) + body = response.json() -@allure.title("Логин с неверным логином и паролем") -def test_login_with_invalid_credentials(): - payload = { - "email": "wrong@mail.ru", - "password": "wrongpassword" - } + assert response.status_code == 200 + assert "accessToken" in body + assert "refreshToken" in body + assert body["user"]["email"] == registered_user["email"] - response = requests.post(f"{BASE_URL}/api/auth/login", json=payload) + @allure.title("Логин с неверным логином и паролем") + def test_login_with_invalid_credentials(self): + payload = { + "email": "wrong@mail.ru", + "password": "wrongpassword" + } - assert response.status_code == 401 - assert response.json()["success"] is False + with allure.step("Попытка логина с неверными данными"): + response = requests.post( + f"{BASE_URL}/api/auth/login", + json=payload + ) + + body = response.json() + + assert response.status_code == 401 + assert body["message"] == "email or password are incorrect" + + @allure.title("Логин без обязательных полей") + @pytest.mark.parametrize("field", ["email", "password"]) + def test_login_without_required_field(self, field): + payload = { + "email": "test@mail.ru", + "password": "password123" + } + payload.pop(field) + + with allure.step(f"Логин без поля {field}"): + response = requests.post( + f"{BASE_URL}/api/auth/login", + json=payload + ) + + body = response.json() + + assert response.status_code == 401 + assert body["message"] == "email or password are incorrect" diff --git a/2_task/utils/helpers.py b/2_task/utils/helpers.py index 9b96cb567..941017cce 100644 --- a/2_task/utils/helpers.py +++ b/2_task/utils/helpers.py @@ -1,8 +1,7 @@ import random import string import requests - -BASE_URL = "https://stellarburgers.education-services.ru" +from utils.urls import BASE_URL def random_email(): diff --git a/2_task/utils/urls.py b/2_task/utils/urls.py new file mode 100644 index 000000000..8450f7f77 --- /dev/null +++ b/2_task/utils/urls.py @@ -0,0 +1 @@ +BASE_URL = "https://stellarburgers.education-services.ru" From 430b640cee9bd2d6a1deffb8a1bfc1fcb70d4857 Mon Sep 17 00:00:00 2001 From: Vitaliy Gulevatiy Date: Sun, 8 Feb 2026 17:25:28 +0300 Subject: [PATCH 4/4] fix: refactor api tests after reviewer comments --- 2_task/conftest.py | 15 +++------ 2_task/tests/test_orders.py | 39 +++++++----------------- 2_task/tests/test_user_create.py | 32 +++++++++++--------- 2_task/tests/test_user_login.py | 52 ++++++++++++-------------------- 2_task/utils/helpers.py | 44 +++++++++++++++++++++------ 5 files changed, 87 insertions(+), 95 deletions(-) diff --git a/2_task/conftest.py b/2_task/conftest.py index 3d60537f1..37670561c 100644 --- a/2_task/conftest.py +++ b/2_task/conftest.py @@ -2,16 +2,6 @@ from utils.helpers import register_user, login_user, get_ingredients -@pytest.fixture -def auth_user(): - user_data, _ = register_user() - login_response = login_user( - user_data["email"], - user_data["password"] - ) - token = login_response.json()["accessToken"] - return token - @pytest.fixture def registered_user(): user_data, response = register_user() @@ -20,7 +10,10 @@ def registered_user(): @pytest.fixture def auth_token(): user_data, _ = register_user() - response = login_user(user_data["email"], user_data["password"]) + response = login_user( + user_data["email"], + user_data["password"] + ) return response.json()["accessToken"] diff --git a/2_task/tests/test_orders.py b/2_task/tests/test_orders.py index 32232fee7..a6874080c 100644 --- a/2_task/tests/test_orders.py +++ b/2_task/tests/test_orders.py @@ -1,6 +1,6 @@ -import requests import allure -from utils.urls import BASE_URL + +from utils.helpers import create_order @allure.suite("Заказы") @@ -15,18 +15,13 @@ def test_create_order_with_auth(self, auth_token, ingredient_ids): "ingredients": ingredient_ids } - with allure.step("Создание заказа авторизованным пользователем"): - response = requests.post( - f"{BASE_URL}/api/orders", - json=payload, - headers=headers - ) - + response = create_order(payload=payload, headers=headers) body = response.json() assert response.status_code == 200 - assert body["order"]["ingredients"] + assert "order" in body assert body["order"]["number"] > 0 + assert body["order"]["ingredients"] @allure.title("Создание заказа без авторизации") def test_create_order_without_auth(self, ingredient_ids): @@ -34,42 +29,30 @@ def test_create_order_without_auth(self, ingredient_ids): "ingredients": ingredient_ids } - with allure.step("Создание заказа без авторизации"): - response = requests.post( - f"{BASE_URL}/api/orders", - json=payload - ) - + response = create_order(payload=payload) body = response.json() assert response.status_code == 200 + assert "order" in body assert body["order"]["number"] > 0 @allure.title("Создание заказа без ингредиентов") def test_create_order_without_ingredients(self): - with allure.step("Создание заказа без ингредиентов"): - response = requests.post( - f"{BASE_URL}/api/orders", - json={} - ) + payload = {} + response = create_order(payload=payload) body = response.json() assert response.status_code == 400 assert body["message"] == "Ingredient ids must be provided" @allure.title("Создание заказа с некорректным id ингредиента") - def test_create_order_with_invalid_ingredient_hash(self): + def test_create_order_with_invalid_ingredient_id(self): payload = { "ingredients": ["invalid_hash"] } - with allure.step("Создание заказа с неверным ингредиентом"): - response = requests.post( - f"{BASE_URL}/api/orders", - json=payload - ) - + response = create_order(payload=payload) body = response.json() assert response.status_code == 400 diff --git a/2_task/tests/test_user_create.py b/2_task/tests/test_user_create.py index a9f1da398..b27c600a2 100644 --- a/2_task/tests/test_user_create.py +++ b/2_task/tests/test_user_create.py @@ -1,8 +1,8 @@ -import pytest -import requests import allure +import pytest + +from utils.helpers import register_user from data.user_data import get_valid_user -from utils.urls import BASE_URL @allure.feature("Создание пользователя") @@ -12,25 +12,27 @@ class TestUserCreate: def test_create_unique_user(self): payload = get_valid_user() - with allure.step("Отправка запроса на регистрацию пользователя"): - response = requests.post(f"{BASE_URL}/api/auth/register", json=payload) + user_data, response = register_user(payload) + + body = response.json() assert response.status_code == 200 - assert "accessToken" in response.json() - assert "refreshToken" in response.json() - assert "user" in response.json() + assert "accessToken" in body + assert "refreshToken" in body + assert "user" in body + assert body["user"]["email"] == payload["email"] @allure.title("Создание уже существующего пользователя") def test_create_existing_user(self): payload = get_valid_user() - requests.post(f"{BASE_URL}/api/auth/register", json=payload) + register_user(payload) + _, response = register_user(payload) - with allure.step("Повторная регистрация пользователя"): - response = requests.post(f"{BASE_URL}/api/auth/register", json=payload) + body = response.json() assert response.status_code == 403 - assert response.json()["message"] == "User already exists" + assert body["message"] == "User already exists" @allure.title("Создание пользователя без обязательных полей") @pytest.mark.parametrize("missing_field", ["email", "password", "name"]) @@ -38,8 +40,8 @@ def test_create_user_without_required_field(self, missing_field): payload = get_valid_user() payload.pop(missing_field) - with allure.step(f"Регистрация без поля {missing_field}"): - response = requests.post(f"{BASE_URL}/api/auth/register", json=payload) + _, response = register_user(payload) + body = response.json() assert response.status_code == 403 - assert response.json()["message"] == "Email, password and name are required fields" + assert body["message"] == "Email, password and name are required fields" diff --git a/2_task/tests/test_user_login.py b/2_task/tests/test_user_login.py index 877a4904e..439a66716 100644 --- a/2_task/tests/test_user_login.py +++ b/2_task/tests/test_user_login.py @@ -1,7 +1,7 @@ -import requests import allure import pytest -from utils.urls import BASE_URL + +from utils.helpers import login_user @allure.suite("Логин пользователя") @@ -9,16 +9,10 @@ class TestUserLogin: @allure.title("Логин под существующим пользователем") def test_login_existing_user(self, registered_user): - payload = { - "email": registered_user["email"], - "password": registered_user["password"] - } - - with allure.step("Отправка запроса на логин"): - response = requests.post( - f"{BASE_URL}/api/auth/login", - json=payload - ) + response = login_user( + email=registered_user["email"], + password=registered_user["password"] + ) body = response.json() @@ -29,38 +23,32 @@ def test_login_existing_user(self, registered_user): @allure.title("Логин с неверным логином и паролем") def test_login_with_invalid_credentials(self): - payload = { - "email": "wrong@mail.ru", - "password": "wrongpassword" - } - - with allure.step("Попытка логина с неверными данными"): - response = requests.post( - f"{BASE_URL}/api/auth/login", - json=payload - ) + response = login_user( + email="wrong@mail.ru", + password="wrongpassword" + ) body = response.json() - assert response.status_code == 401 + assert response.status_code in [401, 403] assert body["message"] == "email or password are incorrect" @allure.title("Логин без обязательных полей") - @pytest.mark.parametrize("field", ["email", "password"]) - def test_login_without_required_field(self, field): + @pytest.mark.parametrize("missing_field", ["email", "password"]) + def test_login_without_required_field(self, missing_field): payload = { "email": "test@mail.ru", "password": "password123" } - payload.pop(field) + payload.pop(missing_field) - with allure.step(f"Логин без поля {field}"): - response = requests.post( - f"{BASE_URL}/api/auth/login", - json=payload - ) + # вызываем helper напрямую с некорректными данными + response = login_user( + email=payload.get("email"), + password=payload.get("password") + ) body = response.json() - assert response.status_code == 401 + assert response.status_code in [401, 403] assert body["message"] == "email or password are incorrect" diff --git a/2_task/utils/helpers.py b/2_task/utils/helpers.py index 941017cce..6249147d2 100644 --- a/2_task/utils/helpers.py +++ b/2_task/utils/helpers.py @@ -1,6 +1,8 @@ import random import string import requests +import allure + from utils.urls import BASE_URL @@ -16,24 +18,48 @@ def random_name(): return ''.join(random.choices(string.ascii_letters, k=6)) -def register_user(): - payload = { - "email": random_email(), - "password": random_password(), - "name": random_name() - } - response = requests.post(f"{BASE_URL}/api/auth/register", json=payload) +@allure.step("Регистрация пользователя") +def register_user(payload=None): + if payload is None: + payload = { + "email": random_email(), + "password": random_password(), + "name": random_name() + } + + response = requests.post( + f"{BASE_URL}/api/auth/register", + json=payload + ) return payload, response +@allure.step("Логин пользователя") def login_user(email, password): payload = { "email": email, "password": password } - return requests.post(f"{BASE_URL}/api/auth/login", json=payload) + response = requests.post( + f"{BASE_URL}/api/auth/login", + json=payload + ) + return response +@allure.step("Получение списка ингредиентов") def get_ingredients(): - response = requests.get(f"{BASE_URL}/api/ingredients") + response = requests.get( + f"{BASE_URL}/api/ingredients" + ) return response.json()["data"] + + +@allure.step("Создание заказа") +def create_order(payload, headers=None): + response = requests.post( + f"{BASE_URL}/api/orders", + json=payload, + headers=headers + ) + return response