From e88e21350226a8f09e2fad6a8115fde70912c627 Mon Sep 17 00:00:00 2001 From: EgyAbdo10 Date: Sun, 4 Aug 2024 03:22:52 +0300 Subject: [PATCH 01/36] fixed tests --- AUTHORS | 1 + __pycache__/console.cpython-38.pyc | Bin 0 -> 4485 bytes file.json | 1 + models/__pycache__/__init__.cpython-38.pyc | Bin 0 -> 439 bytes models/__pycache__/amenity.cpython-38.pyc | Bin 0 -> 939 bytes models/__pycache__/base_model.cpython-38.pyc | Bin 0 -> 2553 bytes models/__pycache__/city.cpython-38.pyc | Bin 0 -> 1045 bytes models/__pycache__/place.cpython-38.pyc | Bin 0 -> 2538 bytes models/__pycache__/review.cpython-38.pyc | Bin 0 -> 1011 bytes models/__pycache__/state.cpython-38.pyc | Bin 0 -> 1364 bytes models/__pycache__/user.cpython-38.pyc | Bin 0 -> 1108 bytes models/base_model.py | 14 +++++++------- .../engine/__pycache__/__init__.cpython-38.pyc | Bin 0 -> 146 bytes .../engine/__pycache__/db_storage.cpython-38.pyc | Bin 0 -> 2855 bytes .../__pycache__/file_storage.cpython-38.pyc | Bin 0 -> 2465 bytes tests/__pycache__/test_console.cpython-38.pyc | Bin 0 -> 1887 bytes .../__pycache__/__init__.cpython-38.pyc | Bin 0 -> 150 bytes .../__pycache__/test_amenity.cpython-38.pyc | Bin 0 -> 4649 bytes .../__pycache__/test_base_model.cpython-38.pyc | Bin 0 -> 5832 bytes .../__pycache__/test_city.cpython-38.pyc | Bin 0 -> 4824 bytes .../__pycache__/test_place.cpython-38.pyc | Bin 0 -> 8023 bytes .../__pycache__/test_review.cpython-38.pyc | Bin 0 -> 5204 bytes .../__pycache__/test_state.cpython-38.pyc | Bin 0 -> 4545 bytes .../__pycache__/test_user.cpython-38.pyc | Bin 0 -> 5468 bytes tests/test_models/test_base_model.py | 10 +++++----- .../__pycache__/__init__.cpython-38.pyc | Bin 0 -> 162 bytes .../__pycache__/test_db_storage.cpython-38.pyc | Bin 0 -> 4257 bytes .../__pycache__/test_file_storage.cpython-38.pyc | Bin 0 -> 4837 bytes 28 files changed, 14 insertions(+), 12 deletions(-) create mode 100644 __pycache__/console.cpython-38.pyc create mode 100644 file.json create mode 100644 models/__pycache__/__init__.cpython-38.pyc create mode 100644 models/__pycache__/amenity.cpython-38.pyc create mode 100644 models/__pycache__/base_model.cpython-38.pyc create mode 100644 models/__pycache__/city.cpython-38.pyc create mode 100644 models/__pycache__/place.cpython-38.pyc create mode 100644 models/__pycache__/review.cpython-38.pyc create mode 100644 models/__pycache__/state.cpython-38.pyc create mode 100644 models/__pycache__/user.cpython-38.pyc create mode 100644 models/engine/__pycache__/__init__.cpython-38.pyc create mode 100644 models/engine/__pycache__/db_storage.cpython-38.pyc create mode 100644 models/engine/__pycache__/file_storage.cpython-38.pyc create mode 100644 tests/__pycache__/test_console.cpython-38.pyc create mode 100644 tests/test_models/__pycache__/__init__.cpython-38.pyc create mode 100644 tests/test_models/__pycache__/test_amenity.cpython-38.pyc create mode 100644 tests/test_models/__pycache__/test_base_model.cpython-38.pyc create mode 100644 tests/test_models/__pycache__/test_city.cpython-38.pyc create mode 100644 tests/test_models/__pycache__/test_place.cpython-38.pyc create mode 100644 tests/test_models/__pycache__/test_review.cpython-38.pyc create mode 100644 tests/test_models/__pycache__/test_state.cpython-38.pyc create mode 100644 tests/test_models/__pycache__/test_user.cpython-38.pyc create mode 100644 tests/test_models/test_engine/__pycache__/__init__.cpython-38.pyc create mode 100644 tests/test_models/test_engine/__pycache__/test_db_storage.cpython-38.pyc create mode 100644 tests/test_models/test_engine/__pycache__/test_file_storage.cpython-38.pyc diff --git a/AUTHORS b/AUTHORS index 64b26acdc14..923864efbef 100644 --- a/AUTHORS +++ b/AUTHORS @@ -4,3 +4,4 @@ Jennifer Huang <133@holbertonschool.com> Alexa Orrico <210@holbertonschool.com> Joann Vuong <130@holbertonschool.com> +Abdelmoneim Maher diff --git a/__pycache__/console.cpython-38.pyc b/__pycache__/console.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000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^wjhSGS08_?> z3Ihyf&RKSjo~6y$5*B*ah6p=3M9tQ>LgD~F@ILFcwBm>Ofix%P)en&BQK zdpD7W9qqT=vL>ZUCsLLy&9mxJ!pXN`S%{-;WgC((N}#RAa_40RCd=B6iR1sdDOUU@ z%_?bUpwmFTlFUK+17D}!ERDf~a21SI>UE;bPkcGiX##S2=53Gkq^y2H%JyPa@(UE7 XG+b8q%=ZyYvu<$4X`OObr#Aft!IXAc literal 0 HcmV?d00001 diff --git a/models/__pycache__/amenity.cpython-38.pyc b/models/__pycache__/amenity.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b25bb14b7150f3d2baff46d7e9b75fe86e6d2d80 GIT binary patch literal 939 zcmYjP&2AGh5VpO}{w0C_9e`7=kx+uf6(L#>oaljyi!atDc9LzqyQ#e?O4I{VEA<5L z(F@PPGx*A>ufU0!-O$$3d^4UId%hX_YrmfoSjWGA&0aA={@~{E>cHk5h?@W?B8Z}j z87e5~z_20^LBR#5=;x+Wgd%KgW+D-RuVbPj7IBe?r16I)ExMvh$tR*B6<-q->p=4> zE_#ZckYTbp7%VEI++b=l=LUy`F7tYQ2i3{(kon{&bNX|owDBCxA@$*0*SfrbVEDc= ztD^MbNp16T4zZrqCad$Rbc=jB#Y-M9zTLPFU}yqO5y2D{K5lPmx zmTPzS9m;(O{PeHpqfSO#9Q+i1+*-wgNh01KRpTnf`%;Xz= zKQ|m%$E}vy`dCU#ka8G!?zEYCp4qwc;n_FTx6~(6Hba;4mi!%$7geFhdcMvksu~~W z_NY99cvWh7@p@d~6S#5P!+Nw_+dlBxM}qK;2w|I@?I1??b$iI6gd-JLA(6UslbPv4 r7wZR7;>m+|RN2Btco1tpBGu4CQa*mu4&*J~@16i~8q*!xYcco-n)B>% literal 0 HcmV?d00001 diff --git a/models/__pycache__/base_model.cpython-38.pyc b/models/__pycache__/base_model.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b3c16125f08bbbd738ca3338d2627ebfec285569 GIT binary patch literal 2553 zcmZuzOK%%D5GJ_~tsa&Y*J&H~fo%{q5t`UV5}-ifq-heM%^~i=E|6{$EY>1rue=Y3 zOWCy|pPXxN`2o@~m;Qm?dh1`{wLpRNC-l;y&WbqQ9mNVd}fPQF#j##RbG2Vc(D2splnQTz>J#N_WIHYOADh&=!J89THN?GaFB$C3?2M`UD;>?4bk7Y*=Y zoN;TytbstX(3?o3IfH?W_rNRaNWPC-9EYHnFyeeQjbJ)7aP3 zSbG-RI2T*)>tHOmV7I@NqvpoV2|2?oIaKSnNUiM?o9~xP?PX#Nu9z_4XF}u4wUe(o-pbv z)V10+>)nBrfQf(HB-c7sLn8ShY-&g&FQH~g|98|fCwuH7au@AI~_JsT#z5JQL zyMLgbIaj=6B043VaIu2)Z8> zK(S&9pg68y_}r){>z0LQpfTJC7Q!L|o|lVot5ColSGFM$ZFh4l1GwoP)};IZCQXpM z0$PU|@@Nn6G<-UTq^_vk%-;p)VgUqUH7K41Ga4XWdYV#G?=#?H#mvCPidRrAW2hD+ z(UdyZp(Vj*@eDJL^YP7B0^8U0_SZU=L~6huhulGp_#R+cG9SwRi=InQ8hlI2}p zM(rvJB&b|Lfk!+Ax{s#eF#adP{!%Q0@Tg5|(6$z#WqB7p$8)`gM32sbyakVPV??<; zCd&(HgQaW5izG_A+af(UbznSeuynGtEPhtYr~YwB58t$e!tmubzRE`Mw3~1CMOT^4 f-*s;7t(HLELo5ocX4}Soi)2|u$!w$$v#tLCvkY{& literal 0 HcmV?d00001 diff --git a/models/__pycache__/city.cpython-38.pyc b/models/__pycache__/city.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..9186101d01edc4c92ef4640443f89324eafd5210 GIT binary patch literal 1045 zcmZ8f&2AGh5VpO}{^h4FLIn<>TqB|8z_miqO67p45EU0+tj*dhQ;47!T0w-oR{8WrI-;QU-JKxOsW4D_UkmGM($KM$tKk#s0T5xy;>c#+y z2%@NBh6)Pbz_2n9LCFQD=;x+Yh9YciW+D-RuVtb#7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yu_@V@xqK+9GH_=-jX$&5HS@)eBGN6ddnH00znth3y_^ z2uiNN2Fi5zB{WW}ZN6x1Zc5i;+UL+yd07LtdJc)`T1Kn9ZSr=d`@BqIANCY{DV&tBEa42tZTm4q^y(Q{ zKJ1-ny9^WwIL!{vF6&d(hd@6;q3WX2QuL<0)mdi(3t#~KA~CgA7Wu$ AYXATM literal 0 HcmV?d00001 diff --git a/models/__pycache__/user.cpython-38.pyc b/models/__pycache__/user.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d9b6b23c6af068ec6120f22e9d7e4e8cd648f97b GIT binary patch literal 1108 zcmZ8g%}yIJ5VoED&kun^Rn#Bl8mS_OUaP95QhO?@pj>>hHftwY@a_hC10v#p1QMtA z+*jbz=jb!|+7qwPQ)f02AiSE-Gah^V&5ZZ3+f4|Jy+6Mvmn}m6qVah6V0-|vV*p7w zkyJ8GIfc2US<&LH!s8yrbx-?6z=K9-I^-d&`8q5j9u+Z$?I6>swSz;e%pF`!_J+*GyQx)QE2*^eP#sbiOjWJQQ*Z{K zD!nL57aY_kFQ?$^7^TxXuSz@1=NSfhJiN7Ge}SS1WJEZVlmnY1U$SFnYT4p}3RNV% zE679!KNydn*vY*eHvaY#yQ8`?lCezSY!CGITHh%9vcqGL1f&hpxgirOyRvs3@%|0* z2;YQyY&Z`~u-x8PbEB*(>n5W?H5sIX1$YLI$uaj)wRe}0%4f(tDi>O(W39eB|C>%T z>J$*M-0doB0 zoiCMbNMLh(yO=BEA|cQ##IWT&tMtTqshL_A9G~HQOI<8P(_0~K$-g(FSyiZ!nx3a) zS&csCX1Cl0e^n}R`gT-cv+W4U@668)GJ1j37yx0*?jbtvZ`{J$%d}8JxI_pzywIq3 zgg9BGdhH2?kW~iD!793oZC#mkszmL&LeyBd)mDSA-vj{8S4Em@7tP^Oo>fNjWRe?O zH@CSMp6W_9A#M)lSaa(_)702DyfJo@cc!!!!aT>=4Ln0_8zBN{gV>h<5%p*S(qDfa z+G8Hr@Udp+uxno7sn-B*bCt}_82$^)Txo+vGT2eaDr@k)yTqR8RA)0)oIfPTdk?ES hl_{Denj0RGY?vZR7rk2*_C3b8JphkJz_GK!)_;|z9H0OI literal 0 HcmV?d00001 diff --git a/models/base_model.py b/models/base_model.py index 9a86addb366..d259e3f5a86 100755 --- a/models/base_model.py +++ b/models/base_model.py @@ -3,7 +3,7 @@ Contains class BaseModel """ -from datetime import datetime +from datetime import datetime, timezone import models from os import getenv import sqlalchemy @@ -23,8 +23,8 @@ class BaseModel: """The BaseModel class from which future classes will be derived""" if models.storage_t == "db": id = Column(String(60), primary_key=True) - created_at = Column(DateTime, default=datetime.utcnow) - updated_at = Column(DateTime, default=datetime.utcnow) + created_at = Column(DateTime, default=datetime.now(timezone.utc)) + updated_at = Column(DateTime, default=datetime.now(timezone.utc)) def __init__(self, *args, **kwargs): """Initialization of the base model""" @@ -35,16 +35,16 @@ def __init__(self, *args, **kwargs): if kwargs.get("created_at", None) and type(self.created_at) is str: self.created_at = datetime.strptime(kwargs["created_at"], time) else: - self.created_at = datetime.utcnow() + self.created_at = datetime.now(timezone.utc) if kwargs.get("updated_at", None) and type(self.updated_at) is str: self.updated_at = datetime.strptime(kwargs["updated_at"], time) else: - self.updated_at = datetime.utcnow() + self.updated_at = datetime.now(timezone.utc) if kwargs.get("id", None) is None: self.id = str(uuid.uuid4()) else: self.id = str(uuid.uuid4()) - self.created_at = datetime.utcnow() + self.created_at = datetime.now(timezone.utc) self.updated_at = self.created_at def __str__(self): @@ -54,7 +54,7 @@ def __str__(self): def save(self): """updates the attribute 'updated_at' with the current datetime""" - self.updated_at = datetime.utcnow() + self.updated_at = datetime.now(timezone.utc) models.storage.new(self) models.storage.save() diff --git a/models/engine/__pycache__/__init__.cpython-38.pyc b/models/engine/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8933fbc5f31c5ae82b5783034a09af1918ac8370 GIT binary patch literal 146 zcmWIL<>g`k0>2aM(m?cM5P=LBfgA@QE@lA|DGb33nv8xc8Hzx{2;!Hyenx(7s(xyE zWnxlFzP@8-kyD;id~!~HUTS=qv3_oTN@`BAerjHNW?rg(e0*kJW=VX!UP0w84jZ6c OX-=vg$iUA)%m4tO<00Gt literal 0 HcmV?d00001 diff --git a/models/engine/__pycache__/db_storage.cpython-38.pyc b/models/engine/__pycache__/db_storage.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a9486e959b1152d271070fba188b26df276012f8 GIT binary patch literal 2855 zcma)8NpBoQ6z+X`#Ow=A8@dbxp3wu@EhvNiNAo5;JxY@k8OoOx9ZjFS4+S8-d2wrjhY5e@3&w2SAqK- zKTbXs_*j7^eg#4`U!yuTV%^uFH)A6)eN#u76f4ShiR-(Hcj9VN^J|K) z#4}0VuPfe-8%fh|D!v-GlD6Mgd@Y_$=KMLu8}Yn95Btx=^T~q0pk(#c$!kTVz~EZvM!20J%JnC&u31QR04Qdu7}Nw5P;9d3X!+(zOc zK^t%vNfk&4?bKt!*9tW82nf@_G@5Tv-8ZS>ThMH3QtO50J9L)X)On%%6Y&Qx!870yZbK7KfaKsX&-IZGy#c)ey$QVuy#>7my$!vc>(n_k3cWB2v#^d} ztk8&A*tD`^@JG3|Z67*?wrw8i;1({JxjJ0Bmx??{^9b)wj^YPw3oI7=Bh_^6wp7mIG`fL*#l zMCtd-y94PG5`o7Pav3%fxSM9U`s8(VqkR8zZC4-89qYb4Sr($VP9C%~Its}JQ#`iwwEX|KS(i=xuPwLB^ima&kXF|@O zG{z(xZMBs&!2q&K07b|Zgdk99kTBqkh=OS^!11IR#zML&drD{&=Dr1=LR#Q$LYhFO zxx)s^L?yWdYxrA0u0j)NP|dIa?92KB&^f)X4;xd6L4i}~BGMS`3SC?bsA-3Kp{oec z0S9Ba98jttC_UcGv)2RCG5DLX6P%XPmxekNzXF0YN=p;Y_%X9@EH6! zOR3oerd0Dt!|bh;{4mUtB+5NFpcifh=_V6i*8hKsI_27zdZ{Zq>=auFm*9Y12iZi= z<`hmG`gc6fqoU}cRle{FTt9^ff`sn%d6v9ZQA{;n)c4XX_j(Y2y$QljxdTVjpFx*@ z0J58?HD&^gzhQf-ce(Bq#OMV$RYANAOs?Vw^j6t0w~&LfY5ZhBp0x|iw+6(FMjUE_ z39R7~XK@x#p+aPOs!0m}9Lkin5v5eN*^j#sXCzBWi9Dt?{5M|&B5UK~2BzfaP})FJ zM}mIUF_oEoRpLk=sz$~Kva()QzB4dLr&LOv3JacQH1#F~#z{2FDW}l*Z-=`UqN{P1 zWC!d@$Ae6}mC;GE*yYgy){AlcdqJM_Xk$M=VY+f9N2Jf{Y(th6>`NG#xLj*$IyKhO z;bzh6H26C(N!AE~bi5y9BB>Lyw;#mgv{E62W+5RZj))$|oUHN%e;>In67&^*4ap}+ zrU9Thm0>XG&^lrPh^t%p8g8pL<65p&v)u~E8J&w9BSku8d63PrUxp-yS0Hr_k+WkV z)^${z#T=clELk(-!4Rio-k0^UWEU?;>iQxZV-Z(ZC3TxQo(9DlE)!^KIoWF;u21Ts zBaKX``YCHrXoEQ1V#z?&QolJBEJIZ--Ay^(66%JBdlfFyy#cxa^fxg*iT8k5mJ3O@ S4Q=`=38ZBMvKYL7JJvs~Jh^)S literal 0 HcmV?d00001 diff --git a/models/engine/__pycache__/file_storage.cpython-38.pyc b/models/engine/__pycache__/file_storage.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a4a5ad827d81abcc47290b0f91b1365f7cd451ba GIT binary patch literal 2465 zcmZ`*U2oh(6rCB{Yp-`VA4{7mLV!Uf%|ewR6_9|mv}pyXf~7R73Kqz6c4iZA{E?2G zM6nzRsTGg#jKo9o*cW~WzhPdG;EBJ$3*0;2ZZ;u!G!Cz?<69PibHUl>tQaw$he5% z#k^ZLS`XrIAfTb~Q0zzI06c4>2n%d7ALT;!Y{_6QX`nIDSZEq(Y&3|_0PZsvM&E`z z{~U}U02lEYr@q0NZ$`wo_#8L6^^E!r-r)8#;@jNeO?W!o? z8Rc2pA7HjGE=(13z6*E$8JG(8eWxkcBXYzlG9t(Hgxn+FEq%+5j3cw6l{sQNEPuE5 zM#c`43zb>1%2*>$7An|190h5x(vzatlj9xa(V&R3G?a&45M-MpF(~qW&s3L#sbnWT z%8Ck+>k??iGvU56R7R0R7sRuiO3zADnKC>5)SP>|OoTiHESMi|F0BP=su z2y>`OyL5rN@GNJi7QF&-XD~%-;H@!T24{@v)ryYD2&(G}w2Z(4!W7UlDz*j{2ACP; z`?)A^pHD&3{0G3igQ(c{AV+Tv-!v>9B64db;(bL|o}01_e(vZV>P&h9=qz!b~^S+Y=brecelH;^4< z_QWlaNd~7+*-zagqcD#x=rK+hC6CE_CrFFi#M`n`ru+P90W=7gE;id0=W%dyEAWnw`nlkX+FJyQeax3TF3K{aBE4$p&T z=Hb408*Vk34rBVl-*?O#?Nh(;T6*(p+uvNP5S^4n* zR0ISQ;acu_i72)+?hP|JCG1hUb*>Cx`yi=WN~v6eX?s-D`24yp(7asSgMeJCKP%^_ zvDdvl3dd=`*RBP`4FZtIJ&?pewS(ZvUKrQ%tLz})*&qmNeqaH}%VlA@Uj; zRKKaUXf#oFBq|8L9~S&^gwSX*#q${bLQvfDQ2br(ymJWJ5>u literal 0 HcmV?d00001 diff --git a/tests/__pycache__/test_console.cpython-38.pyc b/tests/__pycache__/test_console.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..086cbe8efad846f33de0333f68179d90a84ef6e6 GIT binary patch literal 1887 zcmcIl%Z}7W6s_{3ZF+imghz-3k`)l4Bhmw5!vaMx9bOv?iOI&Bl5thfbmMjnRb|jv z!wRue%M^@ z4rOKXaitTpC6c1dwN5sKHqfnQDgKm&?!JduBrVV`J{~mgz^AW+5d<(0j1RFr?!O^f zzylsa8S)N~pzQFNAA>UDU5LG6PaKNV42CZJNUFpDgmJZ*a9Pw-0SL`lR*4+7C|hg= zg}4Wg50wzUA$d71T$GQ6!_BoVITdSSb0>ew<=Wk`TCdhwQOZiN7dO|CR_!dC zqqi5ao1s7K#SQ0GAr5AoKt`P^y&mn+F7-Y(zad-0xkLuv^zfe^)C~;X9ux*WvYRDm zrcfNs*`?Fn(J53;svzNrI)(fJO}d*v-JDMcd@kS<_oG&Ri8Ee zD>Oj6#L$ULa?~zr*#y}0nsWbH$h|!e6iq?VL30(OCoY*Vv*)6oN?wCFA+@woAj!13 zurOK)!F7_)hu>_pM*Ayl#27eY%ywJJZm3#VzZBJsDiqCODqF4XuVyV2 z^w2`N2rD#_PdwCF;GO)s+P>!Ff1~i>db&Q8Q%DX-a(7dG#+^2oj*cE-Qk{g2^+R%jp4#sXTIoyosZ&@H4-)<%K2hMP81VK#Ox8r{TF{1vF literal 0 HcmV?d00001 diff --git a/tests/test_models/__pycache__/__init__.cpython-38.pyc b/tests/test_models/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a84d53bbe681b408a87e2aa944321c9aa3e202e8 GIT binary patch literal 150 zcmWIL<>g`k0>2aM(m?cM5P=LBfgA@QE@lA|DGb33nv8xc8Hzx{2;!Huenx(7s(xyE zWnxlFzP@8-kyD;id~!~HUTS=qv3^NvaY-?ljL*$aNzEzNkB`sH%PfhH*DI*J#bE;! OEX_%^0~z`mh#3GxLnFKZ literal 0 HcmV?d00001 diff --git a/tests/test_models/__pycache__/test_amenity.cpython-38.pyc b/tests/test_models/__pycache__/test_amenity.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ce900fb05addefc504db45a76faaa72874772e00 GIT binary patch literal 4649 zcmb_g%W@mX6`dCb0}!NWndOKsDH=P5EhG}@vhz@6*%tM(l`12yh+YIP*VGWxAVC5% zP&DS2a%bEjYEzJ2cLdvD{r<>jh{PxHV3 z={#Sxtp8DE_T!;)507{bkytG&u@k3f_wAN#Q`zk~El0oImW#L7bNgP)(|x60sqeS^ zVqCdZ*5iU!z`XrRtMZkV_(}Pdm6TbqUp;nPOK1s_3R)^fOD%DqT8(P{Vf8_l%D9_~ zQ0}pCn+dtqXK7a+KFr!8Z1-Xzn5g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&r<(%!l|L&-uS>P?-RcI8Ltz<(OD z{y-ig$Dxp-JQ{+0d8et6RvE{qecmTfQu!u~tBQ~rk9S!l`8x#TpGeSITZC;z!=}#% zX+b2JfVPTMW!0I>5DjRP;d79Yy(VniN5!yB!qHI}1-I-I_terEBDpuTNuR(0RJgB< zoC9Ao5ToHF-#v0ixaAyF_+9h|Bjl8(|Cz2Q&bY4cEna?yHiCRVO1f>NnA*vOhI2$r zYDIn>^TY5(SMG%ao(&k+$P0Bj5^;nSUGpx&OEOi7itrFM8x=#*(f}5a-GLlrlCa2 za(oyj0H0TicU~u66^t?_x@d-T*77l#_6`3+AweFmEe2#yY}m;K?hb6=tXqcERF`BG z1S;506MNEDnr}0sa1SV*_#@m43Omz$7>V}sw7s|?6c(f#!t=N{WIAeTYjP%sJY`AP z;aPuTeY*OiCh-M=&E#w}| z+4vGA<>Gj88l?i1I&`De;|sgB0vQ!SkDLJ~)D}(m_MGX=7QV+g9Vslwvwdx}HG9pz zV&~UiYcliAIb*q)W^%MBUo}T7u_=q#hd-jrs5w|8hcbs_4YVDqsw=p&Sfx<@&zh(huQ{mq(585RSv|s)Q5+R8{lK3l$M!~l&Mg@0GYW@W+sDDiGyc$RmAU>J5?_R$7GcJC(!vFvP literal 0 HcmV?d00001 diff --git a/tests/test_models/__pycache__/test_base_model.cpython-38.pyc b/tests/test_models/__pycache__/test_base_model.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ceba1a6d17709f34083380dceec2af43703d8696 GIT binary patch literal 5832 zcma)ATXWmS6~+P}2wtSfj*{4J(jaM+hHfS2R*&P{94i-R+Hi7h8>R^iaaR&)5}`=Y18lQ0;DL*Ga&~Dd&6S)obP<+EIwLV zsyq1I{M%o*x6U}uKdEx`=c953m-;;fcRCJd+#RqX>#(8QaT(RUf!FcO-S7D3Ug-qp zUhP!PJ?w(rPd{C>UP=rqjT=``PRc!dXFIXn5hhiD0lmixH( zfzzr@E`BJKj;;qTOP-Kg_x}x-{nK&qL)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wI-nl=uaq_Zt!vTc^>QH)xrtAQgxhBdiusVJvv#V$NbUn)@># z_0=1Z0zDK@I_wQ-MZ-Dbx3H`!eg}C5HF1l8`8^2())&+|53Gv@tl^R%trCC2+|z*l zlC-8!uz*d?p8}1DJ&MV{n7Y?fsCV(x*r7n zP_BoW=&z3Z%d1Z5G`i|MOS=PZj&9>X!PP)yoW)xr?~UA=3XaNK2wVz_#pS==Snl0e zW*f_2uPr}bTYj>#yd@|p+T^iHt#WY9J>l3$psti3?e!3pDr@jw}wx=IY=e4zRR+#UZ$QT<(f z?ZsguesS1rgcib2u(MbpL6ou3eT`PbxAixvsY9E_<{E9?O;@2eBNZcmzki;KJJSH)A#kh32fdQIpDlIBqqA052Zzh@%G}f52 zD^tB9NGF>jjU5;45wo(1f4;D64D9c3v literal 0 HcmV?d00001 diff --git a/tests/test_models/__pycache__/test_place.cpython-38.pyc b/tests/test_models/__pycache__/test_place.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d0c87167e7fcdd297ce755ed3b23890d021eb7c2 GIT binary patch literal 8023 zcmc&(OLH9674Fx}^o$;sWnpB4abpm8c*riE#$aM>V{j5CPHa+PDAH-oy^=9wzPfc6SFh!^ zy}HNm3avuBSTAOJrFx0={JJl_t#ZBmktK?v^o=D-(%-7wbL%rG@kJRW<*Z~@xVNlo zC3(JbwcF8Avl9n;QwFzXtZ%lWhP>8o#6hDK#j%Vl-(iGS)lPj8X{noSS;Ir2M|!v^ zUx{M*Nms~LgY?FKE*>u9KfVSbt-6hQVor5edcqOzH`YD7UJ#xrd}Gy%X3UrikF@TK zikLxpS_l*YuFgn;79jlk*oNRmmsut-`0+{w%k2u*9tvhqjx7+z9n_g?*;2!HRvkPG=f^S zkd^>rPd0Q~*^s&|+iOzAX@R>;E6sSl-)Yc@(h@@#t^+)`(TX2fY8E|yf9c$2w=K`f zjh$#sbkBXzR98Az!bYpxk>QuGpW|*=hHXMSHuv1tYHug4#8Q9SyGk}&q**u+mYXb3 z;I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aDijpWRlQ6iAn^u?izMD7LEcwg zCUK3#brK(w_$i4RiJK6q--j!u?lHFQX79%O*a7JlX?;P0&X1}=Vq{jn<5cLYctM@U zXCNpQ>id2<`>XiFKOB)t{)|7PNWVH~hV9^9(Tq*MjM7n)Yg%2y=U?+h(&Xumk(wYu r4mb4)oU72`Y%8}qZFs5wp84eQKJ~?)U_EaZj=@L9&RmP`;w%3Ho}szl literal 0 HcmV?d00001 diff --git a/tests/test_models/__pycache__/test_review.cpython-38.pyc b/tests/test_models/__pycache__/test_review.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4988efde613952ecf305f68065a3d3397984fdc6 GIT binary patch literal 5204 zcmcgwTW=f372X?{OG=hyTWziS(oGZ9W@5`m+$65*8ji1V0keVa04berINRm8_yb5E48)m$P&E&Nt_r;Wx*Q)g64A z|N7_pKTbN%zo|0$2~fF(pL_+uoR-5}=5^hk+j3nh`(3Z)nWx|K@eI0tFK7j(uhOmb z!d6)7Ra;e~7qucDY}Q(}2M!Ba^{vCIJld@9`mH&%M68CETG=ws{3lMMUaZvb9`jcn{`zj-mT|kAO37vYJ1o&@xH@8~;;Pf*O;kc*6j7?(P9=YoGu~~J z;^fCi(Ar%25-MG8)12S(Bs&d>f~9RW-OL!tIOkjJ+}L^duzK`*6>4R zvdSI&>`IRp_;&ygB zX?OFCC$FwuF%ub?^aycj%XYBU{+6ywuDCf}g?Q z5(?P83wC*bcX!-v_Z@8Z+}(3`fX6$3+uIDtc6&aU7y_GWafzk@DyfRg<&9PrxAP2; z^^B#yzW4R@)u;QeuDl#{xGENBwFOz@`wRE;0c_XCPD=xFA#x$(i)7N*smMCnbJ>zyu_dXA_p)V-I3w5#V;uF`H|2ix~`AbEFPS7-!S zOK>^pDq{{Sj$tkOEJ2@;N>c75&DuP%`}-L*q&e{3ygTpKUGG1|Co_;A_5KfPgd1Zc z(3~Yj4yDT>MiIxcm%=jo2%;GSi4)Lm3L=^~O@b&qf!PO#@7c6k;LhWPS>UeH`X7(n z(CYsjWC}eZ&WOSvqXMcr%H1Sq>Je3mx+>vIg@cZ?){Dy0dG)}?xAevO3>NT)g-|fNuukPk59#bYro60eOD|) zVHQElIy)7ecr1bju!~s13z8srJYrnnExwm`?-}6-MDD{WNo(L zAU-rI;um;`h(t`{0}{U^@ga#BmYp#KDR*dM))*r4VFw}lnAU1nau;A)h8;e@6hh=o zYxo)W_!xz4XVbase0v|x5y4^`u5#G{)8HoI9uc&cojteYT%an$e(=r(??Y}5h8t0VCyg)!Xn8itb#5JbrZcOIl%f-H_gd}fGdV@^j&lBGRP=Oh`@ zKGE|@Lhjr47-qo7Q>3%o6*R9nOX3`fk4VrN5f@2}Sz}7%)CD<;Mf@a*$PHZ2tp`!n zeob#19aA6Tz%BgbR}hmajZJ7;CL|(Vsg&tVSf(@8GM$Oabf(4@*m0BAEW+w1bbZXp z;wOdyl#xvymjhI!)f+0_M?pEe&X9)6xHRkNh;+N&9e+`SSJiv<%kBWKR|UBtFyCMO}_9WKy~dso=QG2!XqI zv9$81%PYOhE9~jYS8FSe)>fXZuB?k&*p~IKSEzIqVrW6}CAAn=K`}x5aLswue4a;TAMAoOYUj6IR8G2*%zm5 zn*Z4{>D&0?o1I4dW~bQ*EsVdSZLgBJN5a7Odz2c!y~@x+b!a2qEIg5c2Ys)hB#C;& zVsQ7=EE3Q`MkpH45VTwI35l4*uSu+txIuyv1M!f=BNF7vC#D@IeV5TeFBnr$(icTh z&3xygIYGURV|D_{^#m=>1{AZQ6E+~PKEt10_CFY#(42yrjs{sr(blYEh-fo+plDJ_ hGxT9A($NijwYy0Zn*W}HU>;{VLVjbPp?~tye*xgjFnIs~ literal 0 HcmV?d00001 diff --git a/tests/test_models/__pycache__/test_state.cpython-38.pyc b/tests/test_models/__pycache__/test_state.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..42bbb3b7799f0c8f0090dd175c612455c905525a GIT binary patch literal 4545 zcmb_g&2k&Z5#B#679dE`GAj|4DBjqnE!Yz2vYjf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v4(L)qkqb)ribK^8IlCX3~!^LoIPi3g37oq>(I#H_Pl*$hLgHCSNCn51;+Fm z`O=8XX6-JyF*$l<&?XCnoR^F`F=M!W&sK06LK#Eb8RtvX@)A*lWKIMmJ<)FyKp(2^rS zJ68m)IG}(TxzCB`|2rzV=XYPZ`;NJ7c?$QfJy#hgMJ|iEJKmGBi2-nCNLJq7^>^@P z;7L_{g8s@5_-+4FQ)k||ZtnU)woX#uvK+H+8`m|HZ$#Gdn(8h^MKD#-&I#Am~t^-~0LLr4AwtO_+$6oT_lpWS zYVaYolrfJ9$p1ir;TmjI12Bzhd_e61c5lV8@r3G7l}|b1jJj-Fsn}+@aE&g#D(~Q0 zP4Oq651eSPOxyDdcCIwKU_VQGBW@B#qd>vcNDMfOIwI{))S3v6`<@W^6p<~j{`K-| z|MDt(u=?ft>R0Ql_t#cCfyUXrbH=8>^#bE_a`IuvJfaoS@4-mrv zLaav~Kp$_+K?-&}%Gmb|+9osiGxGt(I%P`FAl&#oP&lKe9K$Fbso@A;EdEB$`|If9 zi`_=_Vz=2STL?cSk=KaaAz}j7A5d!e_SQ$+)McA0%tI3zuY$gRf=QCuk^RDIPZg~e z9L+{uG|(?dQt@*l5s_aIStoLx2xV2`29e(rp=c=nL}aRzY3h6#9W=^(G@{fw48v;v zUkDcj^*2t~btq>Rv_l)5jZ~*>X0!GP9{}xlDVr3Y0hg`k0>2aM(m?cM5P=LBfgA@QE@lA|DGb33nv8xc8Hzx{2;!H!enx(7s(xyE zWnxlFzP@8-kyD;id~!~HUTS=qv3^NvaY-?ljL*$aNzH+>Q}fa@^HTNW<1_OzOXB18 V3My}L*Z>uj=A_zzEcgt>3;;KyD2xCA literal 0 HcmV?d00001 diff --git a/tests/test_models/test_engine/__pycache__/test_db_storage.cpython-38.pyc b/tests/test_models/test_engine/__pycache__/test_db_storage.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0596e6136ce443d4b4ab6cfabc6ce6418d04bd05 GIT binary patch literal 4257 zc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G5^&{Sw_|6~;2Cy7uDhh5OpUeneQWOu@Q-M04TpkI>&Pzs3Q!6$x`v|??qStZsKBBo#OzIB6 zE|mGYv8KQy$4*h%c_t2-5KJ6t`^Q)vLL4=()en%s?wy68CS zM#;Wd!~zQF33csLTxh5x^lP?}FM=q-=`0J&1q%qTxOoJ$ z-v37b*ckO%MTbe!ZFD&8s^oBcB)Xa;6fKH7Ml1*^6nBfY3d$PI=u8V>mt%yjm(?{U8!r1ldi;J_|2 zFyvw(cW3UHoD6qL$L^Rc4R^|E8EUBLg&E)m=Z!oleVq_9EV6C)9O5W?7My;d&V@+VlM4o0s= z+G{D^kvfq5O~Ou>5~R=IElI>xYG}7o?O+0i-C9@#!E1EKm5paSE*WMFXP==~kk8N| z5_?7Yo30*~5=>^6)zI|C;9sJXq!fmTq`wO?7ja%fmKU<~Y_LL;J4P(JPH{;NVC>WX ziHm|u@MkOJ-G;v_;Lq6wci_t#dTj^!Hv?Z@+XG+zkhX?@-FmtN1^D2PIPt+^aA1MM zz+Bm*vCbThwI3c>=;xr{SE{sM9@@z7Lsg;Zv1flXzgrrX_N&;83<=$EEACK<5b^hJC!+liai~pR{`SwzOZoAnDS``6NnQr{?5T#0Hs@Ld=J_LCZ5? zkwVNOD+f3h7MY-XwF^bsL)nF(q)+@2CY~!EwpwKKMXEVJszYR?&kp9>fj%{=+{6cn z;+@rePSBN6eUn=H7*bb9H9h(&VZJoz!>0)IeZqWr7&pUyRNQ=q7?0J*8=LtiA%0H- z+PM_xXvPo8m<(=>>O%tiHs)g@s9EJn(CF|wW`xZ52CZEZ{;pdEb0IjJ{!< Date: Sun, 4 Aug 2024 23:48:37 +0300 Subject: [PATCH 02/36] added or modified a file --- api/__init__.py | 0 api/__pycache__/__init__.cpython-38.pyc | Bin 0 -> 136 bytes api/v1/__init__.py | 0 api/v1/__pycache__/__init__.cpython-38.pyc | Bin 0 -> 139 bytes api/v1/__pycache__/app.cpython-38.pyc | Bin 0 -> 717 bytes api/v1/app.py | 28 ++++++++++++++++++ api/v1/views/__init__.py | 8 +++++ .../views/__pycache__/__init__.cpython-38.pyc | Bin 0 -> 350 bytes api/v1/views/__pycache__/index.cpython-38.pyc | Bin 0 -> 526 bytes api/v1/views/index.py | 10 +++++++ git_task.sh | 4 +++ models/__pycache__/__init__.cpython-38.pyc | Bin 439 -> 439 bytes models/__pycache__/amenity.cpython-38.pyc | Bin 939 -> 939 bytes models/__pycache__/base_model.cpython-38.pyc | Bin 2553 -> 2553 bytes models/__pycache__/city.cpython-38.pyc | Bin 1045 -> 1045 bytes models/__pycache__/place.cpython-38.pyc | Bin 2538 -> 2538 bytes models/__pycache__/review.cpython-38.pyc | Bin 1011 -> 1011 bytes models/__pycache__/state.cpython-38.pyc | Bin 1364 -> 1364 bytes models/__pycache__/user.cpython-38.pyc | Bin 1108 -> 1108 bytes .../__pycache__/db_storage.cpython-38.pyc | Bin 2855 -> 2855 bytes 20 files changed, 50 insertions(+) create mode 100644 api/__init__.py create mode 100644 api/__pycache__/__init__.cpython-38.pyc create mode 100644 api/v1/__init__.py create mode 100644 api/v1/__pycache__/__init__.cpython-38.pyc create mode 100644 api/v1/__pycache__/app.cpython-38.pyc create mode 100644 api/v1/app.py create mode 100644 api/v1/views/__init__.py create mode 100644 api/v1/views/__pycache__/__init__.cpython-38.pyc create mode 100644 api/v1/views/__pycache__/index.cpython-38.pyc create mode 100644 api/v1/views/index.py create mode 100755 git_task.sh diff --git a/api/__init__.py b/api/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/api/__pycache__/__init__.cpython-38.pyc b/api/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..5ec23806c99d68c6db73f39c9a8651939b18af71 GIT binary patch literal 136 zcmWIL<>g`kf{^R$(?IlN5P=LBfgA@QE@lA|DGb33nv8xc8Hzx{2;!Hnenx(7s(xyE zWnxlFzP@8-kyD;id~!~HUTS=qv3_Dfrha^UW?p7Ve7s&kg`kg4$>6(?IlN5P=LBfgA@QE@lA|DGb33nv8xc8Hzx{2;!H4enx(7s(xyE zWnxlFzP@8-kyD;id~!~HUTS=qv3_Dfrhb{BetdjpUS>&ryk0@&Ee@O9{FKt1R6CGK IpMjVG0K#e?3IG5A literal 0 HcmV?d00001 diff --git a/api/v1/__pycache__/app.cpython-38.pyc b/api/v1/__pycache__/app.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c7431ca2bc14b990a4dd85391eb5c2ded7474938 GIT binary patch literal 717 zcmYjPy>HV%6u&!vJ8{xdv1g5t5-L`N+908_q!kUz3F+kKUK6*r&pKb+kF^M~ure^U zBNP7$vsV`Q7npeGF!Y`7ecyY(_w4sc5)-7Kzki&6V1)d##$)o(IKW$fLna9)l1i4- zf^kNz?&MD4a<|jn+$((UceUmWb_pOW$J?bA1TT3?RRsu~q( zR*niKH#z)4*knvwuZyA*)JExa1*k@tE1C?hYBc;67$}?hlG+#l$?CWj@)~d5M`p-9 zeIVGAU{5+9Gwqq)dZToQ__Xc_0&Bgl& zZ_?~fx+Q7X0%5Aw_NTCj%CrD{?jU;pM8hhp4QO$eZ=ljyY51OjRNHX`W-L`{;M#QK v=pI(kcA>4KH)Xe}M=b2>zubPoR~A-1Lgv!`_OOt}4q9$VUFx!shTZ)KV6(1R literal 0 HcmV?d00001 diff --git a/api/v1/app.py b/api/v1/app.py new file mode 100644 index 00000000000..0fde3ff8bfe --- /dev/null +++ b/api/v1/app.py @@ -0,0 +1,28 @@ +#!/usr/bin/python3 +"""Flask app main module""" +from flask import Flask +from models import storage +from api.v1.views import app_views +from os import getenv + +app = Flask(__name__) + +app.register_blueprint(app_views) + + +@app.teardown_appcontext +def shutdown(exception=None): + storage.close() + + +if __name__ == "__main__": + HBNB_API_HOST = "0.0.0.0" + HBNB_API_PORT = 5000 + + if getenv("HBNB_API_HOST"): + HBNB_API_HOST = getenv("HBNB_API_HOST") + + if getenv("HBNB_API_PORT"): + HBNB_API_PORT = getenv("HBNB_API_PORT") + + app.run(host=HBNB_API_HOST, port=HBNB_API_PORT, threaded=True) diff --git a/api/v1/views/__init__.py b/api/v1/views/__init__.py new file mode 100644 index 00000000000..7c1d711594d --- /dev/null +++ b/api/v1/views/__init__.py @@ -0,0 +1,8 @@ +#!/usr/bin/python3 +"""initialize a blueprint""" +from flask import Blueprint +from api.v1.views.index import * + + +app_views = Blueprint("app_views", __name__, url_prefix='/api/v1') +register_routes(app_views) diff --git a/api/v1/views/__pycache__/__init__.cpython-38.pyc b/api/v1/views/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ee2db3629f4292799b2c379a2aa3ea8c8ea9eaed GIT binary patch literal 350 zcmYjMJ5Iwu5Z(1Bb|L~21$Ej`comSS5DGp34bZq5ZL*WFV*SzjL*ka2gHUl2F5s31 zu0X}u0*R64&Aj9?6GpcDeA~QJ{OHMl^NB3U%QFJS5~jFv3{RcJ;eGBJ_l}{X zJoJ>WMlWvS;|Tp{PTk;^&BOLYXS&kT=oV*kwlXyqR%g{0>9INQ#_?Z;2tVz{vM8X@ z_*AxmkcAe_f*OCp|UZ%OK4PNzElp%q~4|wPv@*f`EV2=O* literal 0 HcmV?d00001 diff --git a/api/v1/views/__pycache__/index.cpython-38.pyc b/api/v1/views/__pycache__/index.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..9284f713405b746c0efd2d257e6f3b4f753aece0 GIT binary patch literal 526 zcmZ8dJx{|h5Ve!EDWw%mObn5jvNS?ntBQ{isSFiM7b}h3){w@L?G#$U)cz0{JMn+K zvViypOq^3e3n$$>oqhM--Q6^sbp-bL{yI9u2))^4*BnUBz|}DTMFT`Jby7Ta1`bBl zrQQk+Tw3X)u(}AOC^S=n7zKL5f;i8~jI;Y-m=-LTJkuY*f!5ggw@PGuG*3YB*Q}BY zehIFQ03OjZsJ(z5bysMKpD;zBfbh$lK-832J z`bt`{HIh{bC49A`iI}p8jpy-@is+oni|m3VsmK_awWB!a(d;y`>!^rlls&Zaxv7tt zCL7k8Rkf_hS)52V=1Mb3HV0{SQjx@|>bAD^AvTrrH+0P2&!v>KG~21952-o$M`s_E x2Y_%5%YBHw&@(TLbxY1#XDVosvaTJuB=ekx`wi6+dhh@M literal 0 HcmV?d00001 diff --git a/api/v1/views/index.py b/api/v1/views/index.py new file mode 100644 index 00000000000..1b2ea206053 --- /dev/null +++ b/api/v1/views/index.py @@ -0,0 +1,10 @@ +#!/usr/bin/python3 +"""routes of the app_view blueprint""" +# from api.v1.views import app_views avoid circular import +from flask import jsonify + + +def register_routes(app_views): + @app_views.route("/status") + def get_status(): + return jsonify({"status": "OK"}) diff --git a/git_task.sh b/git_task.sh new file mode 100755 index 00000000000..36e35474a0a --- /dev/null +++ b/git_task.sh @@ -0,0 +1,4 @@ +#!/usr/bin/bash +git add . +git commit -m "added or modified a file" +git push diff --git a/models/__pycache__/__init__.cpython-38.pyc b/models/__pycache__/__init__.cpython-38.pyc index 6b416f985fa114750953278d74931c4290dd47d6..5a210c92e9ff575ef13302a3ca9aecbbdba62275 100644 GIT binary patch delta 55 zcmdnayq%dVl$V!_0SLC;n#i@A@z%s+QH(5;6&W=}S%HGL*osnf@)J{5G8BOn6>&|D HXN&*ktt?^%iWji~iKxl3%zgk2bqg>6 diff --git a/models/__pycache__/base_model.cpython-38.pyc b/models/__pycache__/base_model.cpython-38.pyc index b3c16125f08bbbd738ca3338d2627ebfec285569..f639bfffc58000a725ee5c2f21281dd083a756fa 100644 GIT binary patch delta 293 zcmew<{8N}al$V!_0SMx+uiwc1f|>EwTC{SV`XGin;gY1r>F`P(PSzDX}-mgms%d5l9^nBV$4kTIqI4qeOe$jY$>TZ zsU@jJ*bFwD9K)f)s5-fkL!D7`@=6XzO=XZi4G^INA`C!;A&5Y@6XLGP!koGSCLkFm o5Wx&0G$#je25XoCnYUP+5{pxBvE?Uar2<_C3Ij|NPIKx30HWbu`)8MPL5)iQ&a(pXfhRnG~eRLOD&I2$xJRmF=i(F9CZzlK24Aswv^PI z)RNR9Yz7-lj^R*YRGHk!q0Xo=c_oLVrV>b>I*8B)5&9s)07NLD5{i?BIduh$L4r&m nf*C|;Ob*}-)-VAwZ?QNf7N_1~%TLNm1-cFt2AC$C=F|fKu<|(t diff --git a/models/__pycache__/city.cpython-38.pyc b/models/__pycache__/city.cpython-38.pyc index 9186101d01edc4c92ef4640443f89324eafd5210..61cf0a11110fd711245ae31813f3b6f9d55ded5f 100644 GIT binary patch delta 32 mcmbQrF_nWml$V!_0SMx+uiwZm$;=ovS(SMqB@0A3mg00000 diff --git a/models/engine/__pycache__/db_storage.cpython-38.pyc b/models/engine/__pycache__/db_storage.cpython-38.pyc index a9486e959b1152d271070fba188b26df276012f8..eb02fb993bcd4c973c83e5a5c59ab71e44188a2a 100644 GIT binary patch delta 602 zcmZXS%SyvQ6o!pylQzAen`$G~T2QRLD7X<3d;>S)W;P*Bj}T3oawhb$a;tXXBB1C4 zSh^DN72LXVA@mh|3Fjn1i)Qg<&VT;-=faE&<3i>%m(%9NXM8@tWNu`M1$S~oD!#tS z1L%iqHspgX;cn+$=mhSaJt!UPv()L zaO1}n`t@K_xmqI^Q!LMQZGR#~#+kU_U3sj8NlF_W@Bz2}q)=H8uGI&dEx@2_BN$%C zhystRDkjLVM5|~Pg6V@{It~^{%@MK$TA?b3tFtTz&W$tE@;w|f^+Z&**O@(IFiPE* zqD>*VUJr1aLT0ypl-`jlftRlDlMh!2WkQuuBh(2^!Y<)=c6>V@>Bi-r=u8#Y6KCfv zAN`xA3mw}Z;=E|G#aL{a9E@;`GR4ucStf2;WKWWkjg_urT7U{kxmZHz+0aLI#+Gez cU)&g`NDD@qE*{8}R?|zO#ysKQuD`UyZ^w3!(EtDd delta 602 zcmZXS%}T>S5XX&a(>DD;FBMa@R6#8Lyogc+-=G)q(o0Cw5u!;`W3Ld<8^0u$wOSqE+EtpuEiv*WVoAG2HMtaXOy-rMojK|#WIpeY*moH#~nsA0F(5mDQ zaPP+z_zV87a#ajmis?Fz<;|tgxKPgjP#(8KPY-PH04sm0P}uaZ6Au<&f$_jX(A~Zs z7HpRj7$d`)09Q=}!vo#0ZOoIJC1eP6LRk(@?_?M-rk@$6=i-DXPDEt6{lyvmY4UzE zYzo0~hk$h|ve@=KGzU57DnUbrK*fkjF!5U>MM`QDJlr+g6CnXap1KThG6_T=%gfO&Vgoy=Prp`QZ bW0)k(pQ@U8AWv#V+Y&M62>-hNQjfj?pp=-1 From f65eb7a37e2b58959c68cf357df557342d501a30 Mon Sep 17 00:00:00 2001 From: EgyAbdo10 Date: Sun, 4 Aug 2024 23:50:12 +0300 Subject: [PATCH 03/36] added or modified a file --- api/v1/app.py | 1 + api/v1/views/index.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/api/v1/app.py b/api/v1/app.py index 0fde3ff8bfe..071744b5ca1 100644 --- a/api/v1/app.py +++ b/api/v1/app.py @@ -12,6 +12,7 @@ @app.teardown_appcontext def shutdown(exception=None): + """close storage after every request""" storage.close() diff --git a/api/v1/views/index.py b/api/v1/views/index.py index 1b2ea206053..d84c92e9c99 100644 --- a/api/v1/views/index.py +++ b/api/v1/views/index.py @@ -5,6 +5,8 @@ def register_routes(app_views): + """register all routes of blueprint app_views""" @app_views.route("/status") def get_status(): + """return status OK""" return jsonify({"status": "OK"}) From d3a20e42c2a17c755e87bc6e97f18d3ec027d107 Mon Sep 17 00:00:00 2001 From: EgyAbdo10 Date: Mon, 5 Aug 2024 00:03:32 +0300 Subject: [PATCH 04/36] added or modified a file --- __pycache__/console.cpython-38.pyc | Bin 4485 -> 4485 bytes api/v1/views/index.py | 21 ++++++++ file.json | 2 +- .../__pycache__/db_storage.cpython-38.pyc | Bin 2855 -> 3596 bytes .../__pycache__/file_storage.cpython-38.pyc | Bin 2465 -> 3020 bytes models/engine/db_storage.py | 49 +++++++++++++++--- models/engine/file_storage.py | 23 +++++++- .../test_base_model.cpython-38.pyc | Bin 5832 -> 5832 bytes .../test_db_storage.cpython-38.pyc | Bin 4257 -> 3818 bytes .../test_file_storage.cpython-38.pyc | Bin 4837 -> 4837 bytes .../test_engine/test_db_storage.py | 43 ++++++++++----- 11 files changed, 115 insertions(+), 23 deletions(-) diff --git a/__pycache__/console.cpython-38.pyc b/__pycache__/console.cpython-38.pyc index f8b0a02fe375aeb2b0576d2065d403409c8b682e..fd3f789967f69e5d023945c599c6586ec1faa213 100644 GIT binary patch delta 20 acmZowZdK+E<>lpK0D}1I>o;;&2?78wI0XR! delta 20 acmZowZdK+E<>lpK00O@g>o#&%2?78vVg%p- diff --git a/api/v1/views/index.py b/api/v1/views/index.py index d84c92e9c99..bf9d0d262db 100644 --- a/api/v1/views/index.py +++ b/api/v1/views/index.py @@ -2,6 +2,18 @@ """routes of the app_view blueprint""" # from api.v1.views import app_views avoid circular import from flask import jsonify +from models import storage +from models.amenity import Amenity +from models.base_model import BaseModel, Base +from models.city import City +from models.place import Place +from models.review import Review +from models.state import State +from models.user import User + + +classes = {"Amenity": Amenity, "BaseModel": BaseModel, "City": City, + "Place": Place, "Review": Review, "State": State, "User": User} def register_routes(app_views): @@ -10,3 +22,12 @@ def register_routes(app_views): def get_status(): """return status OK""" return jsonify({"status": "OK"}) + + @app_views.route("/stats") + def get_stats(): + """get objects count""" + stats = {} + for cls_name, cls in classes.items(): + stats[cls_name] = storage.count(cls) + + return jsonify(stats) diff --git a/file.json b/file.json index aa1ff5bad2b..2b5279f858c 100644 --- a/file.json +++ b/file.json @@ -1 +1 @@ -{"Amenity.643d8420-fee2-4983-ab25-02a45a6f6376": {"id": "643d8420-fee2-4983-ab25-02a45a6f6376", "created_at": "2024-08-04T00:21:07.174971", "updated_at": "2024-08-04T00:21:07.174971", "__class__": "Amenity"}, "BaseModel.d5e08d32-f4de-4066-88af-14cb342c6a2d": {"id": "d5e08d32-f4de-4066-88af-14cb342c6a2d", "created_at": "2024-08-04T00:21:07.174982", "updated_at": "2024-08-04T00:21:07.174982", "__class__": "BaseModel"}, "City.e7357a36-f9d2-464b-8111-d93f5acaa58a": {"id": "e7357a36-f9d2-464b-8111-d93f5acaa58a", "created_at": "2024-08-04T00:21:07.174991", "updated_at": "2024-08-04T00:21:07.174991", "__class__": "City"}, "Place.c094f74f-63e7-4730-ba41-0cfc215c94ad": {"id": "c094f74f-63e7-4730-ba41-0cfc215c94ad", "created_at": "2024-08-04T00:21:07.175002", "updated_at": "2024-08-04T00:21:07.175002", "__class__": "Place"}, "Review.94d82cc8-2df1-4996-9dbd-b5c8f9521d56": {"id": "94d82cc8-2df1-4996-9dbd-b5c8f9521d56", "created_at": "2024-08-04T00:21:07.175014", "updated_at": "2024-08-04T00:21:07.175014", "__class__": "Review"}, "State.98401f04-3403-4f1a-9fc0-c0aa5dba180e": {"id": "98401f04-3403-4f1a-9fc0-c0aa5dba180e", "created_at": "2024-08-04T00:21:07.175051", "updated_at": "2024-08-04T00:21:07.175051", "__class__": "State"}, "User.756ad9dd-283c-461b-9916-8698c1589139": {"id": "756ad9dd-283c-461b-9916-8698c1589139", "created_at": "2024-08-04T00:21:07.175064", "updated_at": "2024-08-04T00:21:07.175064", "__class__": "User"}} \ No newline at end of file +{"Amenity.2d2d081b-0028-448e-a642-40b3df899ba9": {"id": "2d2d081b-0028-448e-a642-40b3df899ba9", "created_at": "2024-08-04T20:59:22.456133", "updated_at": "2024-08-04T20:59:22.456133", "__class__": "Amenity"}, "BaseModel.490fb2b7-70b8-4d02-889e-81b459569f80": {"id": "490fb2b7-70b8-4d02-889e-81b459569f80", "created_at": "2024-08-04T20:59:22.456144", "updated_at": "2024-08-04T20:59:22.456144", "__class__": "BaseModel"}, "City.b3d4862e-b248-4c97-a5b1-53dfc3902f78": {"id": "b3d4862e-b248-4c97-a5b1-53dfc3902f78", "created_at": "2024-08-04T20:59:22.456153", "updated_at": "2024-08-04T20:59:22.456153", "__class__": "City"}, "Place.1531e741-a4ea-4ff0-ba3a-a92f6d0f73ac": {"id": "1531e741-a4ea-4ff0-ba3a-a92f6d0f73ac", "created_at": "2024-08-04T20:59:22.456161", "updated_at": "2024-08-04T20:59:22.456161", "__class__": "Place"}, "Review.82ff04c8-85e4-45d6-b6ac-542c2f12b7ae": {"id": "82ff04c8-85e4-45d6-b6ac-542c2f12b7ae", "created_at": "2024-08-04T20:59:22.456168", "updated_at": "2024-08-04T20:59:22.456168", "__class__": "Review"}, "State.9f5a5bd8-9975-4da7-b63a-a299a8bd728a": {"id": "9f5a5bd8-9975-4da7-b63a-a299a8bd728a", "created_at": "2024-08-04T20:59:22.456175", "updated_at": "2024-08-04T20:59:22.456175", "__class__": "State"}, "User.90ce6f6e-611b-48dd-856f-f77e780ed296": {"id": "90ce6f6e-611b-48dd-856f-f77e780ed296", "created_at": "2024-08-04T20:59:22.456183", "updated_at": "2024-08-04T20:59:22.456183", "__class__": "User"}} \ No newline at end of file diff --git a/models/engine/__pycache__/db_storage.cpython-38.pyc b/models/engine/__pycache__/db_storage.cpython-38.pyc index eb02fb993bcd4c973c83e5a5c59ab71e44188a2a..eed0b8c5a76d43c8ceaf870c2d27e7a068014f6b 100644 GIT binary patch delta 1674 zcmZ`)&u<$=6rP#=;k9EsZb{?BjjDwfTDOqWav-WgB|^m^hx8E9L!@f8*%^m**4|`h zlM-t!3#lhcC8QORxFGw|swaeyxN?9qSELdDK@a=~i1&6~(WLEe_M5kFzxih7n|aRD z`EQr%U({+90@su0KXsngf3E*VX(#)Wy7XN34_&-5&u4h`A>FF*8m~VjTQhu?H=wQZ zGyE*HHQwZJ@i}1BIol-dg<{CI(chpRk|9eer@Ljjk4fas z5R)z&8wpA2BAL*!IUz$MHSUo6t)U5g)+DLfwVGsTrDn=fYnAMO*#Bm#bet>Mxzcf= zl+qI_OQ3R}c1y1nI_$5(M4&qiw=%S+0`>`k3m{;2oi`}_y8mPLyLofAtV==UD5fI|-uE)b5(I!Mn8-UsX zDQzYGb|hpAs0EzI=pBG-@F)xjGwB@M4z1HFo1+bg8aAu4Ds5zstie?mINI2~R{|;gM0kD_$$8Ay5UL0+K-hEv%B% z;Km}^BpByaV-C*kfPb#2n;3B*Ypv#>w zf(`JtkMhIOHj90`j09A`HLHUtIlWv1#@&MNst!PyL#wm}=f|WD8;ojq);7Upe@83> zEnrBQUg(AePwoZ^yvB_yP*O(W#n=K5Sc+?>>K>;Z-yW|yp7=7c%7VeVTd6rnn0 zjl8`Ip9DPWEI{E+1DwITO6Tcd_J4Z{UAoaO{$}O7SzLa9Y3@s0O`2Hx;oA5MSdWpjj7r+CB~(m hG?hRNODs8^J*u?eU%`{gwN`#+af+|3FneBE{SPyrf8YQB delta 927 zcmZWnPixdb6rai8+1+IO$70>K)}km)TZ80Db`xPb&Ee9{dWv$u3yiB=eg$zxU?NZ{ExP#QU?=C$3vY@B}|U z)@RF~s$VdEEWhC?JS6|%+J#|Sq0TP$%haXSUF28j03C$cq1r0)&V0V9wK4YP2mLCp z$shW=dL44bsH3H51wDJ((KAf(IuX+uPEn@UP|wcvb;3!88u$Pr6@Q2i^h4A!G6VKa zcFfFd7!8wZqX;Z(6m_i3%(To}LL18)L_RRDm+ah*nxPO(?wgmor64F)L6DOmXooEZ zmKIab=I20Du18JblQ!E5XdI=!0ZZW<$y!6?I$*A^vu$33$R3O-YYJc%h8P4unt=(P zz$1Xe*ugvQ%I(!O;o);OA2#JZi_J_zRIZ1V9%;p){4x+HlIA*SSdhQ0uBXC%D@t0e zI6cC>9seuH4H0g#Mfuu(bEQabQPyNB3^7=i3<-(H1PoU~60v^Z-fA-yA)OM4G{r*hUxHW{BeeQIt-%|x*K;1L=C(sl;^ z)ur%x_>uZteo@|a=DI2)A6GD?z*C@#T0KtZOH8N1H z5Q7+Hlh|BEcw_tqOu5xcpj^VQ_U3u`C)#m0-R4TDKh$T}LcxN<<~s1)P|ix<8O0E8 zD#qzEFPdS*xTPq!PjR*xvn_5P4-;t!Z6e2Wy%db|l6>Vl(3(AWcI-TO3&E%ED!;o+ Fe*s_i*T(<= diff --git a/models/engine/__pycache__/file_storage.cpython-38.pyc b/models/engine/__pycache__/file_storage.cpython-38.pyc index a4a5ad827d81abcc47290b0f91b1365f7cd451ba..c743cd3756acb7c6e2b80b813c0f051a28a9aecd 100644 GIT binary patch delta 730 zcmZ8f&2G~`5Z>9{xNZ_Vf>MkSl`8Rbs*0c$r%1>kAtQlO@212_W3+aW2(EIV zZ{S-`$rB)y2jB&G0v|bW0f|>&)&x|s>-lzOc4l|KPhK>?cJ1euRVFxI{`fRFu6(vV zxcUl1Nqi8*rviK?sLzMQFNs$60XE#Ws0!;0{Iak`?Tq*paY@v1t%{Clh$ik>f_cR4 zE|>6~L71JFo~^eyNsLihiR@QtAJ($F#FG>!glZn_@DpJ`C<006~bK@z% zR`zpkcNQ@Hy4B#g>i7{_yoZoNLgug_BSSq%A;jl)NlLrql%*^sA)E7JZ%6wnyFxr7 zs7EGTqc)dK+eb2yPTx^7h?H;!Dmr$=q3Yo2J-0Mdo9N`myZ-n@#>&D#X}xkjlJ8@e zD_du38ZK+7YiRz17J50u8=jyOR}l!Uf{n9G4LYr90lXwq{Udn?s{*PkRzs8JGlYWe zV{|UCy^)eRO<@72G+`;#8hixJ+QX`NFJ+h|A^(%VU+9610U6Wj^#Juwoaiu=K@vOB zz)9XnCw?n~;b16*6O8+DjNCQ#8Bw?JX4OW>*;q~r_7{2QCLZ)!41**u6$k%EUu|Qn zhZbw8H2pGEf#YnzwD<%53Q%;r&|7`BRy(_A?zXqEPu8)_%}Vt)G#jPag{ delta 183 zcmX>jzEGGil$V!_0SNp~tV_Gkv5_yBQOXC%O=XB;Oks#(N@0v*PGO2-$z+IPO%a$} z&8R3Yn8K67+rk*dmBN?8-@*{Zox&WSVI_jCUdg6GO|tfXH%Zs z%I3((w)r?)AS0vNWJwM?4oyZs5aOBa&*j9e2DGb49YknMUdE*;F9c+AFtRYSFtIRk aadEJ5aBy&Ou@`Xyg*AnWv?ssfdISJ)fh7e1 diff --git a/models/engine/db_storage.py b/models/engine/db_storage.py index b8e7d291e6f..0ba35cee01e 100755 --- a/models/engine/db_storage.py +++ b/models/engine/db_storage.py @@ -42,14 +42,26 @@ def __init__(self): def all(self, cls=None): """query on the current database session""" - new_dict = {} - for clss in classes: - if cls is None or cls is classes[clss] or cls is clss: - objs = self.__session.query(classes[clss]).all() + obj_dict = {} + if (cls is not None) and (cls in classes.keys()): + objs = self.__session.query(classes[cls]).all() + for obj in objs: + key = cls + "." + obj.id + obj_dict[key] = obj + + elif (cls is not None) and (cls in classes.values()): + objs = self.__session.query(cls).all() + for obj in objs: + key = cls.__name__ + "." + obj.id + # print(obj_dict) + obj_dict[key] = obj + else: + for table in classes.values(): + objs = self.__session.query(table).all() for obj in objs: - key = obj.__class__.__name__ + '.' + obj.id - new_dict[key] = obj - return (new_dict) + key = obj.__class__.__name__ + "." + obj.id + obj_dict[key] = obj + return obj_dict def new(self, obj): """add the object to the current database session""" @@ -74,3 +86,26 @@ def reload(self): def close(self): """call remove() method on the private session attribute""" self.__session.remove() + + def get(self, cls, id): + """gete a record from db""" + self.reload() + if cls in classes.values(): + result = self.__session().query(cls).filter_by(id=id).all() + if result == []: + return None + return result[0] + else: + return None + + def count(self, cls=None): + """count objects of the specified class""" + self.reload() + if cls in classes.values(): + count = self.__session.query(cls).count() + return count + elif not cls: + count = 0 + for clss in classes.values(): + count += self.__session.query(clss).count() + return count diff --git a/models/engine/file_storage.py b/models/engine/file_storage.py index c8cb8c1764d..187770116c3 100755 --- a/models/engine/file_storage.py +++ b/models/engine/file_storage.py @@ -55,7 +55,7 @@ def reload(self): jo = json.load(f) for key in jo: self.__objects[key] = classes[jo[key]["__class__"]](**jo[key]) - except: + except FileNotFoundError: pass def delete(self, obj=None): @@ -68,3 +68,24 @@ def delete(self, obj=None): def close(self): """call reload() method for deserializing the JSON file to objects""" self.reload() + + def get(self, cls, id): + """gete a record from db""" + if cls in classes.values(): + key = cls.__name__ + '.' + id + if key in self.__objects.keys(): + return self.__objects[key] + else: + return None + else: + return None + + def count(self, cls=None): + """count objects of the specified class""" + if cls in classes.values(): + obj_dict = self.all(cls) + count = len(obj_dict.values()) + return count + elif not cls: + count += len(self.__objects.values()) + return count diff --git a/tests/test_models/__pycache__/test_base_model.cpython-38.pyc b/tests/test_models/__pycache__/test_base_model.cpython-38.pyc index ceba1a6d17709f34083380dceec2af43703d8696..06f9dc041cc09ff3c075c40ed1f51d8daa425acc 100644 GIT binary patch delta 18 YcmX@1dqS5pl$V!_0SHPra_$!c04-buaR2}S delta 18 YcmX@1dqS5pl$V!_0SF2=a_$!c04+!aZ2$lO diff --git a/tests/test_models/test_engine/__pycache__/test_db_storage.cpython-38.pyc b/tests/test_models/test_engine/__pycache__/test_db_storage.cpython-38.pyc index 0596e6136ce443d4b4ab6cfabc6ce6418d04bd05..ff0746908311d679ea1130d860ad12330463babf 100644 GIT binary patch delta 1427 zcmZWp%a7Yc829IQoWyb7*%t(8py`%HT_MqyLsfdHRHOw26_O>0(#-6VtQ}Y5Nl~M$ za@bzDv6?GL$zRX|e+4JR3CWlCN-s#XEwxOrP6J}EuYNQt&aTc<|2O^h$KZXg2q!gW%fu>KJh-@@INC6i+gf{Tzt zz>GyBe?|NY``2lHQJ}?SzUanKZUBO8$HJMgyn&-@)4;y3H#t(Np1unlCqc}`n%JN6~$iqGwTz!Z0!cF=y6 zFm*a`MJ${r#g24!E%q)lO5)6|2A5tXKXxy`RY|UkKiwzL5x?ekua%LcHoYgM%sxz5 z+~@2fn!6IZI%}iDJe-UNs}$C;z3=V74e_b>iFlfqFlU_S%D+np19{UyHTe)KVNB&1gXZDlmmjQMQ_M=^J2JFCJYA zIBcpi*b}ZTV5tGV^`&+KGG~LEQnRp5=b3}dT%T44$z;sij1Ce;()MuNCif1y_9|1G z(J1MY%u=LP({5td*uI2y>)16ksHUwtC)LbTX{c?VNjiPLs(uaG`p`W_9}MaD>Q8Y_Q**N#wijnj zQp#8!&oW18GS2iQWt&oEHxNqba0XFF)>2NU`;{E0TYb3&3-DTH#5cj7_#tRK2Pd*c ADF6Tf literal 4257 zcmb_f%Wm987UjF&diW_h&X~@OlXQ}i@&FPeuW>BLh8NQ?B6}7D1_aerlDf?%+f{5U zV&s**8esll7Sd9i`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r3amZNhSfkeWUu8%0h(rWcqCYzS=XgKi%ph{H1`Lc!3*9w1xY|Im%YGvKWHATLCX( z?72Fk(OapegQ-F_89nFzP^3dH;(ed~WT~Q#G%4g;>&rAbN5Ps_kh=cul!mKwHKbOZ zc2lgQrJzGpd`3e1yXpuxFd9pF@@a4Qa9hxcp=u>3!%TcbZNDY)9SQPmbA8AcsCa-R z$*qtNS%MEivWq0BzWr`-rV(ESo#cA9pjGUIwIV1hqKAdD4DOHai29C0VbQ@I7vSdhCNPRa{C$k8BnbcRsaWhHRN_}x0k2ONTt#6UaAzLUbm131t z{tF56?W&^LkMO)oxNkry?JM= 1, "{:s} method needs a docstring".format(func[0])) - -class TestFileStorage(unittest.TestCase): - """Test the FileStorage class""" @unittest.skipIf(models.storage_t != 'db', "not testing db storage") - def test_all_returns_dict(self): - """Test that all returns a dictionaty""" - self.assertIs(type(models.storage.all()), dict) + def test_get(self): + """test get storage method""" + first_state_id = list(storage.all(State).values())[0].id + first_state_obj = storage.get(State, first_state_id) + self.assertTrue(type(first_state_obj) is State) + self.assertTrue(first_state_obj.id == first_state_id) @unittest.skipIf(models.storage_t != 'db', "not testing db storage") - def test_all_no_class(self): - """Test that all returns all rows when no class is passed""" + def test_count(self): + """count records in db""" + storage.reload() + count = storage.count() + self.assertTrue(len(storage.all()) == count) - @unittest.skipIf(models.storage_t != 'db', "not testing db storage") - def test_new(self): - """test that new adds an object to the database""" +# class TestFileStorage(unittest.TestCase): +# """Test the FileStorage class""" +# @unittest.skipIf(models.storage_t != 'db', "not testing db storage") +# def test_all_returns_dict(self): +# """Test that all returns a dictionaty""" +# self.assertIs(type(models.storage.all()), dict) - @unittest.skipIf(models.storage_t != 'db', "not testing db storage") - def test_save(self): - """Test that save properly saves objects to file.json""" +# @unittest.skipIf(models.storage_t != 'db', "not testing db storage") +# def test_all_no_class(self): +# """Test that all returns all rows when no class is passed""" + +# @unittest.skipIf(models.storage_t != 'db', "not testing db storage") +# def test_new(self): +# """test that new adds an object to the database""" + +# @unittest.skipIf(models.storage_t != 'db', "not testing db storage") +# def test_save(self): +# """Test that save properly saves objects to file.json""" From b59e0adef32f02692141a3f8a49f834a56024221 Mon Sep 17 00:00:00 2001 From: EgyAbdo10 Date: Mon, 5 Aug 2024 00:07:34 +0300 Subject: [PATCH 05/36] added or modified a file --- api/v1/__pycache__/app.cpython-38.pyc | Bin 717 -> 752 bytes .../views/__pycache__/__init__.cpython-38.pyc | Bin 350 -> 350 bytes api/v1/views/__pycache__/index.cpython-38.pyc | Bin 526 -> 1287 bytes api/v1/views/index.py | 2 +- 4 files changed, 1 insertion(+), 1 deletion(-) diff --git a/api/v1/__pycache__/app.cpython-38.pyc b/api/v1/__pycache__/app.cpython-38.pyc index c7431ca2bc14b990a4dd85391eb5c2ded7474938..13ff259d0f86f8a75ecbcfbc84a0dca5c1ca5418 100644 GIT binary patch delta 90 zcmX@h`hk@r7fApB delta 55 zcmeysdX|+pl$V!_0SGRVOuw|Ovl0bPCu zlaPQUG%+~MjKH9XO>SmZU}zy#1zcD zf!+lBHgx#}%sH8Wrq`fwVqTF;dO@|v0*{?I+G8XxaQ4Pe1v^e<$%G$qen)@>=Yh*80&P?VmmGqj0jH<_Y`M8;n%-n3dr)>IxnM zqY`ucc+M@HUTklj7jeYpM(=k0*wLi^=7fAK=$g|r04ccuUK4svUXpjKZ;cCjVU)(i zJU6aE+H<;2KGaL=9Ha)$bliscesOrp;!^r?G0e-Zt=yPLQZlLRv}BnSm_XTjR$#)e zschsRl^1gv=26C!3FuZF(ZVg2`QhaQ7)pF0#I$IOwv6$k|1y@l_~5i2kgzg;<5ILC zjJS_xaT(Km&3|HcV9hkE;nAw)QSlHwyWLgghG9~~VW{jQp!#03Qci|tFr&LP9rS=3 zR*HV;sy%ZaLZO5jPv5=^VO4E58RK%~s_HY(0P9HChHA`QLRXY7mBliYl#xm*@zm~Qdn+`RI{(d{wA411Oy8r+H delta 347 zcmYk0ze>bF5XNW!Bo|MERw8I4R%r#X5fRi%iG|ptS;9?D4s+z#Nfbn}@IWg;@&Z~~ z`4T?Gwps|jgtI~92IiZcnf-mtL;p!1pT%(>IDWq0hf4zB(>Jprx!L2SH5P;nP@pWu zSY}cHD%4ZR6b7e|gwG$F+XMFa56>#jeNI|txq%nvU)cfG6z;{XKwwg*?U&eEO!ncxWc9^ McKuzQo0bde7fVe;JOBUy diff --git a/api/v1/views/index.py b/api/v1/views/index.py index bf9d0d262db..b7cdb8ecd18 100644 --- a/api/v1/views/index.py +++ b/api/v1/views/index.py @@ -12,7 +12,7 @@ from models.user import User -classes = {"Amenity": Amenity, "BaseModel": BaseModel, "City": City, +classes = {"Amenity": Amenity, "City": City, "Place": Place, "Review": Review, "State": State, "User": User} From 5943957e36e7e4031fc467e76191fbb82ec41770 Mon Sep 17 00:00:00 2001 From: EgyAbdo10 Date: Mon, 5 Aug 2024 00:10:51 +0300 Subject: [PATCH 06/36] added or modified a file --- api/v1/views/__pycache__/index.cpython-38.pyc | Bin 1287 -> 1280 bytes api/v1/views/index.py | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api/v1/views/__pycache__/index.cpython-38.pyc b/api/v1/views/__pycache__/index.cpython-38.pyc index b399b1a4c317acd0cfea6151cffe02d0a8cc5ebe..6e4997003af4402ea8546e8370ac504910b7f39d 100644 GIT binary patch delta 90 zcmZqYYT(ii<>lpK0D``^>(fp$GcY^`agYH!kmCTv#gis#SMhSE@}}~q3Z@FDaL-|z axMc=2TM_H#5XR-qJS>b%3}E=5jRgSn&=9Wx delta 97 zcmZqRYUk1p<>lpK0D=W?)~7vWW?*;>;vfSKAjbiSi>FM~uHxrN Date: Mon, 5 Aug 2024 00:11:25 +0300 Subject: [PATCH 07/36] added or modified a file --- api/v1/views/__pycache__/index.cpython-38.pyc | Bin 1280 -> 1301 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/api/v1/views/__pycache__/index.cpython-38.pyc b/api/v1/views/__pycache__/index.cpython-38.pyc index 6e4997003af4402ea8546e8370ac504910b7f39d..ba037fa79bafd13fe3070eafb2ef69880b680de2 100644 GIT binary patch delta 169 zcmZqRn##o+%FD~e00iOh)~8+E$ZN-Fe2X(NH#IM_Br~=67F#luF33qt2J+d9Qp++^ z%YhQbC5a_K0oKyu)S}|anT+SzM1iIhiEg%I5@+Owut5T1lM|SuMa4l(Ij{maAvXB} Yvl^q~i2wiq delta 148 zcmbQr)xgCY%FD~e00ez+*QcG_$ZN+aSHueB7IA Date: Mon, 5 Aug 2024 01:45:40 +0300 Subject: [PATCH 08/36] added or modified a file --- api/v1/__pycache__/app.cpython-38.pyc | Bin 752 -> 1025 bytes api/v1/app.py | 9 ++++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/api/v1/__pycache__/app.cpython-38.pyc b/api/v1/__pycache__/app.cpython-38.pyc index 13ff259d0f86f8a75ecbcfbc84a0dca5c1ca5418..0c6855581ceda03a0e3916aab5b95e3a1e7ab38e 100644 GIT binary patch delta 655 zcmYjOzi-n(6uvv#v7Oki(v7DnP2lh!DSqTcRlUEYhCs@GdUUrK;MM zAu6tlf`~y=Ki|pO{&#h>}o8T#!vcfskeg1sM zrC}Ryu1fY5WU%tyS>fbC250#+SvqbC0L5JU&S^@a5j)+&&VE$jUW;c8;fvYAqZMo z+WK4W9|#uy1a~imJM5eH=IzcfcjA|4XK5+}cW%BvM~`HcZQQ;%g@FnXkQgY4BH%eS zv|x%goEct(Dr`76Q6ZFoKocD=K}jv&S~`3OSCNwhI~bw32j`?Z#&}BXGfI_VOSQGY zWC?b$&MI>`U2cPYXb89ma?;V6Zexb+C+fz9C&6xa^|L9U=7(ljPOBd5R7Y?Mw0eae zMAaAUr>WbZBz`Mu Date: Mon, 5 Aug 2024 01:55:13 +0300 Subject: [PATCH 09/36] added or modified a file --- api/v1/__pycache__/app.cpython-38.pyc | Bin 1025 -> 1025 bytes api/v1/app.py | 6 ++++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/api/v1/__pycache__/app.cpython-38.pyc b/api/v1/__pycache__/app.cpython-38.pyc index 0c6855581ceda03a0e3916aab5b95e3a1e7ab38e..0e132925326cc39c095e9015ed9e63205cc69fa8 100644 GIT binary patch delta 46 zcmZqVXyo7x<>lpK0D^MX4QWmrd7m;e3QYdYxSUaJ@@%FfjJGByFxN0LPrl2n0ss;9 B4MP9` delta 46 zcmZqVXyo7x<>lpK0D?l64QUP=d7m;e@=gBCxSUaB@@%Ffj8T&lm}?jrC*NgO0RRg7 B4730M diff --git a/api/v1/app.py b/api/v1/app.py index b07c8d7c790..6eb22e1c131 100644 --- a/api/v1/app.py +++ b/api/v1/app.py @@ -1,6 +1,8 @@ #!/usr/bin/python3 """Flask app main module""" -from flask import Flask, jsonify + + +from flask import Flask, jsonify, make_response from models import storage from api.v1.views import app_views from os import getenv @@ -20,7 +22,7 @@ def shutdown(exception=None): @app.errorhandler(404) def handle_not_found(error): """return a not found response""" - return jsonify({"error": "Not found"}), 404 + return make_response(jsonify({"error": "Not found"}), 404) if __name__ == "__main__": From 07c988b1711c2f8fc8dbf53e0f098a223d851f34 Mon Sep 17 00:00:00 2001 From: EgyAbdo10 Date: Mon, 5 Aug 2024 01:58:27 +0300 Subject: [PATCH 10/36] added or modified a file --- api/v1/app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/v1/app.py b/api/v1/app.py index 6eb22e1c131..202272a82b0 100644 --- a/api/v1/app.py +++ b/api/v1/app.py @@ -21,7 +21,7 @@ def shutdown(exception=None): @app.errorhandler(404) def handle_not_found(error): - """return a not found response""" + """return a not found response """ return make_response(jsonify({"error": "Not found"}), 404) From 8f195967d2e2193d27c0b8ac9d717eab4b3773bc Mon Sep 17 00:00:00 2001 From: EgyAbdo10 Date: Mon, 5 Aug 2024 21:15:56 +0300 Subject: [PATCH 11/36] added or modified a file --- api/v1/__pycache__/app.cpython-38.pyc | Bin 1025 -> 1057 bytes api/v1/views/index.py | 4 ++-- api/v1/views/states.py | 0 3 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 api/v1/views/states.py diff --git a/api/v1/__pycache__/app.cpython-38.pyc b/api/v1/__pycache__/app.cpython-38.pyc index 0e132925326cc39c095e9015ed9e63205cc69fa8..1652c24ffa840c96d83e8b4779ed99fd5ec4610f 100644 GIT binary patch delta 544 zcmYjNL5tKd810v|old9e?5thIQDJ03ScCyjvLIfBy(xm|A(vW6iZhe6OFFaSUY2#% zA28&q;GDd8@aVyVzoUo!De9Nb#X!FAeeWgVy^sfMw5i0v4-hvp2pa6g!uk8Iqn^%h z%1j1=xTXnHo2?;8^$)sng~J*TnK zWpW{w6;|nUO0lRZGpP`p;BnZ{URJ3Hn$m Q`IO+)Jiy}9%wE&Oe@&f%mjD0& delta 553 zcmYjPJ!>055WU^K)7?q8vJ@#UYyt^^fC&+}aFvk42A3uf;$oXcX!eNYy}K|c+1QOg z|A4s^DXq?>OBboq<{w;{E`K6;_6#NqGw;p38F&M`jLswZMas5E?M+l6lUy<-jlAiaaLK46 zXDcv-2;wV7N{^I2w3iGzkX(7xd1eyWk_Q~`p{oY4qJ}1h-X+5ykEjNOeX4ICk#sqG zZU$y}{pW3;*TJqGmj`t?D~o)Z9#`+!1@o&rw#MS>H`{&Rq0|0;XP!5qczTWtiXDow zM`_;NJ|&MJQvTW7@K4sOJ-)tK2L`dglX$O~zf6lo4w%sV21B<`APF#jO6}@~zhd3$ z7vG<()}hu=Ote-(>TDu+b8b Date: Mon, 5 Aug 2024 21:41:43 +0300 Subject: [PATCH 12/36] added or modified a file --- api/v1/views/__init__.py | 4 +-- .../views/__pycache__/__init__.cpython-38.pyc | Bin 350 -> 323 bytes api/v1/views/__pycache__/index.cpython-38.pyc | Bin 1301 -> 1169 bytes api/v1/views/index.py | 29 ++++++++++-------- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/api/v1/views/__init__.py b/api/v1/views/__init__.py index 7c1d711594d..a151983a167 100644 --- a/api/v1/views/__init__.py +++ b/api/v1/views/__init__.py @@ -1,8 +1,8 @@ #!/usr/bin/python3 """initialize a blueprint""" from flask import Blueprint -from api.v1.views.index import * app_views = Blueprint("app_views", __name__, url_prefix='/api/v1') -register_routes(app_views) + +from api.v1.views.index import * diff --git a/api/v1/views/__pycache__/__init__.cpython-38.pyc b/api/v1/views/__pycache__/__init__.cpython-38.pyc index 7f1c623af85886319b41f20bb6c412cae2f2bb3d..5775559bd0ae107bf61085d010d3a509f0fa4f49 100644 GIT binary patch delta 148 zcmcb|beM@Zl$V!_0SH1QH>O>f$SbR<1>~eKL@}f=rZD9&<}yVwF*2kwr7)*5r?8~3 z_A*DY0A<*6SVJa88%~_4I@?yQryp+_6iT{JS*nn~@j6BSIOaOY`CB*;$ delta 157 zcmX@ibdQNQl$V!_0SFpju1`BVkyqBx2*^och+;@#Okv7l%w>vVVg#|7bC^RIQkha% zQdv@1Q`mZ$qgYefQdyfB87BrCvT8EkV$_=0q9p34$$pDHK0YNsIX?atYg$fXadr{Y z#Pi|`w>aYC^AdAYd=|{Z0hC~2i*>P+)1jR0Y9?SPDW6bg5vt#WJ}|mG&-unpJ^wpDFMb~`gZOzIhX|f$o1Z7YmhtfI7f2YQ zh+#$qmV^>%Q46=ZC2Z+X$FMD2=~2(HBYYXqK!!9lxhqy=L?gqVh-HU%4EthLCNwb| zh_39>p5aie$v*8He!L>C$&{uTagRs5!xP@)eHMLi={iq8Zm{?hW*xTr4xMAVX`BR{ zF6$X*z}5~>)?a?z8f2vLj&wPjPF^*!ERK1uxSp3Y&6j^(M7Rlx`8+?F@>5+u#rNyq z_$J<~yX0PyVMX94Tq2diOQrPzd6aAb>efbqoZd9c+wNE5&}xvq*z58Jvv2(oOP z;Do3V@P2l^@$#IN<2-Mii75238MMA_Uz{~jF`w?7+}SZ3sTl670Z8Mha#3+Jv#Iib qsrKCTH?92#vSbUvAGRCnZ4jFzID)v+mLO~!6J+AA>-jjeef$rMf__Q> delta 750 zcmah_KW`H;9JPJ_lU$P!QvOImR~XUvUC&OH;>$($g^H+E2Koik z6B|Qe>%?d2dOK?+J^}pfv^(A+Puqqtog;Iw^@sYr-=61+7QL<<<;Zn1+KkARZPaCkJT1_ zTb<$UMTT|$>t?~M#|s$h3BWNrhxlLNG0ZwepYRDb6&orJb4`UX5A^-{Q^^m;s^l_C zg@|M^E4hk_QM4~+d@9G2GD@e@ zvrb6#7(u2X=NTnDIw8xwV3%liPxvT+A@$o%1d zlc~KJ*N({zhQXhYkgxB6j(nhD^=!?IVf!D^9_*}aiH{q$kL3nb_Tu&0OA=OONm4r_ xk*fFAk@fABysL%uiNAD>gAw<4@`B9--_?JsA^@ATu Date: Mon, 5 Aug 2024 21:44:04 +0300 Subject: [PATCH 13/36] added or modified a file --- .../views/__pycache__/__init__.cpython-38.pyc | Bin 323 -> 323 bytes api/v1/views/__pycache__/index.cpython-38.pyc | Bin 1169 -> 1155 bytes api/v1/views/index.py | 15 +++++++++------ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/api/v1/views/__pycache__/__init__.cpython-38.pyc b/api/v1/views/__pycache__/__init__.cpython-38.pyc index 5775559bd0ae107bf61085d010d3a509f0fa4f49..519f597a84c4c2a628e756d1509abeb20b942b7e 100644 GIT binary patch delta 22 ccmX@ibeM@Zl$V!_0SIQwY)sp{k=Kk706k>|g#Z8m delta 22 ccmX@ibeM@Zl$V!_0SH1QH>O?K$ZN(306TF7S^xk5 diff --git a/api/v1/views/__pycache__/index.cpython-38.pyc b/api/v1/views/__pycache__/index.cpython-38.pyc index 3404fb755e8d985725a2ef5bf39801acf65fe24e..a2e82704405e112c99952b54f268a50fd95efb5e 100644 GIT binary patch delta 166 zcmbQp+04ls%FD~e00geG8`Ii0@+L4bN=?pVGGx@5ynsnlwuYgZF_=MfuWAXAuG7zG#wn2O{l$1q+R5JE^03kX@57~$|28y5#77b^!N0L;K0vH$=8 delta 190 zcmZqXoXE)=%FD~e00h308`C~+$9qUkPgsLo;IvV>44QgC^7D zi%h~AFHZnfYqH&9PtHj!E>11J#hO`?np<4N0u;W*nw(#nS5m|bWKU*dHW!u!GKx8X z1Oqb*qX44-Q<1`CALfffQb3VgtVQ{yC8 Date: Tue, 6 Aug 2024 00:37:53 +0300 Subject: [PATCH 14/36] added or modified a file --- api/v1/__pycache__/app.cpython-38.pyc | Bin 1057 -> 1072 bytes api/v1/app.py | 5 +- api/v1/views/__init__.py | 8 ++- .../views/__pycache__/__init__.cpython-38.pyc | Bin 323 -> 510 bytes api/v1/views/__pycache__/index.cpython-38.pyc | Bin 1155 -> 1182 bytes .../views/__pycache__/states.cpython-38.pyc | Bin 0 -> 2643 bytes api/v1/views/index.py | 4 +- api/v1/views/states.py | 67 ++++++++++++++++++ models/__pycache__/base_model.cpython-38.pyc | Bin 2553 -> 2553 bytes 9 files changed, 79 insertions(+), 5 deletions(-) create mode 100644 api/v1/views/__pycache__/states.cpython-38.pyc diff --git a/api/v1/__pycache__/app.cpython-38.pyc b/api/v1/__pycache__/app.cpython-38.pyc index 1652c24ffa840c96d83e8b4779ed99fd5ec4610f..64085093b4f8e68f01b13b44ea476b2ed6eb0f95 100644 GIT binary patch delta 514 zcmYjM%}yIJ5YE`U8}E;IlR)?>LLe0(RS2YBH~?zjfEyfqL8`R4QYjqRDaSO|F`Wz?YcZ|`^idMdZ!&-7sPSMDnx z8X7dWLEco&ntN8{p$cp6+bEA!T=T#txl|GwhM9B%Dl^%vWx_d-lHIoTsuntY0CGCy ztmtSCI@ZZUgOpX1YI(=-QKzb_Gqq-7-I{y^oYe$WmvVaoxOmA_kln7Eu34KtAAsjl z*l8~P-nRmW?hx)Fa0~bVvHJ@rvQ1-^tQwA^bRBjITkf1~9WQ-@Sm4j_ycq8Gi_t)1 zN=2U-dX$h?95AbR{051ev94UF^Xro>_rxw?!)@}NujrGZg1peimKaorr1$;iX#DwT zd}Dr;*d%GmiV{WT$-eECcUNf2VSi*XbjZ(2S>LK#yY3CNCDtMdI~A-DEIEz_?^>#x mODaR0(a$4mzEsne`ve}}faGO!!6NQK;tPl z>QIIb`&CqP$sG==VI9lZ;jkLjiA-RinHJX|Q=NVtYrX|y(#1q&imTxbP-IGxJr!?3 zjZ|_oAm*MHN-P=vP^rw+SnlgsO|AiN^%DnVM#PkeZ#z#3>Eb|VdVllhXy*07>#8uz zK3bTznU`0+sEeh}QJeF&F}iyJUm)nd!$XL>-*6%(w54HoR}Yi!kiCS*-5GmyHtPe8 z*y6|Gn|3uT+jXN*P}VbsJ~{L(223rsU$rwMLjB}J(Wpx2O}oln;Q_J#W{kUE?47*d zM|rN=_jxXZ(&|Mk!8LX5WmvaLR|W&3Wm25ak1w7dU(EHT!O+fNt-;8~ge$lEt;%(U zy!-5(n#5H({W~p)W1?_s%^sQF!*%nYZnuFG&rfOcy3((#AoG-r?`4qeF5@ird`JQg MF+CrA#(}%{7X^fYS^xk5 diff --git a/api/v1/app.py b/api/v1/app.py index 202272a82b0..1d6cb8da0f1 100644 --- a/api/v1/app.py +++ b/api/v1/app.py @@ -2,12 +2,13 @@ """Flask app main module""" -from flask import Flask, jsonify, make_response +from flask import Flask, jsonify, make_response, abort from models import storage from api.v1.views import app_views from os import getenv from flask_restful import Resource + app = Flask(__name__) app.register_blueprint(app_views) @@ -21,7 +22,7 @@ def shutdown(exception=None): @app.errorhandler(404) def handle_not_found(error): - """return a not found response """ + """return a not found response""" return make_response(jsonify({"error": "Not found"}), 404) diff --git a/api/v1/views/__init__.py b/api/v1/views/__init__.py index a151983a167..c2fe7d99f83 100644 --- a/api/v1/views/__init__.py +++ b/api/v1/views/__init__.py @@ -1,8 +1,14 @@ #!/usr/bin/python3 """initialize a blueprint""" from flask import Blueprint - +from flask_restful import Api +from api.v1.views.states import * app_views = Blueprint("app_views", __name__, url_prefix='/api/v1') from api.v1.views.index import * + +api = Api(app_views) + +api.add_resource(State_view_all, "/states/") +api.add_resource(State_view, "/states/") diff --git a/api/v1/views/__pycache__/__init__.cpython-38.pyc b/api/v1/views/__pycache__/__init__.cpython-38.pyc index 519f597a84c4c2a628e756d1509abeb20b942b7e..93068730a022e15a1d0ac832d17a23ce3f282a17 100644 GIT binary patch delta 316 zcmX@i^pBY@l$V!_0SMf6Hl}4VPUMqGi39Rd7@`5B9<{ai+mM9i5 znmpO_ZsDdSj11QRp%HGTv#hJ>vfGd?dg<~O5H<-?7VB3D!B{q6k@(CMJ3md{iR;8n zc++wci?id4Qj1H{N^^>sfo_cwPAtgOD>Kw9%S*7J$;uCXnqPP(Jl?+8ZK%K#K-3)=BCES7cox`WEAII$xy@z6ffeOynxY*iw($RVdP=vV*&scMIv$l diff --git a/api/v1/views/__pycache__/index.cpython-38.pyc b/api/v1/views/__pycache__/index.cpython-38.pyc index a2e82704405e112c99952b54f268a50fd95efb5e..c25e435019c95cf360268e0b7d60fe5f81979a08 100644 GIT binary patch delta 190 zcmZqXoX5!<%FD~e00di9H>Pcx$SccuY@+sTgDi;@-W0wR{$8dOffT_OhGxbn$y70* zs1Q_CI7I|3DwQG{%%CYY@!dlqH%-P{e8nY2naL&b#W{(^8L5-cF@~~<0}U?{pRCCg zz$iJnifI`)L;xfzF%%CYU@!P}6uNXtv#DFFgiA{E43Sg9&Je6q~H$(s=Dn8kbS%Fc0ays)x kHA$erE!Lv^(vs9736P{bSRX1OJ~@uXij9Mji@wDTE?2QbK99Y=ljmLzBfBtB~boY`LkUK z2>Ay))5U?#HK?)=hLMOc%B+m$R%B6Z+nJp^k(0ZTn|qO$`;l+Poh-;JQ6;ZN)qEzJ z$!k#!=gpj(&E|8_9JD>=KO@nxTZ9Fy@{F(wukP5QuX{I9hkK`*oJcOjvQrk4YhUn3T`raOAIh>w+uLC;_n zVD&9VHv@4_SS?`05 zq+l5jp*_M^hGW>I30K)wVai$%i~WKaAWjB{3(!CucFBOQ6TpEEtzEKAep(pVeQRj< z?V+fSiqa2xGyB^l61dr7Cm3#NTl#w=|q;lYu> zH%IcU9aSLm(u_v|f{{V=#4%W5z!;h1*sXy%0d*YJfI75B=V@=@a6lH}VlR1%Kp1Zo zGcwp-zn+M1MeVJnf(j&?vqP|IRopd^*#B46kwSP@qu`3`eMzj z^hPU{+Xf#0N(Z*`hJN41ctPZXUBdh}GC1g+yD2y%ngsru8!v@-Zm+I|6F!ZYwD%hT z^`Z(if@R;V-fljp+RwR^kV{SN6iLo|weM0X(_%fu-rnEfQN3dFP6yz7jJc{SD^FUy zqtdc4bl1)%-P8`7j*Ej2)4&oRu8ppaC$9c)R8MbS2{HU8`;~77WS=owX1G4xK_MbW) zlTsK8ApF>n$RH#@5C|M=K|NIVlL}Sl^+{!<)MEi)RMFJ~A9`p1C$TWA@SI7pp@H=# zRCx-FB8v9u4rrSKbsO5dWSl#f?~Vm|p9|ysSqg8h9A!k~ieUzb)K$O=V?TlsLtqem zZjTTQChK0AJ)hvsF!>1})|(O%lQXaM8K2_z#Gj>b zdF9)cwUr|*pYmz%FWCK%V@9t%W;PU`!t4|k3=0}ChN@*)fUbZu#}9y89KCu78y}YM zYrxOYIq(P6z+f}5$7P*xCGTbv-dFDrJ;10aL%Un=~rtp<2WD8eLa;hlT0VS#uH?l0a(gX!3WPniW@ zuxiW53yTw_t6j4(w#6c>sn1Li2bEvEhbBaWVbN}?crLXsIs6w;!f1pzi_=CUe8VvD z84eg}eji)s@J$nk%74jq)L}@G-);xR+=Z+E(7B}m@I1ft&=B%ir z`4|oAzCg^yWi&<&4vb+05*uHT0T`nTZr}+VZPpjeF1iNF!!x;PlEh??cH8)WM_|qh z%nGBS=HsMi%~UMl&riFX38as}y#;>OM0%;)P!! literal 0 HcmV?d00001 diff --git a/api/v1/views/index.py b/api/v1/views/index.py index 225082f63ce..5f47a4b4b6b 100644 --- a/api/v1/views/index.py +++ b/api/v1/views/index.py @@ -23,13 +23,13 @@ } -@app_views.route("/status") +@app_views.route("/status", strict_slashes=False) def get_status(): """return status OK""" return jsonify({"status": "OK"}) -@app_views.route("/stats") +@app_views.route("/stats", strict_slashes=False) def get_stats(): """get objects count""" stats = {} diff --git a/api/v1/views/states.py b/api/v1/views/states.py index e69de29bb2d..e274449f470 100644 --- a/api/v1/views/states.py +++ b/api/v1/views/states.py @@ -0,0 +1,67 @@ +#!/usr/bin/python3 +"""retrieve state objects""" +from models.state import State +from flask import Flask, Response, request, jsonify +from flask_restful import Api, Resource, reqparse, abort, request +from models import storage + + +def abortNotExists(cls, obj_id): + """exit with a 404 status if obj not found""" + obj = storage.get(cls, obj_id) + if obj is None: + abort(404) + return obj + + +class State_view_all(Resource): + """handle all states requests without id""" + def get(self): + """get all state objects""" + objs_dict = storage.all() + obj_list = [] + for obj in objs_dict.values(): + obj_list.append(obj.to_dict()) + return jsonify(obj_list) + + def post(self): + """Creates a State: POST /api/v1/states""" + try: + data = request.get_json() + except Exception as e: + abort(400, message="Not a JSON") + if "name" not in data.keys(): + abort(400, message="Missing name") + + new_obj = State(**data) + storage.new(new_obj) + return new_obj.to_dict(), 201 + + +class State_view(Resource): + """handle all states requests with id""" + def get(self, state_id): + """Retrieves a State object: GET /api/v1/states/""" + obj = abortNotExists(State, state_id) + return jsonify(obj.to_dict()) + + def delete(self, state_id): + """Deletes a State object:: DELETE /api/v1/states/""" + obj = abortNotExists(State, state_id) + storage.delete(obj) + return {}, 200 + + def put(self, state_id): + """Updates a State object: PUT /api/v1/states/""" + obj = abortNotExists(State, state_id) + try: + data = request.get_json() + except Exception as e: + abort(400, message="Not a JSON") + + for key, val in data.items(): + if key not in ["id", "created_at", "updated_at"]: + setattr(obj, key, val) + + storage.new(obj) + return obj.to_dict(), 200 diff --git a/models/__pycache__/base_model.cpython-38.pyc b/models/__pycache__/base_model.cpython-38.pyc index f639bfffc58000a725ee5c2f21281dd083a756fa..71edd132d6d3dddf04f69c709136e39310ba370b 100644 GIT binary patch delta 55 zcmew<{8N}al$V!_0SKO&Y~09Q!Oj>pxrO~Yqrv1Dj=605K=C4j$^SVV8I319awajF JOkTnn3IMqc52gSB delta 55 zcmew<{8N}al$V!_0SMx+uiwaB!OnPVatr%)M#IT59CO(WfZ|1llmBx#GMY?w Date: Tue, 6 Aug 2024 00:43:16 +0300 Subject: [PATCH 15/36] added or modified a file --- api/v1/views/states.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/api/v1/views/states.py b/api/v1/views/states.py index e274449f470..1b40fb93ffc 100644 --- a/api/v1/views/states.py +++ b/api/v1/views/states.py @@ -1,8 +1,8 @@ #!/usr/bin/python3 """retrieve state objects""" from models.state import State -from flask import Flask, Response, request, jsonify -from flask_restful import Api, Resource, reqparse, abort, request +from flask import jsonify +from flask_restful import Resource, abort, request from models import storage @@ -28,7 +28,7 @@ def post(self): """Creates a State: POST /api/v1/states""" try: data = request.get_json() - except Exception as e: + except Exception: abort(400, message="Not a JSON") if "name" not in data.keys(): abort(400, message="Missing name") @@ -56,7 +56,7 @@ def put(self, state_id): obj = abortNotExists(State, state_id) try: data = request.get_json() - except Exception as e: + except Exception: abort(400, message="Not a JSON") for key, val in data.items(): From 90d6b340e4a5065e65049d2056eaa33d95ef23e3 Mon Sep 17 00:00:00 2001 From: EgyAbdo10 Date: Tue, 6 Aug 2024 00:46:17 +0300 Subject: [PATCH 16/36] added or modified a file --- api/v1/views/index.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/api/v1/views/index.py b/api/v1/views/index.py index 5f47a4b4b6b..51f7b5eeabc 100644 --- a/api/v1/views/index.py +++ b/api/v1/views/index.py @@ -1,10 +1,9 @@ #!/usr/bin/python3 """routes of the app_view blueprint""" # from api.v1.views import app_views avoid circular import -from flask import jsonify, make_response +from flask import jsonify # , make_response from models import storage from models.amenity import Amenity -from models.base_model import BaseModel, Base from models.city import City from models.place import Place from models.review import Review From f2b92fec36409b1999dd30b9aed6d018c40b8498 Mon Sep 17 00:00:00 2001 From: EgyAbdo10 Date: Tue, 6 Aug 2024 00:50:22 +0300 Subject: [PATCH 17/36] added or modified a file --- api/v1/app.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/api/v1/app.py b/api/v1/app.py index 1d6cb8da0f1..62f0aa73ee0 100644 --- a/api/v1/app.py +++ b/api/v1/app.py @@ -2,11 +2,10 @@ """Flask app main module""" -from flask import Flask, jsonify, make_response, abort +from flask import Flask, jsonify, make_response from models import storage from api.v1.views import app_views from os import getenv -from flask_restful import Resource app = Flask(__name__) From a00c11bd7f6b4ca513ee7798c202499e93aba323 Mon Sep 17 00:00:00 2001 From: EgyAbdo10 Date: Tue, 6 Aug 2024 22:01:14 +0300 Subject: [PATCH 18/36] added or modified a file --- api/v1/__pycache__/app.cpython-38.pyc | Bin 1072 -> 1019 bytes api/v1/app.py | 2 +- api/v1/views/__init__.py | 10 +- .../views/__pycache__/__init__.cpython-38.pyc | Bin 510 -> 354 bytes api/v1/views/__pycache__/index.cpython-38.pyc | Bin 1182 -> 1090 bytes .../views/__pycache__/states.cpython-38.pyc | Bin 2643 -> 2208 bytes api/v1/views/states.py | 162 +++++++++++++----- .../__pycache__/db_storage.cpython-38.pyc | Bin 3596 -> 3596 bytes 8 files changed, 124 insertions(+), 50 deletions(-) diff --git a/api/v1/__pycache__/app.cpython-38.pyc b/api/v1/__pycache__/app.cpython-38.pyc index 64085093b4f8e68f01b13b44ea476b2ed6eb0f95..c3b6545069d993aa598ad55721e624732bcb2018 100644 GIT binary patch delta 571 zcmYjOJ8u**5Z>{6cYV9w%e_*7gmgTbRisFCNQn?t8YCK^akDIpk9+JZ_FWKZ5W2KT zp#1|$ONCO<@E52lwxy!t2hd<|1d6Sh`8+e8`8@u@{seo^<2ZE8`h9#kd+a*SPkXq& zd~W63VSc=)o9V+@d; zfr;#x$N+m6fFVX_j`0j-gnUKRCB|ZeeKD3H?rcGQys~0s>|px>)OiQMB=F@#j^r4J zW{*BlL&1OQB$LzKqde2AX;#!9uGCtv^<2peCAJ>Qmz&oKJV|!jAWgA)m8Qa*S;mU|E8R5_z9BAitvurvJgXP` zC-?VH7V?c&_ETC?X%#f@-NWOk%aBS{YMzyt8`QV8238GiuB$fXHKrYB`|m9~yc*9# c+g#r>inb%7 delta 587 zcmYjOJ8#rL5cc@(vwgnY#o>sMI0QnnA|g=}0Szfr@F>^@8Fr6*_@!B25Hu++4Fv^q zN0rnxp`fSWSGYq|`~{$3)+eFtYG=N0zJ1Kh{&6ncy=P(A(`fv@^<_FUH0`G%mxo2< zAuaj+Uy29k#O|4_OGB&_#a@EE3V#KzQds zk!Z2Sx4Fx`Qy^tX%82*Qf%`l-)hMzp`aE3f_>K2j%p{qt5wY0eLq7UoPy)^qEs5X7hgm9@leDTPc{(p9dC6Cq_@zor%+~7E)>+81m`~rf zVV*9<3ly>{3n^MFeOY3iK-Vl1%$$|7W@bf?F}I$fNV(t%93|t%Gp;{C z^$E%`=3GNv(xU^9*8hq3z)m?Mo2 diff --git a/api/v1/app.py b/api/v1/app.py index 62f0aa73ee0..99928aa34b8 100644 --- a/api/v1/app.py +++ b/api/v1/app.py @@ -35,4 +35,4 @@ def handle_not_found(error): if getenv("HBNB_API_PORT"): HBNB_API_PORT = getenv("HBNB_API_PORT") - app.run(host=HBNB_API_HOST, port=HBNB_API_PORT, threaded=True) + app.run(host=HBNB_API_HOST, port=HBNB_API_PORT, threaded=True, debug=True) diff --git a/api/v1/views/__init__.py b/api/v1/views/__init__.py index c2fe7d99f83..5b455eeed5d 100644 --- a/api/v1/views/__init__.py +++ b/api/v1/views/__init__.py @@ -1,14 +1,14 @@ #!/usr/bin/python3 """initialize a blueprint""" from flask import Blueprint -from flask_restful import Api -from api.v1.views.states import * +# from flask_restful import Api app_views = Blueprint("app_views", __name__, url_prefix='/api/v1') from api.v1.views.index import * +from api.v1.views.states import * -api = Api(app_views) +# api = Api(app_views) -api.add_resource(State_view_all, "/states/") -api.add_resource(State_view, "/states/") +# api.add_resource(State_view_all, "/states/") +# api.add_resource(State_view, "/states/") diff --git a/api/v1/views/__pycache__/__init__.cpython-38.pyc b/api/v1/views/__pycache__/__init__.cpython-38.pyc index 93068730a022e15a1d0ac832d17a23ce3f282a17..dd56ab9227846666118a44b3d048a7d7ded284fd 100644 GIT binary patch delta 161 zcmeyz{D_G+l$V!_0SH)&Hl-C#`1 zdzqtHfHG`3tRWy3Y&mQ|nmw37lVf6^*2E)9nwpHa7`6N~*>ADO$EV~c$H(7dP0L9v z&MsmCntO{QK0YroH#I)Kh+p{+L-Gi0L~MZJZ!TkuZxcMw(H%t(IMs2Fb#le#2ko)R zO>LAlEzZ@~ diff --git a/api/v1/views/__pycache__/index.cpython-38.pyc b/api/v1/views/__pycache__/index.cpython-38.pyc index c25e435019c95cf360268e0b7d60fe5f81979a08..45977b0502963cce4f92e0f3d5c7958a7f3e9635 100644 GIT binary patch delta 560 zcmX|;y=ojW5P&7^-u~V0dVN1m0uIJie9eK26af>6F}QOR(x}-ir#W+uEFn049sZbqzR8|m-s46P zP6QQ9QpGrU$xP)ucO1(#Rq(=b zBG=V`4=8~EB1j;G99|Tn|1ID{7@UkmDl(B@GqEO$Pvj%zV`tY_b|8k%ZivxqG8y0e zdA5B=yYR%+r;GW;1kp6Lu8zUtD+Q;E=AwN|k0@`y)5jQpQ<-aq{oWBh#6=I=19p%- zK{QqqPmkNL>sb1z1i(#^f$l+PgS<&nfDZpK^@{y zL|u-AOI+a*4;k%oUj!tu?DJ4WB(favSR^D79n!Hn7-XN%PMAv^664RA9DB70A(Xf-bi6)bouFYPygrx#Ty%m5O6BYHbAYuFl;Tg*IaBJGBU1+tv!o?U0{@ua(F zk{x+Zn`;mUe!$K#SAGTDIQNy){seNOy6t@hu;p@fS9QDVtFOwB+U)?rRXzP}`1eVK z{?db^mkWbC@Q6P_P!uDIDamm`VuH19w66c9CwfgflTNM?zbi^l{0h@;G}sVM4+pPsoy|>kQOZIvyv}j6D+rqPJ`= z3*I(7U%(?G5EAX;3RQScwn;@O-t_rpNhsOD7*zyLYRx`i&odc4%j8CsM%S-gHwT`G zC>!cSN25|k!*VjBE7`9Y&TerJ_Epw8#OHw4vy?T+MeKrel2K*B`xW9Lm|kD+ZAsjtP9Fl*`XEA%*6V@IfFF zVjpha0e$8*EAA`n%jGq|t0MsLflNf6iVY@|S1`FzQZZX>Jo~rIH{g)BR|XKu!KD$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nf(j&?vqP|IRopd^*#B46kwSP@qu`3`eMzj z^hPU{+Xf#0N(Z*`hJN41ctPZXUBdh}GC1g+yD2y%ngsru8!v@-Zm+I|6F!ZYwD%hT z^`Z(if@R;V-fljp+RwR^kV{SN6iLo|weM0X(_%fu-rnEfQN3dFP6yz7jJc{SD^FUy zqtdc4bl1)%-P8`7j*Ej2)4&oRu8ppaC$9c)R8MbS2{HU8`;~77WS=owX1G4xK_MbW) zlTsK8ApF>n$RH#@5C|M=K|NIVlL}Sl^+{!<)MEi)RMFJ~A9`p1C$TWA@SI7pp@H=# zRCx-FB8v9u4rrSKbsO5dWSl#f?~Vm|p9|ysSqg8h9A!k~ieUzb)K$O=V?TlsLtqem zZjTTQChK0AJ)hvsF!>1})|(O%lQXaM8K2_z#Gj>b zdF9)cwUr|*pYmz%FWCK%V@9t%W;PU`!t4|k3=0}ChN@*)fUbZu#}9y89KCu78y}YM zYrxOYIq(P6z+f}5$7P*xCGTbv-dFDrJ;10aL%Un=~rtp<2WD8eLa;hlT0VS#uH?l0a(gX!3WPniW@ zuxiW53yTw_t6j4(w#6c>sn1Li2bEvEhbBaWVbN}?crLXsIs6w;!f1pzi_=CUe8VvD z84eg}eji)s@J$nk%74jq)L}@G-);xR+=Z+E(7B}m@I1ft&=B%ir z`4|oAzCg^yWi&<&4vb+05*uHT0T`nTZr}+VZPpjeF1iNF!!x;PlEh??cH8)WM_|qh z%nGBS=HsMi%~UMl&riFX38as}y#;>OM0%;)P!! diff --git a/api/v1/views/states.py b/api/v1/views/states.py index 1b40fb93ffc..0fae1b4d973 100644 --- a/api/v1/views/states.py +++ b/api/v1/views/states.py @@ -1,9 +1,10 @@ #!/usr/bin/python3 """retrieve state objects""" from models.state import State -from flask import jsonify -from flask_restful import Resource, abort, request +from flask import jsonify, make_response +from flask_restful import abort, request from models import storage +from api.v1.views import app_views def abortNotExists(cls, obj_id): @@ -14,54 +15,127 @@ def abortNotExists(cls, obj_id): return obj -class State_view_all(Resource): - """handle all states requests without id""" - def get(self): - """get all state objects""" +@app_views.route("/states", strict_slashes=False, methods=["GET"]) +@app_views.route("/states/", strict_slashes=False, methods=["GET"]) +def get_states(state_id=None): + """retrieve a state object""" + if not state_id: objs_dict = storage.all() obj_list = [] for obj in objs_dict.values(): obj_list.append(obj.to_dict()) - return jsonify(obj_list) - - def post(self): - """Creates a State: POST /api/v1/states""" - try: - data = request.get_json() - except Exception: - abort(400, message="Not a JSON") - if "name" not in data.keys(): - abort(400, message="Missing name") - - new_obj = State(**data) - storage.new(new_obj) - return new_obj.to_dict(), 201 - - -class State_view(Resource): - """handle all states requests with id""" - def get(self, state_id): - """Retrieves a State object: GET /api/v1/states/""" - obj = abortNotExists(State, state_id) - return jsonify(obj.to_dict()) + return make_response(jsonify(obj_list)) - def delete(self, state_id): - """Deletes a State object:: DELETE /api/v1/states/""" + else: obj = abortNotExists(State, state_id) - storage.delete(obj) - return {}, 200 + return make_response(jsonify(obj.to_dict())) - def put(self, state_id): - """Updates a State object: PUT /api/v1/states/""" - obj = abortNotExists(State, state_id) - try: - data = request.get_json() - except Exception: - abort(400, message="Not a JSON") - for key, val in data.items(): - if key not in ["id", "created_at", "updated_at"]: - setattr(obj, key, val) +@app_views.route("/states", strict_slashes=False, methods=["POST"]) +def post_states(): + """create a new state object""" + try: + data = request.get_json() + except Exception: + abort(400, message="Not a JSON") + if "name" not in data.keys(): + abort(400, message="Missing name") + + new_obj = State(**data) + storage.new(new_obj) + storage.save() + return make_response(new_obj.to_dict(), 201) + + +@app_views.route("/states/", strict_slashes=False, + methods=["DELETE"]) +def delete_state(state_id): + """Deletes a State object:: DELETE /api/v1/states/""" + obj = abortNotExists(State, state_id) + storage.delete(obj) + storage.save() + return make_response({}, 200) + + +@app_views.route("/states/", strict_slashes=False, methods=["PUT"]) +def put_state(state_id): + """Updates a State object: PUT /api/v1/states/""" + obj = abortNotExists(State, state_id) + try: + data = request.get_json() + except Exception: + abort(400, message="Not a JSON") + + for key, val in data.items(): + if key not in ["id", "created_at", "updated_at"]: + setattr(obj, key, val) + + storage.save() + return make_response(obj.to_dict(), 200) + +# def put(self, state_id): +# """Updates a State object: PUT /api/v1/states/""" +# obj = abortNotExists(State, state_id) +# try: +# data = request.get_json() +# except Exception: +# abort(400, message="Not a JSON") + +# for key, val in data.items(): +# if key not in ["id", "created_at", "updated_at"]: +# setattr(obj, key, val) + +# storage.new(obj) +# return obj.to_dict(), 200 + +# class State_view_all(Resource): +# """handle all states requests without id""" +# def get(self): +# """get all state objects""" +# objs_dict = storage.all() +# obj_list = [] +# for obj in objs_dict.values(): +# obj_list.append(obj.to_dict()) +# return jsonify(obj_list) + +# def post(self): +# """Creates a State: POST /api/v1/states""" +# try: +# data = request.get_json() +# except Exception: +# abort(400, message="Not a JSON") +# if "name" not in data.keys(): +# abort(400, message="Missing name") + +# new_obj = State(**data) +# storage.new(new_obj) +# return new_obj.to_dict(), 201 + + +# class State_view(Resource): +# """handle all states requests with id""" +# def get(self, state_id): +# """Retrieves a State object: GET /api/v1/states/""" +# obj = abortNotExists(State, state_id) +# return jsonify(obj.to_dict()) + +# def delete(self, state_id): +# """Deletes a State object:: DELETE /api/v1/states/""" +# obj = abortNotExists(State, state_id) +# storage.delete(obj) +# return {}, 200 + +# def put(self, state_id): +# """Updates a State object: PUT /api/v1/states/""" +# obj = abortNotExists(State, state_id) +# try: +# data = request.get_json() +# except Exception: +# abort(400, message="Not a JSON") + +# for key, val in data.items(): +# if key not in ["id", "created_at", "updated_at"]: +# setattr(obj, key, val) - storage.new(obj) - return obj.to_dict(), 200 +# storage.new(obj) +# return obj.to_dict(), 200 diff --git a/models/engine/__pycache__/db_storage.cpython-38.pyc b/models/engine/__pycache__/db_storage.cpython-38.pyc index eed0b8c5a76d43c8ceaf870c2d27e7a068014f6b..32409717bb99c2c29b4ab88ab659a4e8085b3950 100644 GIT binary patch delta 737 zcmZ`$Jx}965XCrgoWw?=JHlrGArKHggg`o|D4?T3G}}auvq%OzMzc#!sc26+x-Afh zhVHoTfS-W`6-fRCNbnOVn6WKnK)86Gee?Fsv*&o=c%Zyv+odji&YY|N<#SzQ>aRYl z^<6*cuiEMlY(%>2i^vQcd-bO0N|wV)L^@)m@AFQSmrldy(1+3lDpXaKZCq4`}9+BFxyScHwL^b~2jW=aR$BCl@--t3~q^)8Cpy zh|gw!jjl}Tu^qDn7oxuFxH5zeD{SM*3tQRHYN>cKm`nj4gl!JBPgB%W@gEySatk!F zF2Euw1_{Op=r)WXu;Q-gW6pY`164dv<&uw@AOSf<25@oc%MSrwN{^f0IYxOmJZ#Ai zMk_QahszOJ8yc~qO4h12t~RWh^*B^Nv6KX63FZjq3F3K6R4o&bWyUPs(T%lm^bBChJYfh9h`Au0bce95u^n(Y5cS;Ta!Kw4OOvQEDiS{;eiY&tXrY~r*rW-U%L=D=xv;xNQrQaHT_K8% zji`-?{tQ7Yh5ZGB{saqW?owP7uXs1}=Ixu=ozvWDF1=$IsV?}gKkpyXmqd~N4Vh9h zk8k8#S?Ys=B$mUa=2iD9HQN$01`(G8P?CMxl5t^H9m+Bw4IztB!8g>ap*)0=n6=t% zH$yKrju4UhFY57Npi(W*b!~C0guI^O7`MEGy67-k1*38d zmcyeq*kaXB=}XF}zoAdA=aI-E;3RAsVHRNyA?UY=(Fy`uM$CdGWc??7=4cHnQguDp z0GB=Czht_!Zi^P{#$s=qteTuwf|wDsi(xU{E?Ov$Bcr#OhGSZksYn@ZiqWP`4_P82 f(@R{K@S+-We#6MXj!%qnTj)mZ)kEmp9i From ccb7c6d929cad6053a93966ffa66ff8362504fa2 Mon Sep 17 00:00:00 2001 From: EgyAbdo10 Date: Tue, 6 Aug 2024 22:07:28 +0300 Subject: [PATCH 19/36] added or modified a file --- api/v1/__pycache__/app.cpython-38.pyc | Bin 1019 -> 1019 bytes .../views/__pycache__/states.cpython-38.pyc | Bin 2208 -> 2192 bytes api/v1/views/states.py | 5 ++--- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/api/v1/__pycache__/app.cpython-38.pyc b/api/v1/__pycache__/app.cpython-38.pyc index c3b6545069d993aa598ad55721e624732bcb2018..b74447220bab8836f483ad0ce20cff1dbe32b05a 100644 GIT binary patch delta 41 wcmey({+pdQl$V!_0SL;9Hl=xO7H#&wM1o98n*GBUDEe#k5Z016uncK`qY diff --git a/api/v1/views/__pycache__/states.cpython-38.pyc b/api/v1/views/__pycache__/states.cpython-38.pyc index f7f39143758ac93bed367d2643644d0661a0f815..739c3887cf37b8f3b129cca6edf74ed1fbe72fe9 100644 GIT binary patch delta 364 zcmZ1=I6;svl$V!_0SE$1Hl_U+n8+u?cw(ZqVtp=K6k9HP6gwkB3S$aO4o5C$6epO? zn!}aL9mNe~v!$@NFhudBa%b_TaHMdiaHTV*aQ8BU`8)`Iiew633V#b@GZ04c!Bq=D zRHq202(>T(W%%Lxgn=^kK!Z|5QbfU00&poYs3!3g39yV{3U4rjrc{+|ZhlH;TBSm9 zNn%N=LVi+KYH~@jLRn^_f@6SZ@k@~ZG#PKP27{zES#Ggs73b#x)!*XHP0UV>FG?*g z$j>WIy~UcClwVYGi@hjyvM=L5M$XMXOc$BC4S~9gIY4HxY}R0FV`Q|Ryq;Z^QE2j2 rcHPN>9JwkAASp&3MhPJ1VdmfvU=(2F;}c-y;^$yw`Om_{1rz}QqJ&r| delta 379 zcmbOrxImCEl$V!_0SIaeH>Ld)oX97`cwwTpVm%{63S$aO4qGmJ6nid56bG2kn!}mP z6~zT+v*mE-@DctFdDLlQ*U_LK`pCXmQpCZu0*bIbG z{BYHR5Y;I{DZ(ubKp6qBOg%`W2vkZmMGPz@2sct3DkG6136>E`;R|Nal&%shN-ZhM zOf5@QC@x7XNma;C%1TWxDSip^peExj)?kpRCetnUtm6E<%(Ti|yt#?lsqsar#Rd6! z#UL5h#H9S9l3SbI8G(RnvnSI Date: Tue, 6 Aug 2024 22:07:58 +0300 Subject: [PATCH 20/36] added or modified a file --- api/v1/app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/v1/app.py b/api/v1/app.py index 99928aa34b8..62f0aa73ee0 100644 --- a/api/v1/app.py +++ b/api/v1/app.py @@ -35,4 +35,4 @@ def handle_not_found(error): if getenv("HBNB_API_PORT"): HBNB_API_PORT = getenv("HBNB_API_PORT") - app.run(host=HBNB_API_HOST, port=HBNB_API_PORT, threaded=True, debug=True) + app.run(host=HBNB_API_HOST, port=HBNB_API_PORT, threaded=True) From abbaac6d0a814cdb1c758cc3d1e88d426768df47 Mon Sep 17 00:00:00 2001 From: EgyAbdo10 Date: Tue, 6 Aug 2024 22:22:07 +0300 Subject: [PATCH 21/36] added or modified a file --- api/v1/__pycache__/app.cpython-38.pyc | Bin 1019 -> 1010 bytes .../views/__pycache__/states.cpython-38.pyc | Bin 2192 -> 2202 bytes api/v1/views/states.py | 14 +++++++------- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/api/v1/__pycache__/app.cpython-38.pyc b/api/v1/__pycache__/app.cpython-38.pyc index b74447220bab8836f483ad0ce20cff1dbe32b05a..303a8359878b504a002d8ae98b09798fa534c21b 100644 GIT binary patch delta 92 zcmey({)t^Xl$V!_0SG!vHl^7yGcY^`agYHkkmCTv#akw7S21pwxXhSYsF!);Jq{*u f<|vko{Nj=*mV*4Ek|>UnjH1-Ul+={TEX>~lY-1K- delta 101 zcmeyw{+nGpl$V!_0SL;9Hl=wnGcY^`agYHUkmCTv#oH!oS21pyxXhSUFh!`BW#b(V pCOMWUmW=%3k|>sf{GyU5j*^U`)Wnq3lv}JRsY#{jlYcXP2LM2v8n*xd diff --git a/api/v1/views/__pycache__/states.cpython-38.pyc b/api/v1/views/__pycache__/states.cpython-38.pyc index 739c3887cf37b8f3b129cca6edf74ed1fbe72fe9..7717eff66755022db36c775f05c4d756f3fc0921 100644 GIT binary patch delta 138 zcmbOrI7^T(l$V!_0SKm-Z%Shq+{jnS!mr7Ai#sK?IJqdZpd>RtZ}KFTRg9{WZCO_{ zDouXL>ddG)S(oiDH&7LOZfbFHVtVRies+0A^~w6|qHJf~uGs~FWLJF>23RG$2n z)tOOivLV}D)*@-3j>(ej@?jc4h9*xDACM|y0ugK=LLNjYfCyF~af>yxBsI7A7JG4O rNn%M!Q4u>xMj1q~fCy0_p~+e#24ZuA2$jiw?AzJYKuoR4-W>h_pA;o+ diff --git a/api/v1/views/states.py b/api/v1/views/states.py index 11bf87ec354..228d9cf95a6 100644 --- a/api/v1/views/states.py +++ b/api/v1/views/states.py @@ -36,9 +36,9 @@ def post_states(): try: data = request.get_json() except Exception: - abort(400, message="Not a JSON") + abort(400, description="Not a JSON") if "name" not in data.keys(): - abort(400, message="Missing name") + abort(400, description="Missing name") new_obj = State(**data) storage.new(new_obj) @@ -63,7 +63,7 @@ def put_state(state_id): try: data = request.get_json() except Exception: - abort(400, message="Not a JSON") + abort(400, description="Not a JSON") for key, val in data.items(): if key not in ["id", "created_at", "updated_at"]: @@ -78,7 +78,7 @@ def put_state(state_id): # try: # data = request.get_json() # except Exception: -# abort(400, message="Not a JSON") +# abort(400, description="Not a JSON") # for key, val in data.items(): # if key not in ["id", "created_at", "updated_at"]: @@ -102,9 +102,9 @@ def put_state(state_id): # try: # data = request.get_json() # except Exception: -# abort(400, message="Not a JSON") +# abort(400, description="Not a JSON") # if "name" not in data.keys(): -# abort(400, message="Missing name") +# abort(400, description="Missing name") # new_obj = State(**data) # storage.new(new_obj) @@ -130,7 +130,7 @@ def put_state(state_id): # try: # data = request.get_json() # except Exception: -# abort(400, message="Not a JSON") +# abort(400, description="Not a JSON") # for key, val in data.items(): # if key not in ["id", "created_at", "updated_at"]: From 4be1b4fab35072674df70efc71ac7c0d5b9e72db Mon Sep 17 00:00:00 2001 From: EgyAbdo10 Date: Tue, 6 Aug 2024 22:39:10 +0300 Subject: [PATCH 22/36] added or modified a file --- .../views/__pycache__/states.cpython-38.pyc | Bin 2202 -> 2196 bytes api/v1/views/index.py | 8 ++++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/api/v1/views/__pycache__/states.cpython-38.pyc b/api/v1/views/__pycache__/states.cpython-38.pyc index 7717eff66755022db36c775f05c4d756f3fc0921..dae9f99429aae57ee9e3a0b7d923e09b79cfc3c6 100644 GIT binary patch delta 164 zcmbOwI7N^*l$V!_0SIoEZ%UKi$Xmt2xN>p_%MM1h$&Re68I>o$Wp!rMnrz5+m$gV5 zsBE$%yL^}ikfF&_#0R8`m_P&@h>!;n3Lt_NNZex0EJ@8RzQtagT9Q~&QdGnal2HZ` mEFeM@NNBPaiGkSMAVOtwANwT6sL6^PDr{;X0jl$V!_0SKm-Z%Sj|$Xmt2s5!ZVWe20`WJlK3j7pQ=vN{7r4B76wX)@ko z&rK~ZPE1eLWWL3enR1IOxhOTUBsC>IvE&w4X+a80gcUNmts_&+`&GH@z!K%4iz?4kfi2hR}OywgRLjX diff --git a/api/v1/views/index.py b/api/v1/views/index.py index 51f7b5eeabc..3f1b52f242e 100644 --- a/api/v1/views/index.py +++ b/api/v1/views/index.py @@ -1,7 +1,7 @@ #!/usr/bin/python3 """routes of the app_view blueprint""" # from api.v1.views import app_views avoid circular import -from flask import jsonify # , make_response +from flask import jsonify, make_response # , make_response from models import storage from models.amenity import Amenity from models.city import City @@ -22,17 +22,17 @@ } -@app_views.route("/status", strict_slashes=False) +@app_views.route("/status", strict_slashes=False, methods=["GET"]) def get_status(): """return status OK""" return jsonify({"status": "OK"}) -@app_views.route("/stats", strict_slashes=False) +@app_views.route("/stats", strict_slashes=False, strict_slashes=False, methods=["GET"]) def get_stats(): """get objects count""" stats = {} for cls_name, cls in classes.items(): stats[cls_name] = storage.count(cls) - return jsonify(stats) + return make_response(jsonify(stats)) From 903f22d991a4853ba7a4d8be641b9a95898e78f4 Mon Sep 17 00:00:00 2001 From: EgyAbdo10 Date: Tue, 6 Aug 2024 22:39:58 +0300 Subject: [PATCH 23/36] added or modified a file --- api/v1/views/index.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/v1/views/index.py b/api/v1/views/index.py index 3f1b52f242e..0af803f33f0 100644 --- a/api/v1/views/index.py +++ b/api/v1/views/index.py @@ -28,7 +28,8 @@ def get_status(): return jsonify({"status": "OK"}) -@app_views.route("/stats", strict_slashes=False, strict_slashes=False, methods=["GET"]) +@app_views.route("/stats", strict_slashes=False, strict_slashes=False, + methods=["GET"]) def get_stats(): """get objects count""" stats = {} From 4827a10088709824465060026bdad0097c1ec81a Mon Sep 17 00:00:00 2001 From: EgyAbdo10 Date: Tue, 6 Aug 2024 22:43:15 +0300 Subject: [PATCH 24/36] added or modified a file --- api/v1/views/__pycache__/index.cpython-38.pyc | Bin 1090 -> 1147 bytes api/v1/views/index.py | 3 +-- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/api/v1/views/__pycache__/index.cpython-38.pyc b/api/v1/views/__pycache__/index.cpython-38.pyc index 45977b0502963cce4f92e0f3d5c7958a7f3e9635..0c511a6ab01564562ab6958035a2708204e6dacc 100644 GIT binary patch delta 685 zcmYjP&x_MQ6wXYVUro}cO}omf=pL3em$Kf)+u}hGMZFA22$`vy-I=D$q$`DmvaDAR zORoL{f_Tuo2T%Gh%+Y_ti!;**Og3LxX(6LQ>%t4O9J?b(Kc?LVwX8{Tfc4?o5C^Xok5sOi5uulhUh=v9S zG+`q&GPqC2EJZ1>h(`hvl9QMW$q0v^Tr?r+*%U`O#)EeN4?o&C!J`k>H9&hNGv3Lh zcw#cQ@bs0H?cMx2+Rvc$&P2Va=4%`3Kt&0Wnz9b?>bPg8M6adJ_S z_uSu>ZH)Fzk4kv3E4C7ZbN%C>s909Bi$^ovCwQnRK2?Wwc)e0x6HRCvJKoH$QeEUf dR^MGw@ delta 590 zcmX|;zi!kp7{FsEasH>dyIi5DP<24)By<&1)q$A-34u@!h%;|Mqij>JjStO#1fw3)N#Zzp5xqc%nDxO(s9Dpc!ev+ zDI4%19s-Xd8q<{Kw4{3#$*vI|(cwW&a#E1;GbC%Iy7Vpp9y>c&*&!J@yH4u2-ekP| z{Uo~qIy#Vx!)|`6cEFoWowS@Dc6~>sMl-i!bi~@3iPbgO9!!8PWiPr}-$>TV4^;gG zFG~TgRHUL(FBlt~fTKrQ|HTxYjxYMMV4 z$ohO`+%-gGRk2cno^U9topy#v7|!SU)Oni)J;#GO>LPJnNech`cN#6 dP1ShA8r$;fDekCN&x89QSMP!?l!G+P!9PGMl?DI+ diff --git a/api/v1/views/index.py b/api/v1/views/index.py index 0af803f33f0..3f507e01b0b 100644 --- a/api/v1/views/index.py +++ b/api/v1/views/index.py @@ -28,8 +28,7 @@ def get_status(): return jsonify({"status": "OK"}) -@app_views.route("/stats", strict_slashes=False, strict_slashes=False, - methods=["GET"]) +@app_views.route("/stats", strict_slashes=False, methods=["GET"]) def get_stats(): """get objects count""" stats = {} From 2e4eec592fa00a8b1a224dce20d5dbd257fb764a Mon Sep 17 00:00:00 2001 From: EgyAbdo10 Date: Tue, 6 Aug 2024 23:08:49 +0300 Subject: [PATCH 25/36] added or modified a file --- api/v1/views/__pycache__/index.cpython-38.pyc | Bin 1147 -> 1147 bytes .../views/__pycache__/states.cpython-38.pyc | Bin 2196 -> 2198 bytes api/v1/views/states.py | 2 +- file.json | 2 +- .../__pycache__/file_storage.cpython-38.pyc | Bin 3020 -> 3032 bytes models/engine/db_storage.py | 1 - models/engine/file_storage.py | 5 +++-- .../test_engine/test_db_storage.py | 2 +- .../test_engine/test_file_storage.py | 15 +++++++++++++++ 9 files changed, 21 insertions(+), 6 deletions(-) diff --git a/api/v1/views/__pycache__/index.cpython-38.pyc b/api/v1/views/__pycache__/index.cpython-38.pyc index 0c511a6ab01564562ab6958035a2708204e6dacc..3817c7d3699caa064aa8735bf0886cb61eeb2ee9 100644 GIT binary patch delta 282 zcmey(@tcDyl$V!_0SJ<6H*%FR%G}~i%uUV9EXhnQzQvXdrlZ&jauSn){K<0|r?QCx z)fS0PHfIW86rbF|v|a}y01_1g61OH{4j{q6%)%(ZD8N)CH#wPE zm+{u*iOeGPx43ijQ&Mw^^?;UC7O{b}@<2tv))ldXgm|GsMX6<(spUl=)8NWLmZTPO zf`njZl@_NK6@k2Sizl%lQ?JZW52UTQh#M$WBmojJpa(iO7Kng!{oPvB|b9 Fb^v|hO*8-i delta 282 zcmey(@tcDyl$V!_0SMOAY~(6ql!@X@%uUV9EXhnQj$%uO(git*$w2<(IgC@;gn(*` zgeIFa1u%+C?qFK40}%j;3ImB-oaw10@x>*HCB^bUZZQXtU|?op6krr!Dw3X@%&f~8 zHF+YlNPQG{ZhlH?PO%=)lFA}BpsFYys0i4)B6g4vFI1=~wJbBWya;3(Tp7rc)FMuh z5X`L7;?$xdkawbZ5(_f*$_({D+KP*~fkH*1K;jl_QGO{fdO+z)06Pqt;T F0|2HBNK*g+ diff --git a/api/v1/views/__pycache__/states.cpython-38.pyc b/api/v1/views/__pycache__/states.cpython-38.pyc index dae9f99429aae57ee9e3a0b7d923e09b79cfc3c6..c394014ecba4b3215eb3199b74388f822a20f818 100644 GIT binary patch delta 267 zcmbOtI8Bf@l$V!_0SK%bHl-EprXi0+t%)1*{7h7BVt26iSt_m9W<^H8VCd1~Zg!lrYsWG&9vQgGGU=CbKe| zuof`^O`UAXtih|va*Lz5B(WqlJ~QRkO^lh3jHFy5Lh%^@!!0aBt4BD6t-$z(4MF983nIko@* delta 264 zcmbOxI7N^*l$V!_0SIoEZ%UKi$h(TkFAT`5VJNmJVOYSpkfD|_ouQVghH(MYLIxLx zSfN_x8m0xzHOvcG7BVbkWMn9mC}AyOt6^$pY-S8*C}A(*s9|Vks$~X?0#!|BXEvGa zz^oxu!~`@~ljRmiaY@IMVjenXr$l$V!_0SHtZHl;Og<6~&R4S{|R0nOt&K~lFE(~xC1C$k!3(X)(gyOb!%3^5QP0XGe7 zuJGh?_O;x|R_JpqU=*Evfx|#l9HbP(38I`HejY%X6vkSn8paZa1&j+Bve}BXY8Vy( z`3o6qnM;^!m_ee=AQeo(3^k0!E;UR*QHCrQh`2ceL?#6&tI0fhIj5RP5hKt{KTXym zRgkS(AVOsF9Zo4D*5v%sypkx+{G_a6a8Mz88Kg`PNCX3MG03S5Oe~C(Rk>o>M1brf zsmUE&vZ5dbNSdJj-o>R~ZwQi+2NF?yx%nxnImLR3xv6=XC6z@?AVEQ>U{YdnYCM=- z#0(PWhKeVHRI-3Xc%UK$If==sMXVqpUZ_w}YFTD#c@Z13vf`4&lGGx0u-3^r+%f`) L2!Oh72Db?SGeLc( delta 582 zcmca1eny-(l$V!_0SKaBuTRU}$oqsz>J~>{YI%H0W^&0b=IqqUTdZY?Ii;y98H$8A zb2AGw3J3yK7YV}&k;!^2HyEQPv$J{%gQRXTrXkC2PG&X6qGuV~b}2EC8R8&95^fsU zT#?D;>}$D^t6Pv#NyO=FuRBuB+d;LPX?)E0g3QHMGA5flT(XWK|+%QxrIgG62&EnC8 Date: Tue, 6 Aug 2024 23:44:36 +0300 Subject: [PATCH 26/36] added or modified a file --- file.json | 2 +- .../__pycache__/db_storage.cpython-38.pyc | Bin 3596 -> 3566 bytes models/engine/db_storage.py | 1 - temp_get_script.py | 46 ++++++++++++++++++ temp_get_script.sh | 33 +++++++++++++ 5 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 temp_get_script.py create mode 100755 temp_get_script.sh diff --git a/file.json b/file.json index 7cebbe2ceaf..63b912337b8 100644 --- a/file.json +++ b/file.json @@ -1 +1 @@ -{"State.235352bb-b214-4147-86e5-9818c6e664b4": {"name": "Arizona", "created_at": "2024-08-06T20:01:16.158363", "updated_at": "2024-08-06T20:01:16.158416", "id": "235352bb-b214-4147-86e5-9818c6e664b4", "__class__": "State"}, "State.c2c26653-1e41-49a1-a994-935d164f19ca": {"name": "California", "created_at": "2024-08-06T20:01:16.396076", "updated_at": "2024-08-06T20:01:16.396129", "id": "c2c26653-1e41-49a1-a994-935d164f19ca", "__class__": "State"}, "State.cac965f8-619b-4f8d-8cb0-28b259a731e7": {"name": "Louisiana", "created_at": "2024-08-06T20:01:16.641705", "updated_at": "2024-08-06T20:01:16.641758", "id": "cac965f8-619b-4f8d-8cb0-28b259a731e7", "__class__": "State"}, "State.e3cc3266-37ee-4fb2-aa92-5e483b0c19aa": {"name": "Texas", "created_at": "2024-08-06T20:01:18.809267", "updated_at": "2024-08-06T20:01:18.809319", "id": "e3cc3266-37ee-4fb2-aa92-5e483b0c19aa", "__class__": "State"}} \ No newline at end of file +{"State.c8e4d500-920a-46d2-abe8-eb6414b39d36": {"name": "Arizona", "created_at": "2024-08-06T20:41:43.169273", "updated_at": "2024-08-06T20:41:43.169324", "id": "c8e4d500-920a-46d2-abe8-eb6414b39d36", "__class__": "State"}, "State.26cb5b25-07d3-4cfd-b570-8d546504c40b": {"name": "California", "created_at": "2024-08-06T20:41:43.405266", "updated_at": "2024-08-06T20:41:43.405317", "id": "26cb5b25-07d3-4cfd-b570-8d546504c40b", "__class__": "State"}, "State.f0faa8b9-43d5-4690-b90c-e9e47ec79c87": {"name": "Louisiana", "created_at": "2024-08-06T20:41:43.640001", "updated_at": "2024-08-06T20:41:43.640051", "id": "f0faa8b9-43d5-4690-b90c-e9e47ec79c87", "__class__": "State"}, "State.08d7084c-40fe-4a47-aac4-5f1b99e04f4e": {"name": "Texas", "created_at": "2024-08-06T20:41:50.429936", "updated_at": "2024-08-06T20:41:50.429999", "id": "08d7084c-40fe-4a47-aac4-5f1b99e04f4e", "__class__": "State"}} \ No newline at end of file diff --git a/models/engine/__pycache__/db_storage.cpython-38.pyc b/models/engine/__pycache__/db_storage.cpython-38.pyc index 32409717bb99c2c29b4ab88ab659a4e8085b3950..432ae495dc907ee8b76c5eb46dcffad8feefe766 100644 GIT binary patch delta 207 zcmeB?c_+;m%FD~e00bpno6;iqH}Xkw894#DHH;+;3m6wNWV01n)i5kzTF9_~xrT8e zV-`ydQwn1*;{w)&47JQP%;^l-OhrbMlenxI*(NXM3S;8|8OAi3k=xiW2-O^g8ip(; zh$#zLfV!D#n1X@!6#Jzx)-pkCb76>;0Gi4KRmr@N5v0-_sJ75xau>HbBkSbj+-}?{ VK!b|~AQnmS9Af0!e3wU`5db@tF?j$0 delta 237 zcmaDS-6O*n%FD~e00grVH>EA-+sG%yW#t9r)-Wt!SjfQ0P{UZlxPWOPLpEEH6HttK zA;SWe8pef;S*$foDU7|03)mJi)H2sFr!!-I-&!f)>0Dtm0a{vGU diff --git a/models/engine/db_storage.py b/models/engine/db_storage.py index 17849498b9f..6bb0171d012 100755 --- a/models/engine/db_storage.py +++ b/models/engine/db_storage.py @@ -89,7 +89,6 @@ def close(self): def get(self, cls, id): """gete a record from db""" - self.reload() if cls in classes.values(): result = self.__session().query(cls).filter_by(id=id).all() if result == []: diff --git a/temp_get_script.py b/temp_get_script.py new file mode 100644 index 00000000000..0e921c9ab92 --- /dev/null +++ b/temp_get_script.py @@ -0,0 +1,46 @@ +#!/usr/bin/python3 +""" Test .get() +""" +from models import storage +from models.state import State + + +def wrapper_all_type(m_class): + res = {} + try: + res = storage.all(m_class) + except: + res = {} + if res is None or len(res.keys()) == 0: + try: + res = storage.all(m_class.__name__) + except: + res = {} + return res + +state_ids = [] +state_ids_found = [] +for state in wrapper_all_type(State).values(): + state_ids.append(state.id) + +if len(state_ids) == 0: + print("empty", end="") +else: + for state_id in state_ids: + state = storage.get(State, state_id) + if state is not None and state.id == state_id: + state_ids_found.append(state_id) + + if len(state_ids_found) != len(state_ids): + # try with `.` + state_ids = wrapper_all_type(State).keys() + state_ids_found = [] + for state_id in state_ids: + state = storage.get(State, state_id) + if state is not None and state.id == state_id: + state_ids_found.append(state_id) + + if len(state_ids_found) == len(state_ids): + print("Get success", end="") + else: + print("Get doesn't retreive all State in storage", end="") diff --git a/temp_get_script.sh b/temp_get_script.sh new file mode 100755 index 00000000000..36c7242de54 --- /dev/null +++ b/temp_get_script.sh @@ -0,0 +1,33 @@ +#!/bin/sh +service mysql start; + +rm -rf file.json; +rm -rf dev/file.json; + +sleep 1; + +echo "DROP USER IF EXISTS 'hbnb_dev'@'localhost';" | sudo mysql -uroot; +echo "DROP DATABASE IF EXISTS hbnb_dev_db;" | sudo mysql -uroot; + +sleep 1; + +echo "CREATE DATABASE IF NOT EXISTS hbnb_dev_db;" | sudo mysql -uroot; +echo "CREATE USER IF NOT EXISTS 'hbnb_dev'@'localhost';" | sudo mysql -uroot; +echo "SET PASSWORD FOR 'hbnb_dev'@'localhost' = 'hbnb_dev_pwd';" | sudo mysql -uroot; +echo "GRANT ALL ON hbnb_dev_db.* TO 'hbnb_dev'@'localhost';" | sudo mysql -uroot; +echo "GRANT SELECT ON performance_schema.* TO 'hbnb_dev'@'localhost';" | sudo mysql -uroot; +echo "FLUSH PRIVILEGES;" | sudo mysql -uroot; + +sleep 1; + +export HBNB_ENV=dev; +export HBNB_MYSQL_USER=hbnb_dev; +export HBNB_MYSQL_PWD=hbnb_dev_pwd; +export HBNB_MYSQL_HOST=localhost; +export HBNB_MYSQL_DB=hbnb_dev_db; +export HBNB_TYPE_STORAGE=db; + +echo 'create State name="Arizona"' | ./console.py ; +echo 'create State name="California"' | ./console.py ; +echo 'create State name="Louisiana"' | ./console.py ; +echo 'create State name="Texas"' | ./console.py ; From b52280b440036b23fababe8b56ecedc017d4a648 Mon Sep 17 00:00:00 2001 From: EgyAbdo10 Date: Wed, 7 Aug 2024 00:46:54 +0300 Subject: [PATCH 27/36] added or modified a file --- api/v1/views/__init__.py | 1 + .../views/__pycache__/__init__.cpython-38.pyc | Bin 354 -> 385 bytes .../views/__pycache__/cities.cpython-38.pyc | Bin 0 -> 2535 bytes api/v1/views/cities.py | 89 ++++++++++++++++++ file.json | 2 +- .../__pycache__/db_storage.cpython-38.pyc | Bin 3566 -> 3566 bytes 6 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 api/v1/views/__pycache__/cities.cpython-38.pyc create mode 100644 api/v1/views/cities.py diff --git a/api/v1/views/__init__.py b/api/v1/views/__init__.py index 5b455eeed5d..abb29f1fff5 100644 --- a/api/v1/views/__init__.py +++ b/api/v1/views/__init__.py @@ -7,6 +7,7 @@ from api.v1.views.index import * from api.v1.views.states import * +from api.v1.views.cities import * # api = Api(app_views) diff --git a/api/v1/views/__pycache__/__init__.cpython-38.pyc b/api/v1/views/__pycache__/__init__.cpython-38.pyc index dd56ab9227846666118a44b3d048a7d7ded284fd..872ab18e1f6310e82faeddb4a7432dc2f6225092 100644 GIT binary patch delta 79 zcmaFF)X2;m%FD~e00dFJo6;svo6-s=^2#zAP1H7;m>R*zK5?J#WCg}x9uA-^3nLFR9}@>7 E04;$E1poj5 diff --git a/api/v1/views/__pycache__/cities.cpython-38.pyc b/api/v1/views/__pycache__/cities.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..710782b8a9b6336f260cefd7eae6a212e4bbc756 GIT binary patch literal 2535 zcmah~OK;mo5auqQq8^bQ=k2uYp)FJtR)VB0Y8XKh$1VDD0ysfap#?!}*EVfRRCZTN zEJ&9+*R(zK(wlwgA=mzj_Al(Am!A9=a%pFlvTO$kN{P$i&dze?n{Q?xRjZ)|*YCgm zvGFrV|KQ8X%Y~QQaLd18U{=dwgwc$2Xp0h*?ab~tEyu`C=61Z6*YR6^CujwoQmbU< z-7M^sTV*4AS*25LRYCSy@Z4(Ecy;>>E3uH3Hwmk}u-QDTu`|!f9%cB;8F(OhO%jAo8i*Q~}{!>gT~r5n4EREgqI zzP`=dN=Ab;iS9i3LLLGHR)c7F4b>nx%c~erOHLJiN>X**NX=!e=6G)H=bNJJRP`~;g%5$%GxI*YeWv{n2snTJAs&2 zl+isxtPusb?cw|US*oI^soIK?=;pPX#{a&I(hZCu>gFoi$opNkn*K^40$T*IueLY2 z5*|nmTifkSY7Z92DbqGQUs|FDs#iCgTX}~!`Q~o2&hqA+RNU>}joVq?BhGe)7V5EG&Wu&%vl!4n(z7Zu^7GaX7T)?@=jGjR({xAqFOvF`U7T>yXyCFfJ@+Vb-L;@^^XVz$9vV2(_D;yg$%srDxy7FE?_RSjyQ6#Vumt zPq~aTn>jC_t$k;8>0^tz5TSQq?fBxc(Rzhe`5RD;Kanw2!G38(kx3wh2e?Za7*;ue z=C+5G84N#K794to1W=YClEn!9{$I9;3*i6ZFF^5EArui9f4O#l^(E0|#${WiJ(cEN z?R1k4A6C9erA)h<5xyP%1%{34G0lVz6WSn&JxZ5Wp0&9#HSIHYXKI^i!fMDNGMc$h1AF_j1?LJ`=I(i z#O=I$D_^fXTsf6Qq#Qc447Yp_hNC2o38oO5Ac9Sic$l&jP9Os`9e#3;XZ#rG3Hufo zqv9)5$bnDLqmCJW_$Pejs4$Ol@R-?7G(cM*aRsH<7z*jYj~bHR0e#WqAZimOHX?05 zcyyYlSOZg@DtI{#aaft~l%C+{$5Vd7!OQGpege~gozU0jzo%n+?2LfDz}4HzACZwg za`tTKaJP}82CNX+Tn1*k1~6}U<53UtIc4S%U=jHHMz91{qKI&K2L?DdC>$4I+i;x4 ziPB-;?258L9yBT^${)EX-o*h^TM*Dq74JY_mmJPiB@7EsplFD`xNFIWEKDCv>(STZ^yB&z~Rp`xnO!{ z(WJ|hDeOX~O0>HHC(%yP#7sNG1GK0zuUK3ZQUy-Ng~9a&b25q&F2XZUyCUx^Zu+n3 zWTqAbQpI?6A|S&x)6s(^*twtaTUZ_v*E(2D/cities", + strict_slashes=False, methods=["GET"]) +def get_state_cities(state_id=None): + """etrieves the list of all City objects of a State: + GET /api/v1/states//cities + """ + state = abortNotExists(State, state_id) + cities_dicts_list = [] + for city in state.cities: + cities_dicts_list.append(city.to_dict()) + return jsonify(cities_dicts_list) + + +@app_views.route("/cities/", strict_slashes=False, methods=["GET"]) +def get_city(city_id=None): + """retrieve a city object""" + # if not city_id: + # objs_dict = storage.all(City) + # obj_list = [] + # for obj in objs_dict.values(): + # obj_list.append(obj.to_dict()) + # return make_response(jsonify(obj_list)) + + # else: + obj = abortNotExists(City, city_id) + return make_response(jsonify(obj.to_dict())) + + +@app_views.route("/states//cities", + strict_slashes=False, methods=["POST"]) +def post_city(state_id): + """Creates a City: POST /api/v1/states//cities""" + abortNotExists(State, state_id) + try: + data = request.get_json() + data["state_id"] = state_id + except Exception: + abort(400, description="Not a JSON") + if "name" not in data.keys(): + abort(400, description="Missing name") + + new_obj = City(**data) + storage.new(new_obj) + storage.save() + return make_response(new_obj.to_dict(), 201) + + +@app_views.route("/cities/", strict_slashes=False, + methods=["DELETE"]) +def delete_city(city_id): + """Deletes a City object:: DELETE /api/v1/cities/""" + obj = abortNotExists(City, city_id) + storage.delete(obj) + storage.save() + return make_response({}, 200) + + +@app_views.route("/cities/", strict_slashes=False, methods=["PUT"]) +def put_city(city_id): + """Updates a City object: PUT /api/v1/cities/""" + obj = abortNotExists(City, city_id) + try: + data = request.get_json() + except Exception: + abort(400, description="Not a JSON") + + for key, val in data.items(): + if key not in ["id", "created_at", "updated_at"]: + setattr(obj, key, val) + + storage.save() + return make_response(obj.to_dict(), 200) diff --git a/file.json b/file.json index 63b912337b8..a356272ec58 100644 --- a/file.json +++ b/file.json @@ -1 +1 @@ -{"State.c8e4d500-920a-46d2-abe8-eb6414b39d36": {"name": "Arizona", "created_at": "2024-08-06T20:41:43.169273", "updated_at": "2024-08-06T20:41:43.169324", "id": "c8e4d500-920a-46d2-abe8-eb6414b39d36", "__class__": "State"}, "State.26cb5b25-07d3-4cfd-b570-8d546504c40b": {"name": "California", "created_at": "2024-08-06T20:41:43.405266", "updated_at": "2024-08-06T20:41:43.405317", "id": "26cb5b25-07d3-4cfd-b570-8d546504c40b", "__class__": "State"}, "State.f0faa8b9-43d5-4690-b90c-e9e47ec79c87": {"name": "Louisiana", "created_at": "2024-08-06T20:41:43.640001", "updated_at": "2024-08-06T20:41:43.640051", "id": "f0faa8b9-43d5-4690-b90c-e9e47ec79c87", "__class__": "State"}, "State.08d7084c-40fe-4a47-aac4-5f1b99e04f4e": {"name": "Texas", "created_at": "2024-08-06T20:41:50.429936", "updated_at": "2024-08-06T20:41:50.429999", "id": "08d7084c-40fe-4a47-aac4-5f1b99e04f4e", "__class__": "State"}} \ No newline at end of file +{"State.c8e4d500-920a-46d2-abe8-eb6414b39d36": {"name": "Arizona", "created_at": "2024-08-06T20:41:43.169273", "updated_at": "2024-08-06T20:41:43.169324", "id": "c8e4d500-920a-46d2-abe8-eb6414b39d36", "__class__": "State"}, "State.26cb5b25-07d3-4cfd-b570-8d546504c40b": {"name": "California", "created_at": "2024-08-06T20:41:43.405266", "updated_at": "2024-08-06T20:41:43.405317", "id": "26cb5b25-07d3-4cfd-b570-8d546504c40b", "__class__": "State"}, "State.f0faa8b9-43d5-4690-b90c-e9e47ec79c87": {"name": "Louisiana", "created_at": "2024-08-06T20:41:43.640001", "updated_at": "2024-08-06T20:41:43.640051", "id": "f0faa8b9-43d5-4690-b90c-e9e47ec79c87", "__class__": "State"}, "State.08d7084c-40fe-4a47-aac4-5f1b99e04f4e": {"name": "Texas", "created_at": "2024-08-06T20:41:50.429936", "updated_at": "2024-08-06T20:41:50.429999", "id": "08d7084c-40fe-4a47-aac4-5f1b99e04f4e", "__class__": "State"}, "State.e64b2418-9677-475e-82d0-a893be492b34": {"name": "Louisiana", "created_at": "2024-08-06T21:22:15.899206", "updated_at": "2024-08-06T21:22:15.899260", "id": "e64b2418-9677-475e-82d0-a893be492b34", "__class__": "State"}, "State.fc3417ef-81a3-4da3-bd3c-11ace162a1b2": {"name": "Louisiana", "created_at": "2024-08-06T21:22:51.200143", "updated_at": "2024-08-06T21:22:51.200192", "id": "fc3417ef-81a3-4da3-bd3c-11ace162a1b2", "__class__": "State"}} \ No newline at end of file diff --git a/models/engine/__pycache__/db_storage.cpython-38.pyc b/models/engine/__pycache__/db_storage.cpython-38.pyc index 432ae495dc907ee8b76c5eb46dcffad8feefe766..e75ebdc2ff1462c4c5c29bf992b511c2518c3786 100644 GIT binary patch delta 23 dcmaDS{Z5)Ml$V!_0SFkoH>FkcZRC5v3jj;r26F%a delta 23 dcmaDS{Z5)Ml$V!_0SHREHl;=IZ{&Nx3jj}s2EzaV From 14973355705b2d0c674d902148a147a47e338f17 Mon Sep 17 00:00:00 2001 From: EgyAbdo10 Date: Wed, 7 Aug 2024 01:17:23 +0300 Subject: [PATCH 28/36] added or modified a file --- api/v1/views/__init__.py | 1 + api/v1/views/amenities.py | 75 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 api/v1/views/amenities.py diff --git a/api/v1/views/__init__.py b/api/v1/views/__init__.py index abb29f1fff5..7d053e02c44 100644 --- a/api/v1/views/__init__.py +++ b/api/v1/views/__init__.py @@ -8,6 +8,7 @@ from api.v1.views.index import * from api.v1.views.states import * from api.v1.views.cities import * +from api.v1.views.amenities import * # api = Api(app_views) diff --git a/api/v1/views/amenities.py b/api/v1/views/amenities.py new file mode 100644 index 00000000000..37ce6a9c059 --- /dev/null +++ b/api/v1/views/amenities.py @@ -0,0 +1,75 @@ +#!/usr/bin/python3 +"""modify Amenity objects via APIs""" +from models.amenity import Amenity +from flask import jsonify, make_response, abort, request +from models import storage +from api.v1.views import app_views + + +def abortNotExists(cls, obj_id): + """exit with a 404 status if obj not found""" + obj = storage.get(cls, obj_id) + if obj is None: + abort(404) + return obj + + +@app_views.route("/amenities", strict_slashes=False, methods=["GET"]) +@app_views.route("/amenities/", + strict_slashes=False, methods=["GET"]) +def get_amenities(amenity_id=None): + """retrieve Amenity objects""" + if not amenity_id: + objs_dict = storage.all(Amenity) + obj_list = [] + for obj in objs_dict.values(): + obj_list.append(obj.to_dict()) + return make_response(jsonify(obj_list)) + + else: + obj = abortNotExists(Amenity, amenity_id) + return make_response(jsonify(obj.to_dict())) + + +@app_views.route("/amenities", strict_slashes=False, methods=["POST"]) +def post_amenities(): + """create a new amenity object""" + try: + data = request.get_json() + except Exception: + abort(400, description="Not a JSON") + if "name" not in data.keys(): + abort(400, description="Missing name") + + new_obj = Amenity(**data) + storage.new(new_obj) + storage.save() + return make_response(new_obj.to_dict(), 201) + + +@app_views.route("/amenities/", strict_slashes=False, + methods=["DELETE"]) +def delete_amenity(amenity_id): + """DELETE /api/v1/amenities/""" + obj = abortNotExists(Amenity, amenity_id) + storage.delete(obj) + storage.save() + return make_response({}, 200) + + +@app_views.route("/amenities/", + strict_slashes=False, methods=["PUT"]) +def put_amenity(amenity_id): + """Updates a amenity_id object: PUT /api/v1/amenities/""" + obj = abortNotExists(Amenity, amenity_id) + try: + data = request.get_json() + except Exception: + abort(400, description="Not a JSON") + + for key, val in data.items(): + if key not in ["id", "created_at", "updated_at"]: + setattr(obj, key, val) + + storage.save() + return make_response(obj.to_dict(), 200) From 5bac26913d4cfae47ee39366d1766d4265714c60 Mon Sep 17 00:00:00 2001 From: EgyAbdo10 Date: Wed, 7 Aug 2024 01:24:29 +0300 Subject: [PATCH 29/36] added or modified a file --- api/v1/views/__init__.py | 1 + api/v1/views/users.py | 73 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 api/v1/views/users.py diff --git a/api/v1/views/__init__.py b/api/v1/views/__init__.py index 7d053e02c44..98eb17924a8 100644 --- a/api/v1/views/__init__.py +++ b/api/v1/views/__init__.py @@ -9,6 +9,7 @@ from api.v1.views.states import * from api.v1.views.cities import * from api.v1.views.amenities import * +from api.v1.views.users import * # api = Api(app_views) diff --git a/api/v1/views/users.py b/api/v1/views/users.py new file mode 100644 index 00000000000..842d03a9a4b --- /dev/null +++ b/api/v1/views/users.py @@ -0,0 +1,73 @@ +#!/usr/bin/python3 +"""modify user objects via APIs""" +from models.user import User +from flask import jsonify, make_response, abort, request +from models import storage +from api.v1.views import app_views + + +def abortNotExists(cls, obj_id): + """exit with a 404 status if obj not found""" + obj = storage.get(cls, obj_id) + if obj is None: + abort(404) + return obj + + +@app_views.route("/users", strict_slashes=False, methods=["GET"]) +@app_views.route("/users/", strict_slashes=False, methods=["GET"]) +def get_users(user_id=None): + """retrieve a user object""" + if not user_id: + objs_dict = storage.all(User) + obj_list = [] + for obj in objs_dict.values(): + obj_list.append(obj.to_dict()) + return make_response(jsonify(obj_list)) + + else: + obj = abortNotExists(User, user_id) + return make_response(jsonify(obj.to_dict())) + + +@app_views.route("/users", strict_slashes=False, methods=["POST"]) +def post_users(): + """create a new user object""" + try: + data = request.get_json() + except Exception: + abort(400, description="Not a JSON") + if "name" not in data.keys(): + abort(400, description="Missing name") + + new_obj = User(**data) + storage.new(new_obj) + storage.save() + return make_response(new_obj.to_dict(), 201) + + +@app_views.route("/users/", strict_slashes=False, + methods=["DELETE"]) +def delete_user(user_id): + """Deletes a user object:: DELETE /api/v1/users/""" + obj = abortNotExists(User, user_id) + storage.delete(obj) + storage.save() + return make_response({}, 200) + + +@app_views.route("/users/", strict_slashes=False, methods=["PUT"]) +def put_user(user_id): + """Updates a user object: PUT /api/v1/users/""" + obj = abortNotExists(User, user_id) + try: + data = request.get_json() + except Exception: + abort(400, description="Not a JSON") + + for key, val in data.items(): + if key not in ["id", "created_at", "updated_at"]: + setattr(obj, key, val) + + storage.save() + return make_response(obj.to_dict(), 200) From 80bdc546b1627274413eecb5ed559f91dd874b12 Mon Sep 17 00:00:00 2001 From: EgyAbdo10 Date: Wed, 7 Aug 2024 01:28:55 +0300 Subject: [PATCH 30/36] added or modified a file --- api/v1/views/users.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/api/v1/views/users.py b/api/v1/views/users.py index 842d03a9a4b..c2e735a9bf1 100644 --- a/api/v1/views/users.py +++ b/api/v1/views/users.py @@ -37,8 +37,10 @@ def post_users(): data = request.get_json() except Exception: abort(400, description="Not a JSON") - if "name" not in data.keys(): - abort(400, description="Missing name") + if "email" not in data.keys(): + abort(400, description="Missing email") + if "password" not in data.keys(): + abort(400, description="Missing password") new_obj = User(**data) storage.new(new_obj) @@ -49,7 +51,7 @@ def post_users(): @app_views.route("/users/", strict_slashes=False, methods=["DELETE"]) def delete_user(user_id): - """Deletes a user object:: DELETE /api/v1/users/""" + """Deletes a user object: DELETE /api/v1/users/""" obj = abortNotExists(User, user_id) storage.delete(obj) storage.save() @@ -66,7 +68,7 @@ def put_user(user_id): abort(400, description="Not a JSON") for key, val in data.items(): - if key not in ["id", "created_at", "updated_at"]: + if key not in ["id", "email", "created_at", "updated_at"]: setattr(obj, key, val) storage.save() From 822ceece8688fb944fc64a470add8e593e82344f Mon Sep 17 00:00:00 2001 From: EgyAbdo10 Date: Wed, 7 Aug 2024 01:52:08 +0300 Subject: [PATCH 31/36] added or modified a file --- .../views/__pycache__/__init__.cpython-38.pyc | Bin 385 -> 449 bytes .../__pycache__/amenities.cpython-38.pyc | Bin 0 -> 2232 bytes .../views/__pycache__/cities.cpython-38.pyc | Bin 2535 -> 2535 bytes api/v1/views/__pycache__/users.cpython-38.pyc | Bin 0 -> 2240 bytes 4 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 api/v1/views/__pycache__/amenities.cpython-38.pyc create mode 100644 api/v1/views/__pycache__/users.cpython-38.pyc diff --git a/api/v1/views/__pycache__/__init__.cpython-38.pyc b/api/v1/views/__pycache__/__init__.cpython-38.pyc index 872ab18e1f6310e82faeddb4a7432dc2f6225092..9e0bb438aa2dfb03c82a807319dbd1ebe087e710 100644 GIT binary patch delta 115 zcmZoN=%_DQdO0yH4TKh4AO%Y%oTaLeCdV5o~2W+cOX(k0l~G^2f|>-62O+xNO&-|zZ%-pPV~ty{CU zn}z*)w+^<){O73K;PuB%7O)x%w=t`~p!T_O^vvF1Ew=O=@58U#T0}3G(d-mkd5*xd zv{?6Ax1QyN=S<}}%g$NPDc0OT?emj&`UOk3#?h@l&r>yyibs!mPswPMCef|? zU&#YV7qzkWtAMtn{l~J%VU2F~lU*JQE(b*}xptFBg;3fT{K=3@Wfn2O4LwB>6STtlou-6Duy{*Pk+I1b}D?>SJQ2-gbP-iYTC=B_8>S;nWpgn z5{V|b{{F19Q}lUa>$sp~FE_ZAiox~!Ra=AJf>z2)Z zy-;h{uODd7}R4lVZ?r^F7K36*hlasSY z!JX^n%f@it8|yvDYH=CxOjZ`ahhR*Ryk1S9_x* z0~Kfwc;`9OzA9n{c?xr2VQ9CIfSkgk+;k1NkTy;ShMo+-6b%z>=qZO5Sh@*p#tQ~c z!IWHv0l5wiv4b0U88>K%#d#C#+`qT6*)#6L%N)_rV^JG`F=-gg=4cOnhw{ilitL8s z5=Q2ysHt^EUqGd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YKE9wl z<&Oc)L%fbupvV{UlIcco5Dl<%zEE9%K?G2L*NY@_F z%zI4xs)!k+C(LmLHG@IHsArazt^n@R2I;_1kpXz3W+Dw0<EH5XxA5at=BER%sW~C-md%Qx^lOGjvs*rR+W&roHXRPIb^vq}(e68#Rv|$16vFK}hI0`>Y+&f?>q@XW=Rzc?zI)fIpZJ~8jXucL!GWzfi&$!|eu$zz$Pp36@WEy(Qvm%{Cz+-kZaS^;0gBB6zjs0Ib1&+*{tyHf-P}u~WS*k0r zqUrt3jTiDXm3$&l1(VY}L8_1`NR`Z_>VQ-~nn~4tS*lRyo~`-iZ=s$Kpyrtavb_n_ zj>mND98#$Mn<|)8EMg&uu?k{zEo$EAgUvp$`ft?Wy#EK8Scc<@*Uj(-3{cu6Wg-Go zho!VxoG2X*?9Rp(mrPu34rC)p@s=6hHiJP!yQ$(i^h3#^tt(-rcuIhG>XJJ6lFJ^KiO%P#&fDk{1^%h=hEowiGS<#JSU4?HV&*X|x zO4;PxE$G#|WjC{Z&78L^Dz6MK>!t?ZiIw5y75kkKhF+Vpc11Bz-1aJ~d|@ Date: Wed, 7 Aug 2024 02:30:43 +0300 Subject: [PATCH 32/36] added or modified a file --- api/v1/views/__init__.py | 1 + api/v1/views/places.py | 88 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 api/v1/views/places.py diff --git a/api/v1/views/__init__.py b/api/v1/views/__init__.py index 98eb17924a8..6a489f457e9 100644 --- a/api/v1/views/__init__.py +++ b/api/v1/views/__init__.py @@ -10,6 +10,7 @@ from api.v1.views.cities import * from api.v1.views.amenities import * from api.v1.views.users import * +from api.v1.views.places import * # api = Api(app_views) diff --git a/api/v1/views/places.py b/api/v1/views/places.py new file mode 100644 index 00000000000..e7b0bd905a1 --- /dev/null +++ b/api/v1/views/places.py @@ -0,0 +1,88 @@ +#!/usr/bin/python3 +"""modify state objects via APIs""" +from models.place import Place +from models.city import City +from models.user import User +from flask import jsonify, make_response, abort, request +from models import storage +from api.v1.views import app_views + + +def abortNotExists(cls, obj_id): + """exit with a 404 status if obj not found""" + obj = storage.get(cls, obj_id) + if obj is None: + abort(404) + return obj + + +@app_views.route("/cities//places", + strict_slashes=False, methods=["GET"]) +def get_city_places(city_id=None): + """Retrieves the list of all Place objects of a City: + GET /api/v1/cities//places + """ + abortNotExists(City, city_id) + city = abortNotExists(City, city_id) + places_dicts_list = [] + for place in city.places: + places_dicts_list.append(place.to_dict()) + return jsonify(places_dicts_list) + + +@app_views.route("/places/", strict_slashes=False, + methods=["GET"]) +def get_places(self, place_id): + """Retrieves a Place object. : GET /api/v1/places/""" + obj = abortNotExists(Place, place_id) + return jsonify(obj.to_dict()) + + +@app_views.route("/cities//places", + strict_slashes=False, methods=["POST"]) +def post_places(city_id): + """create a new state object""" + abortNotExists(City, city_id) + try: + data = request.get_json() + except Exception: + abort(400, description="Not a JSON") + if "name" not in data.keys(): + abort(400, description="Missing name") + if "user_id" not in data.keys(): + abort(400, description="Missing user_id") + + abortNotExists(User, data["user_id"]) # check for user id if it exists + + new_obj = Place(**data) + storage.new(new_obj) + storage.save() + return make_response(new_obj.to_dict(), 201) + + +@app_views.route("/places/", strict_slashes=False, + methods=["DELETE"]) +def delete_place(place_id): + """Deletes a Place object: DELETE /api/v1/places/""" + obj = abortNotExists(Place, place_id) + storage.delete(obj) + storage.save() + return make_response({}, 200) + + +@app_views.route("/places/", strict_slashes=False, methods=["PUT"]) +def put_place(place_id): + """Updates a State object: PUT /api/v1/places/""" + obj = abortNotExists(Place, place_id) + try: + data = request.get_json() + except Exception: + abort(400, description="Not a JSON") + + for key, val in data.items(): + if key not in ["id", "user_id", "city_id", + "created_at", "updated_at"]: + setattr(obj, key, val) + + storage.save() + return make_response(obj.to_dict(), 200) From 0156dad9b0aef9734f2a95978fd64e0f6821d900 Mon Sep 17 00:00:00 2001 From: EgyAbdo10 Date: Wed, 7 Aug 2024 02:44:44 +0300 Subject: [PATCH 33/36] added or modified a file --- .../views/__pycache__/__init__.cpython-38.pyc | Bin 449 -> 480 bytes .../views/__pycache__/places.cpython-38.pyc | Bin 0 -> 2690 bytes api/v1/views/__pycache__/users.cpython-38.pyc | Bin 2240 -> 2240 bytes api/v1/views/places.py | 12 ++++++------ 4 files changed, 6 insertions(+), 6 deletions(-) create mode 100644 api/v1/views/__pycache__/places.cpython-38.pyc diff --git a/api/v1/views/__pycache__/__init__.cpython-38.pyc b/api/v1/views/__pycache__/__init__.cpython-38.pyc index 9e0bb438aa2dfb03c82a807319dbd1ebe087e710..34cd4d1471c67e5e696bb24422784c041ddfb9b6 100644 GIT binary patch delta 86 zcmX@e{D7G^l$V!_0SMaGZc6(-kyn;6Xri_kD`N^<4%ft@Xh!ad=lVpVgcA!g^~wzO h$}&^Si}ea}5|dLWM>B?q2mm#*F!C_-F>x@$AOIZY6r2D6 delta 57 zcmaFBe2|$pl$V!_0SI~)ZA!a2kyn<{YofN-#M%f(u8G(BCRZ{B3-JMESr~bk`ItBu GArJtNZ_1J4q?^nqFFNmQ%m! zr$>t=;9xXpLnp13YYnuABLaQ5uPCT>dMLJ2Ro{~M%oYA`J zG2IM3_0#~(siRS|#i-NtjMmH^jX7Ir=IA-CIenygtI(XM7qsRKt*sjMOM{DPM&tHQ z&`qKi3$pbs){-LV$5C)=<(@bMFpN4;&I+nQu(%MM?EGaj3^12@n{1lDM#II*pJy`(K2y?;YVHwY3{BX+HMq>4#4>ms%grDPu3fnn2pP$q2;w&S5_B>dw6k7^ zF2}zS@WkR}m{(aFO!5*)bxT>TL?{=G!s_396UZ8k#(r@aU<%+jsDe!cB7%u6Z732Rnv|yXL9LDETpKwOu~c4FssCan@@v0m}|6R z88gvXg!c}te507+OJ#kv^q_94nvgth$xtMb*knSLQYJSuDwbQ|$I*pwA#*ik3m`~C z0%Uu@*^#tMHVlA|Y?*hBpJsNgp}B7jt$q8zH~<(QU6Rfa00l6~VEsFQC1!ml0=db8 z1RMymb`T{=pyPi;59|z(2@8IZU$E(51j!p*)24M-1HdiVt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1/views/__pycache__/users.cpython-38.pyc b/api/v1/views/__pycache__/users.cpython-38.pyc index a0c40a3311cbc97eb546e0495e3f80d43bd5d7c2..87aa0a181dc3517bb19ad328b07ab64e6ea97a6a 100644 GIT binary patch delta 19 ZcmX>gctDUVl$V!_0SF}5Y~gctDUVl$V!_0SI_kY~/places", strict_slashes=False, methods=["POST"]) def post_places(city_id): - """create a new state object""" + """create a new place object""" abortNotExists(City, city_id) try: data = request.get_json() + data["city_id"] = city_id except Exception: abort(400, description="Not a JSON") - if "name" not in data.keys(): - abort(400, description="Missing name") if "user_id" not in data.keys(): abort(400, description="Missing user_id") abortNotExists(User, data["user_id"]) # check for user id if it exists - + if "name" not in data.keys(): + abort(400, description="Missing name") new_obj = Place(**data) storage.new(new_obj) storage.save() @@ -72,7 +72,7 @@ def delete_place(place_id): @app_views.route("/places/", strict_slashes=False, methods=["PUT"]) def put_place(place_id): - """Updates a State object: PUT /api/v1/places/""" + """Updates a place object: PUT /api/v1/places/""" obj = abortNotExists(Place, place_id) try: data = request.get_json() From 5a11d25905a46fb3ff96f70df683164ee8d3bc9a Mon Sep 17 00:00:00 2001 From: EgyAbdo10 Date: Wed, 7 Aug 2024 02:47:55 +0300 Subject: [PATCH 34/36] added or modified a file --- .../views/__pycache__/places.cpython-38.pyc | Bin 2690 -> 2677 bytes api/v1/views/places.py | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/api/v1/views/__pycache__/places.cpython-38.pyc b/api/v1/views/__pycache__/places.cpython-38.pyc index 563497c8fdba56d86a6c83f95fadb06902f45c4e..4db666f02ecf18624ee1fea8e927ffd609f9223d 100644 GIT binary patch delta 86 zcmZn?{VKv6%FD~e00e)xZc00}kyoBYn-Ro?0wy5M48+brTr378N*GEQYZ#iDY8gwI bY8WSnvqUqkWZJxo|o%FD~e00fm=Hl>}|$ScpH%>?2?0W**WVP_yN76TF`3?+;;jLl57OeIV; mOq0V|qB%5~Z?P1o=A>=j!t#KLQZ}T+v`%D0Y?-V!y diff --git a/api/v1/views/places.py b/api/v1/views/places.py index 744434a059b..60312af7423 100644 --- a/api/v1/views/places.py +++ b/api/v1/views/places.py @@ -32,7 +32,7 @@ def get_city_places(city_id=None): @app_views.route("/places/", strict_slashes=False, methods=["GET"]) -def get_places(self, place_id): +def get_places(place_id): """Retrieves a Place object. : GET /api/v1/places/""" obj = abortNotExists(Place, place_id) return jsonify(obj.to_dict()) From e98be481846d22f2ae1fdde86c1bb91d1915e918 Mon Sep 17 00:00:00 2001 From: EgyAbdo10 Date: Wed, 7 Aug 2024 03:37:28 +0300 Subject: [PATCH 35/36] added or modified a file --- api/v1/views/__init__.py | 1 + api/v1/views/places.py | 1 - api/v1/views/places_reviews.py | 90 ++++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 api/v1/views/places_reviews.py diff --git a/api/v1/views/__init__.py b/api/v1/views/__init__.py index 6a489f457e9..fe6c209478c 100644 --- a/api/v1/views/__init__.py +++ b/api/v1/views/__init__.py @@ -11,6 +11,7 @@ from api.v1.views.amenities import * from api.v1.views.users import * from api.v1.views.places import * +from api.v1.views.places_reviews import * # api = Api(app_views) diff --git a/api/v1/views/places.py b/api/v1/views/places.py index 60312af7423..16970b400a3 100644 --- a/api/v1/views/places.py +++ b/api/v1/views/places.py @@ -22,7 +22,6 @@ def get_city_places(city_id=None): """Retrieves the list of all Place objects of a City: GET /api/v1/cities//places """ - abortNotExists(City, city_id) city = abortNotExists(City, city_id) places_dicts_list = [] for place in city.places: diff --git a/api/v1/views/places_reviews.py b/api/v1/views/places_reviews.py new file mode 100644 index 00000000000..1429d06646d --- /dev/null +++ b/api/v1/views/places_reviews.py @@ -0,0 +1,90 @@ +#!/usr/bin/python3 +"""modify place objects via APIs""" +from models.place import Place +from models.city import City +from models.user import User +from models.review import Review +from flask import jsonify, make_response, abort, request +from models import storage +from api.v1.views import app_views + + +def abortNotExists(cls, obj_id): + """exit with a 404 status if obj not found""" + obj = storage.get(cls, obj_id) + if obj is None: + abort(404) + return obj + + +@app_views.route("/places//reviews", + strict_slashes=False, methods=["GET"]) +def get_place_reviews(place_id=None): + """ + Retrieves the list of all Review objects of a Place: + GET /api/v1/places//reviews + """ + place = abortNotExists(Place, place_id) + reviews_dicts_list = [] + for review in place.reviews: + reviews_dicts_list.append(review.to_dict()) + return jsonify(reviews_dicts_list) + + +@app_views.route("/reviews/", strict_slashes=False, + methods=["GET"]) +def get_reviews(review_id): + """Retrieves a Review object. : GET /api/v1/reviews/""" + obj = abortNotExists(Review, review_id) + return jsonify(obj.to_dict()) + + +@app_views.route("/places//reviews", + strict_slashes=False, methods=["POST"]) +def post_reviews(place_id): + """Creates a Review: POST /api/v1/places//reviews""" + abortNotExists(Place, place_id) + try: + data = request.get_json() + data["place_id"] = place_id + except Exception: + abort(400, description="Not a JSON") + if "user_id" not in data.keys(): + abort(400, description="Missing user_id") + + abortNotExists(User, data["user_id"]) # check for user id if it exists + if "text" not in data.keys(): + abort(400, description="Missing text") + + new_obj = Review(**data) + storage.new(new_obj) + storage.save() + return make_response(new_obj.to_dict(), 201) + + +@app_views.route("/reviews/", strict_slashes=False, + methods=["DELETE"]) +def delete_review(review_id): + """DELETE a review: /api/v1/reviews/""" + obj = abortNotExists(Review, review_id) + storage.delete(obj) + storage.save() + return make_response({}, 200) + + +@app_views.route("/reviews/", strict_slashes=False, methods=["PUT"]) +def put_review(review_id): + """Updates a Review object: PUT /api/v1/reviews/""" + obj = abortNotExists(Review, review_id) + try: + data = request.get_json() + except Exception: + abort(400, description="Not a JSON") + + for key, val in data.items(): + if key not in ["id", "user_id", "place_id", + "created_at", "updated_at"]: + setattr(obj, key, val) + + storage.save() + return make_response(obj.to_dict(), 200) From 88c1e9e53b232009d1438602070c7d89a53403b4 Mon Sep 17 00:00:00 2001 From: EgyAbdo10 Date: Wed, 7 Aug 2024 03:49:35 +0300 Subject: [PATCH 36/36] added or modified a file --- api/v1/__pycache__/app.cpython-38.pyc | Bin 1010 -> 1097 bytes api/v1/app.py | 2 ++ .../views/__pycache__/__init__.cpython-38.pyc | Bin 480 -> 519 bytes .../views/__pycache__/places.cpython-38.pyc | Bin 2677 -> 2665 bytes .../__pycache__/places_reviews.cpython-38.pyc | Bin 0 -> 2764 bytes 5 files changed, 2 insertions(+) create mode 100644 api/v1/views/__pycache__/places_reviews.cpython-38.pyc diff --git a/api/v1/__pycache__/app.cpython-38.pyc b/api/v1/__pycache__/app.cpython-38.pyc index 303a8359878b504a002d8ae98b09798fa534c21b..b47a07d7579b1c29ef92ea7a4e4201c6d9e30d73 100644 GIT binary patch delta 486 zcmYjNy-piJ5Wd+x;`Mp={KFZL5Pb|1p++c)gd(Mj1WL2b$zs;Y8T(F};~F<9pasd? z3xqd_k_SkNH0e^La?KM^QZZ{Q52%K={5^U_Wi?M+Un;B$)(Y4@Q{I%`W9e6hG;3jG`SHS8nXL=al0k*Mo z6>wzT8SI`5`io7QV9)klgzJ|;-&SZ7#)Qwm7`K_QARceH#PzX{8`ly7Y@G&!t@(Yr zH-JTW{NdzuCSL8@MnT!9EH7t`gZ-rqz&6R1MMY<>tdF69sQv+mrpIHJ!VfD+*N-qh zG0X>oLI#qa1I3>EA6dB;vqk6gFvp2Y^Wq{M6;+N~9Q|LZ?G-9br^75y)B2})3!As{ zeQcxAWLTc3X9bm{>UZ*}(k!*w5f!wmNaSx**E`?cLQ<7Kdwto*vITWCEwGxn*S`Pq bCA&~2pjRdpBqEX_=rsiq?+`+vKrQzZ7*1+! delta 385 zcmYjNy-EW?5Wcw$=6-gQ%jF_i*x3X@(kc=~Q0zsJvp52?L1S_UlcY&wku(;HVN09j z4McniU%|)l0mRt^#T}S$cE0)fc0atYvbt0%aQHlo-n#9%+J^V}?$Nz=bvT7oYPnF_ zTLL&*_9|G%GI}#$rpio&{t__2aOQBPrbCo>F1?~kW2~fg9bk0|^t{G2W{mj0SR?bY zm*`m6v4-)Z00%cNoMtjDdn+>_j-g>r#JPD9`&S`X x@jnn1v>rxe8_8;-njIl%oc~+AlCawD9S#Z{_jTJ!AMUU#i3FrI;h9!x>jzMTQ;Prq diff --git a/api/v1/app.py b/api/v1/app.py index 62f0aa73ee0..61d65c7a92f 100644 --- a/api/v1/app.py +++ b/api/v1/app.py @@ -6,9 +6,11 @@ from models import storage from api.v1.views import app_views from os import getenv +from flask_cors import CORS app = Flask(__name__) +CORS(app, resources={"/*": {"origins": "0.0.0.0"}}) app.register_blueprint(app_views) diff --git a/api/v1/views/__pycache__/__init__.cpython-38.pyc b/api/v1/views/__pycache__/__init__.cpython-38.pyc index 34cd4d1471c67e5e696bb24422784c041ddfb9b6..a9d2b4208f11cfd1dae29c83ad830f77a57f4473 100644 GIT binary patch delta 97 zcmaFB+|I%m%FD~e00grRZc0;Sn#d=^7&TElh?OygEr)wzRWu{d#A}OXqNEcGGWE&~ o^~y3+%Zv32auSnMi{pz@LEOm|j3Ht|KoeLPd6@Z_I2aKS02ligjQ{`u delta 60 zcmZo?dBDsU%FD~e00eDoH>Le%oX97`7&K8kXku#wBlpC6izm-x3>FapO0zKXF!M2S HFv1`J$sd_C7)2&aF~48~OR`PoV!6Vou=zgA hO-4qI$vfHpGTLq4&OVEg(PMKECmSOp_vA<}833PU4l$V!_0SNwX-IR7{Bky%4UMnE4grS77hM}2>aq@E}4Mw@i0?aQsctFb7 txELq@W4^+uxcM^6O-4q|$!ppEGTLum%|45f(Q~sKCmSOp&tzXN834Af8Cd`T diff --git a/api/v1/views/__pycache__/places_reviews.cpython-38.pyc b/api/v1/views/__pycache__/places_reviews.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..50426017a009ea622aff0722c4e7fa26132eb0ae GIT binary patch literal 2764 zcmai0OK;mo5a#kFilXI5oWxF@hHcS@iquMwpa={j$jdGIa*QNKQ=x^xXxBDvN>p}N ziY-XJIM)u6sZ@~4( z@4syYCByg|A0{sc9&W*3`~w3uY6d0LOi0tLnFM7kv6^rkv#@4+$~)CIn*jK4kl`44=hvCyc`D zSFVRbMzSNqcnhNnTd54U(o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