From 8c96b71fc7e732ea8c4ff2da03cd9432badcd884 Mon Sep 17 00:00:00 2001 From: Venkat Date: Tue, 11 Jun 2024 23:48:02 -0400 Subject: [PATCH] update --- .../__pycache__/anyscale_dag.cpython-311.pyc | Bin 0 -> 1502 bytes .../anyscale_service.cpython-311.pyc | Bin 0 -> 2201 bytes tests/hooks/test_anyscale_hook.py | 40 +++++++++--------- 3 files changed, 20 insertions(+), 20 deletions(-) create mode 100644 tests/dags/example_dags/__pycache__/anyscale_dag.cpython-311.pyc create mode 100644 tests/dags/example_dags/__pycache__/anyscale_service.cpython-311.pyc diff --git a/tests/dags/example_dags/__pycache__/anyscale_dag.cpython-311.pyc b/tests/dags/example_dags/__pycache__/anyscale_dag.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..5e8baefde5f50a031c568b4bf1c0b33a7f1aeaa3 GIT binary patch literal 1502 zcmZuw%}*Og6rc6i8h@^Bz=V*hlC($XGksag%5vAtoxIx~it z6USESfm?g%0rfyt!C%lnqB0VP(VQanQf{u2Q%-$jV=Ai7&c2U%v-5uMH*bHW}; z`lHkOJ%-Sq+8K|`rSU3ZAoL?5h!`&NPy=~J!!WcTaU))|5gpo5H|E6~@u3}a6Q0>H z!H$ze1W`mxk|YzyQG`z59SxFzCk0W1q)#))kmCg2%UJejvymjZ#stLUG<7}tJbkq< zzYlgJ1G}QcqDfL9MUprz9mnA`ct@j=g}6y3=>(Y~)1(Yuj{Y~}OdF9KzZfJ%v!}Di zz{<&x8GS+{PxDYqaSK&%Ug(8tL?sCpR5%`06Iv4L3S2c*bff+;sMs?sI-m<%-EGei zb-%}(*rlHZ+secaYq`PRW9Kgup$i}#T|~6d#b0R5@SW*7epgUlHB~&=^C?q#LPP2k zZU?>{VlGsQ3(SPAVJM4w*l~5J1-i?q%3ZB6Dp*gMS~--f^w75fFYc)!s+t^=-j_C##aOI57t-L@2WskjJOvr|neQ((ShI|N_>QQC<4Sl_+l;Wo9q%u%_^ zRGLairP7)&$8X!jVJby^xP>r)@>E7=a~Snt4S4YI3wwMyQG(l5i|Jp4>BeA5Ep$&P zGlY(Eoo$xT-rM7E#X&x4MFt4OL1r+GCKvk1f>ZLP@5tf( z@BJVA^W4JGH)px^gY?V9#6eTWZp*?gX>G{qS(zye(g`#2Hv;imi-YLELgl6Y^rFnX zC3ClBdP-W$a_SvfoH|@M+&L@GpBLw)H7`r|`@<=VC7DbQrqX3N2E=PE`lvLxjf_dq Kqsi_8Y5xH6AJhB* literal 0 HcmV?d00001 diff --git a/tests/dags/example_dags/__pycache__/anyscale_service.cpython-311.pyc b/tests/dags/example_dags/__pycache__/anyscale_service.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..242ec850446a952f6473103e5ae31ddd13c2d8f1 GIT binary patch literal 2201 zcmZuyOK)366rLMDuHW&a#AzPIqHS6uV&_2xjS#{#ZK*_4ph5^QxSHOX*q7WFGvfqD zEecW>EW2wLEFu;G)ch87gNnEssS*-GB0E>@sw>VowrMEinR936oS8X~?;QV_&885v z$G^1KAIA~;Q!R!qJD5C8X$aj%1QE?f4r(GtYigQWkJ)2Rq#5bYBX-n@HDmpG)Q&rP zQ}54XcEU+ElQ54HeGE}V5+q4ddl7^l!Z>O~hhG}F8p-Tu_u##UFb2Hb_j)r$#+!;C zA$gi21yUsXerYcTaxjisGXs2`oSxhQiXmfI1OS9KZlwp_~OIH5ju2{$~~@G%!M#RX=#wlFYjfeM6j zlUcs7JXaRD*`}leul8@;#J1E;EX;Ptmy_(sr7tN2F6DxG0~c?f94cIAxVy4cTUxFy z%=_Kt#l`KC)15ax#|LM^*Il<-D~sEg+d}w!rCx7=?wwmT5U7u?AfCw$`gPwEypEaK zwl-;<(RE&LQ%rarTLDDee4p|Z=145%FQ5P#PS`Kbe zqr)tj8yKd72ZqVC3X|ow3}P{vfyZqNJPA(bGNazJ7*+bg>lR?h#wNhT1Z7#*02rIV zk`aPiCO~l16g*WTKfMj)J`$tEMMx;r4%)tUJgx7b+i3R%{!k7CeSY&&U)3`wK4BAZ_^^MIl>cUvEX&^E3Xew1vv|gp} zhrt^_cF^N=`M1hKkX}4UFFr~y?yQE{!tdGBzh+PW^i5b_=tWTO%oC*LmYylHbLFpS z^1Hcjuiw4C)Bin%OOTwjTuWHkwzgl$Ze?vX!pB45(Z-zGYKZgWYPLsn|0G z0tO`#F;$-Adw1N`B~wb8$f#z zP18bjKKQ>LqH=J&hiExC-a~XXINn2aF*x3Pag-~E<(aTJb?^LxH+KuWjf3LcqvBjR zIU7z)hvWIMG;{Cb?#Dst+(GHwqtdzFcp^X6LqK*iy$N*Ubb#`I#FIN_7@Z3XvtfQU zoR|tTgE+S%VlcH3X6C}oOqeW(xoTKCALc&`OO@cY_kv<0D7+sQ zt_A%bW{Y8|946Aea%LJX0`g1|FuOMs)rvhdA{lh*jR#+-drzEI2lVJEH~{3CA_1D} S<&ZWROkX%a7lL8$2jCw*DWRVL literal 0 HcmV?d00001 diff --git a/tests/hooks/test_anyscale_hook.py b/tests/hooks/test_anyscale_hook.py index 3bef42c..50e9088 100644 --- a/tests/hooks/test_anyscale_hook.py +++ b/tests/hooks/test_anyscale_hook.py @@ -158,6 +158,24 @@ def test_get_logs(self, mock_get_logs): mock_get_logs.assert_called_once_with("test_job_id") assert result == "job logs" + @patch('anyscale_provider.hooks.anyscale.AnyscaleHook.get_logs') + def test_get_logs_empty(self, mock_get_logs): + mock_get_logs.return_value = "" + + result = self.hook.get_logs("test_job_id") + + mock_get_logs.assert_called_once_with("test_job_id") + assert result == "" + + @patch('anyscale_provider.hooks.anyscale.AnyscaleHook.get_logs') + def test_get_logs_error(self, mock_get_logs): + mock_get_logs.side_effect = AirflowException("Failed to get logs") + + with pytest.raises(AirflowException) as exc: + self.hook.get_logs("test_job_id") + + assert str(exc.value) == "Failed to get logs" + @patch('anyscale_provider.hooks.anyscale.AnyscaleHook.get_service_status') def test_get_service_status(self, mock_get_service_status): mock_service_status = ServiceStatus(id="test_service_id", name="test_service", query_url="http://example.com", state=ServiceState.RUNNING) @@ -205,29 +223,11 @@ def test_terminate_job_with_delay(self, mock_sleep): mock_terminate.assert_called_once_with(name="test_job_id") mock_sleep.assert_called_once_with(1) assert result is True - + @patch("anyscale_provider.hooks.anyscale.time.sleep", return_value=None) def test_terminate_service_with_delay(self, mock_sleep): with patch.object(self.hook.sdk.service, 'terminate', return_value=None) as mock_terminate: result = self.hook.terminate_service("test_service_id", time_delay=1) mock_terminate.assert_called_once_with(name="test_service_id") mock_sleep.assert_called_once_with(1) - assert result is True - - @patch('anyscale_provider.hooks.anyscale.AnyscaleHook.get_logs') - def test_get_logs_empty(self, mock_get_logs): - mock_get_logs.return_value = "" - - result = self.hook.get_logs("test_job_id") - - mock_get_logs.assert_called_once_with("test_job_id") - assert result == "" - - @patch('anyscale_provider.hooks.anyscale.AnyscaleHook.get_logs') - def test_get_logs_error(self, mock_get_logs): - mock_get_logs.side_effect = AirflowException("Failed to get logs") - - with pytest.raises(AirflowException) as exc: - self.hook.get_logs("test_job_id") - - assert str(exc.value) == "Failed to get logs" \ No newline at end of file + assert result is True \ No newline at end of file