YouTube-operational-API icon indicating copy to clipboard operation
YouTube-operational-API copied to clipboard

Finish unit tests

Open Benjamin-Loison opened this issue 3 years ago • 16 comments

Don't forget not to make the unit tests based on my personal channels.

Once done remove this comment.

Could run everyday unit test as YouTube UI evolves.

Maybe some manually triggered unit tests for the no-key service would also make sense.

Not to suffer of #11 could run these tests regularly on a private instance and notify me when something goes wrong.

Should verify the whole returned JSON instead of just a subset of entries.

Should also exhaustively but, as a different set if repeatedly, establish Stack Overflow example tests.

+6

Benjamin-Loison avatar Sep 08 '22 22:09 Benjamin-Loison

Note that redefining die with function does not work and it does not seem possible to disable die.

Benjamin-Loison avatar Dec 03 '23 03:12 Benjamin-Loison

Note that prefer to be independent from other persons who may possibly make the unit test incorrect, but do not use my own channel but can use ad hoc channels that I own.

Benjamin-Loison avatar Dec 03 '23 04:12 Benjamin-Loison

Also note that the purpose of the unit test is mainly to monitor YouTube UI changes.

Benjamin-Loison avatar Dec 03 '23 04:12 Benjamin-Loison

Could verify when specific value with another normal one but let us left this for future work. Just returning two different values for each field enables to some extent to verify that we retrieve what we expect. Also reduce as most as possible workload by using id instead of handles and test handles once.

Benjamin-Loison avatar Dec 03 '23 14:12 Benjamin-Loison

Should verify pagination when there is one.

Benjamin-Loison avatar Dec 03 '23 14:12 Benjamin-Loison

~~Let us use multiple parts to simplify the code but later the code may split on its own (or not for instance with countryChannelId) for more detailed errors.~~ Let us be precise then.

Benjamin-Loison avatar Dec 03 '23 16:12 Benjamin-Loison

['part=shorts&id=UCX6OQ3DkcsbYNE6H8uQQuVA', 'items/0/shorts/0/thumbnails/0/width', 405]
['part=shorts&id=UCX6OQ3DkcsbYNE6H8uQQuVA', 'items/0/shorts/0/thumbnails/0', [
    'url' => 'https://i.ytimg.com/vi/AjZDwxt7S8w/oardefault.jpg?sqp=-oaymwEkCJUDENAFSFqQAgHyq4qpAxMIARUAAAAAJQAAyEI9AICiQ3gB&rs=AOn4CLDpFzxLJ-uZqNP4s-y1quvwfNjRJQ',
    'width' => 405,
    'height' => 720
],

Benjamin-Loison avatar Dec 03 '23 18:12 Benjamin-Loison

Could as well unit test YouTube Data API v3, as it seems to have some features removal sometimes.

Benjamin-Loison avatar Jan 04 '24 22:01 Benjamin-Loison

php tests.php 2>&1 | grep -v 'PHP Warning'

Share tests/ maybe as a sub-module.

Currently reviewing videos?part=shorts.

Benjamin-Loison avatar Feb 20 '24 03:02 Benjamin-Loison

On fail unit test showing first difference would be nice. This could be done with diff.

Benjamin-Loison avatar Feb 23 '24 21:02 Benjamin-Loison

PASS videos part=isOriginal&id=FliCdfxdtTI items/0/isOriginal 
PASS videos part=isOriginal&id=iqKdEhx-dD4 items/0/isOriginal 1

false does not show 0. Ideally should show true and false instead of respectively 1 and 0.

Benjamin-Loison avatar Mar 10 '24 01:03 Benjamin-Loison

Make unit tests in other files than production endpoints.

Benjamin-Loison avatar Apr 13 '24 11:04 Benjamin-Loison

https://github.com/Benjamin-Loison/YouTube-operational-API/issues/300#issuecomment-2359809058

https://github.com/Benjamin-Loison/YouTube-operational-API/blob/0ddadb17ef58624da1b87cf0eee9592db4a5055d/common.php#L5

Is there a reason for:

https://github.com/Benjamin-Loison/YouTube-operational-API/blob/0ddadb17ef58624da1b87cf0eee9592db4a5055d/videos.php#L36

to be after:

https://github.com/Benjamin-Loison/YouTube-operational-API/blob/0ddadb17ef58624da1b87cf0eee9592db4a5055d/videos.php#L5-L34

?

Note that I strongly believe that there is a good reason maybe when executing those tests for instance.

https://discord.com/channels/933841502155706418/933841503103627316/1288274036471758858 suffered of this issue.

Benjamin-Loison avatar Sep 19 '24 02:09 Benjamin-Loison

If exhaustively and regularly tested can quickly jump to the unit test and verify that it still works fine and then can provide the unit test video id and if the person still faces his issue ask for his video id.

https://discord.com/channels/933841502155706418/933841503103627316/1298451409372713004

Benjamin-Loison avatar Oct 23 '24 01:10 Benjamin-Loison