Benjamin-Loison / YouTube-operational-API

YouTube operational API works when YouTube Data API v3 fails.
391 stars 48 forks source link

Finish unit tests #24

Open Benjamin-Loison opened 2 years ago

Benjamin-Loison commented 2 years ago

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.

+4

Benjamin-Loison commented 10 months ago

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

Benjamin-Loison commented 10 months ago

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 commented 10 months ago

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

Benjamin-Loison commented 10 months ago

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 commented 10 months ago

Should verify pagination when there is one.

Benjamin-Loison commented 10 months ago

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 commented 10 months ago
['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 commented 9 months ago

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

Benjamin-Loison commented 8 months ago
php tests.php 2>&1 | grep -v 'PHP Warning'

Share tests/ maybe as a sub-module.

Currently reviewing videos?part=shorts.

Benjamin-Loison commented 8 months ago

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

Benjamin-Loison commented 7 months ago
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 commented 6 months ago

Make unit tests in other files than production endpoints.

Benjamin-Loison commented 1 month ago

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 commented 1 week ago

Related to Webscrap_any_website/issues/38.

Benjamin-Loison commented 4 hours ago

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