a ,"?g¯ ã@sÊddlZddlmmZddlZddlZddlm Z m Z m Z ddlm Z ddl m Z ejdd„ƒZGdd„dejƒZd d „Zd d „Zd d„Zdd„Zdd„Zdd„Zdd„Zdd„ZedkrÆe ¡dS)éN)Úauthenticate_biolucidaÚthumbnail_by_image_idÚimage_info_by_image_id)Ú Biolucida)ÚappcCsdtjd<t ¡S)NTÚTESTING)rÚconfigÚ test_client©r r úC/home/cmiss/Jenkins/workspace/SPARC-API-DEV/tests/test_biolucida.pyÚclient s r c@s4eZdZdd„Zdd„Zdd„Zdd„Zd d „Zd S) ÚBiolucidaTestCasecCs tƒ}tƒ| d| ¡¡dS)NÚ)rrZassertNotEqualÚtoken)ÚselfÚblr r r Útest_authenticatesz#BiolucidaTestCase.test_authenticatecCs,tdƒ}| d|d¡| d|d¡dS)Né’ÚsuccessÚstatusZ115Z collection_id)rÚ assertEqual)rZ image_infor r r Útest_get_image_infosz%BiolucidaTestCase.test_get_image_infocCstdƒ}| | d¡¡dS)Nró/9j/4AAQSkZJRgABAQAAAQ)rÚ assertTrueÚ startswith)rÚ thumbnailr r r Útest_get_thumbnailsz$BiolucidaTestCase.test_get_thumbnailcCs,tƒ}| d¡tdƒ}| | d¡¡dS)NZ a20f155e818fbfebbb03275f30f87697rr©rÚ set_tokenrrr©rrrr r r Útest_old_token!s z BiolucidaTestCase.test_old_tokencCs,tƒ}| d¡tdƒ}| | d¡¡dS)NZ bad_tokenrrrrr r r Útest_bad_token's z BiolucidaTestCase.test_bad_tokenN)Ú__name__Ú __module__Ú __qualname__rrrr r!r r r r r s r c Csn| d¡}d}|j}||v}|sˆt d|fd||f¡t |¡dt ¡vsRt |¡r\t |¡ndt |¡dœ}dd|i}tt  |¡ƒ‚d}}}d }|j}||v}|st d|fd||f¡t |¡dt ¡vsÞt |¡rèt |¡ndt |¡dœ}dd|i}tt  |¡ƒ‚d}}}|jd}d }||k}|s‚t d |fd ||f¡t |¡t |¡d œ}dd|i} tt  | ¡ƒ‚d}}}|jd}d }||k}|sðt d |fd ||f¡t |¡t |¡d œ}dd|i} tt  | ¡ƒ‚d}}}|jd}d}||k}|s^t d |fd ||f¡t |¡t |¡d œ}dd|i} tt  | ¡ƒ‚d}}}dS)Nz/image_xmp_info/2727Ú pixel_width©Úin©z,%(py1)s in %(py5)s {%(py5)s = %(py3)s.json }Úr©Úpy1Úpy3Úpy5úassert %(py7)sÚpy7Úchannel_coloursz0.415133©ú==©z%(py1)s == %(py4)s©r+Úpy4úassert %(py6)sÚpy6Ú pixel_heightÚ z_spacingú1.000000© ÚgetÚjsonÚ @pytest_arÚ_call_reprcompareÚ _safereprÚ @py_builtinsÚlocalsÚ_should_repr_global_nameÚAssertionErrorÚ_format_explanation© r r)Ú @py_assert0Ú @py_assert4Ú @py_assert2Ú @py_format6Ú @py_format8Ú @py_assert3Ú @py_format5Ú @py_format7r r r Útest_image_xmp_info_2727.s  ŠŒnnrOc Csà| d¡}d}|j}||v}|sˆt d|fd||f¡t |¡dt ¡vsRt |¡r\t |¡ndt |¡dœ}dd|i}tt  |¡ƒ‚d}}}|jd}d }||k}|sôt d |fd ||f¡t |¡t |¡d œ}d d|i} tt  | ¡ƒ‚d}}}|jd}d }||k}|sbt d |fd ||f¡t |¡t |¡d œ}d d|i} tt  | ¡ƒ‚d}}}|jd}d}||k}|sÐt d |fd ||f¡t |¡t |¡d œ}d d|i} tt  | ¡ƒ‚d}}}dS)Nz/image_xmp_info/1197r%r&r(r)r*r.r/z0.008184r1r3r4r6r7r8r9r:r;rFr r r Útest_image_xmp_info_11978s  ŠlnrPc Csn| d¡}|j}d}||k}|sˆt d|fd||f¡dt ¡vsJt |¡rTt |¡ndt |¡t |¡dœ}dd|i}tt  |¡ƒ‚d}}}d }|j }||v}|st d |fd ||f¡t |¡dt ¡vsÞt |¡rèt |¡ndt |¡d œ}dd|i}tt  |¡ƒ‚d}}}|j d }d }||k}|s‚t d|fd||f¡t |¡t |¡dœ} dd| i} tt  | ¡ƒ‚d}}}|j d}d }||k}|sðt d|fd||f¡t |¡t |¡dœ} dd| i} tt  | ¡ƒ‚d}}}|j d}d}||k}|s^t d|fd||f¡t |¡t |¡dœ} dd| i} tt  | ¡ƒ‚d}}}dS)Nz/image_xmp_info/850éÈr1©z3%(py2)s {%(py2)s = %(py0)s.status_code } == %(py5)sr)©Úpy0Úpy2r-r.r/r%r&r(r*z0.830266r3r4r6r7r8r9r:© r<Ú status_coder>r?rArBrCr@rDrEr=© r r)Ú @py_assert1rHrLrJrKrGrIrMrNr r r Útest_image_xmp_info_850As  ŠŒnnrZcCs˜| d¡}|j}d}||k}|sˆt d|fd||f¡dt ¡vsJt |¡rTt |¡ndt |¡t |¡dœ}dd|i}tt  |¡ƒ‚d}}}dS) Nz/image_xmp_info/XYZér1rRr)rSr.r/© r<rWr>r?rArBrCr@rDrE©r r)rYrHrLrJrKr r r Ú$test_image_xmp_info_invalid_image_idKs r^c Cs’| d¡}|j}d}||k}|sˆt d|fd||f¡dt ¡vsJt |¡rTt |¡ndt |¡t |¡dœ}dd|i}tt  |¡ƒ‚d}}}d }|j }||v}|st d |fd ||f¡t |¡dt ¡vsÞt |¡rèt |¡ndt |¡d œ}dd|i}tt  |¡ƒ‚d}}}|j d }d }||k}|s‚t d|fd||f¡t |¡t |¡dœ} dd| i} tt  | ¡ƒ‚d}}}dS)Nz/image_blv_link/849rQr1rRr)rSr.r/Úlinkr&r(r*z-https://sparc.biolucida.net:443/link?l=jpmqiXr3r4r6r7rVrXr r r Útest_image_blv_link_849Qs ŠŒr`cCs˜| d¡}|j}d}||k}|sˆt d|fd||f¡dt ¡vsJt |¡rTt |¡ndt |¡t |¡dœ}dd|i}tt  |¡ƒ‚d}}}dS) Nz/image_blv_link/XYZr[r1rRr)rSr.r/r\r]r r r Ú$test_image_blv_link_invalid_image_idYs rac Csr| d¡}d}|j}||v}|sˆt d|fd||f¡t |¡dt ¡vsRt |¡r\t |¡ndt |¡dœ}dd|i}tt  |¡ƒ‚d}}}|jd }d }||k}|sôt d |fd ||f¡t |¡t |¡d œ}dd|i} tt  | ¡ƒ‚d}}}|jd}d}||k}|sbt d |fd ||f¡t |¡t |¡d œ}dd|i} tt  | ¡ƒ‚d}}}dS)Nz/image_search/77Zdataset_imagesr&r(r)r*r.r/Zdiscover_dataset_idZ77r1r3r4r6r7rrr;rFr r r Útest_image_search_dataset_77_s ŠlrbcCsz| d¡}|jd}d}||k}|sjt d|fd||f¡t |¡t |¡dœ}dd|i}tt |¡ƒ‚d}}}dS) Nz/image_search/292rÚfailurer1r3r4r6r7)r<r=r>r?r@rDrE)r r)rGrLrIrMrNr r r Útest_image_search_dataset_292fs rdÚ__main__)ÚbuiltinsrAÚ_pytest.assertion.rewriteÚ assertionÚrewriter>ÚpytestÚunittestZapp.mainrrrrrÚfixturer ÚTestCaser rOrPrZr^r`rarbrdr"Úmainr r r r Ús""