-
Notifications
You must be signed in to change notification settings - Fork 425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve stream extractor tests & various fixes #309
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than these small things, this looks good to me. Also, your testUploadDate()
seems to be incorrect for PeerTube.
...chabi/newpipe/extractor/services/media_ccc/linkHandler/MediaCCCStreamLinkHandlerFactory.java
Outdated
Show resolved
Hide resolved
...chabi/newpipe/extractor/services/peertube/linkHandler/PeertubeChannelLinkHandlerFactory.java
Show resolved
Hide resolved
...schabi/newpipe/extractor/services/peertube/linkHandler/PeertubeStreamLinkHandlerFactory.java
Show resolved
Hide resolved
...in/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java
Outdated
Show resolved
Hide resolved
...in/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java
Outdated
Show resolved
Hide resolved
extractor/src/test/java/org/schabi/newpipe/extractor/services/DefaultStreamExtractorTest.java
Outdated
Show resolved
Hide resolved
051e3fa
to
b6ae057
Compare
Ok, I fixed everything that was suggested plus an oversight when testing video streams, check commit messages for more info. @B0pol @wb9688 On my machine all tests succeed, but they did even two days ago when PeerTube gave issues in the tarvis-ci. The issues has to do with date timezones, I think, but if the improvement I pushed now (i.e. setting the same timezone to expected and actual dates) didn't do the trick I have no idea what to do. |
@Stypox: It's rebase time! Yes, again. Anyway, I'll try to take an actual look at it tomorrow. |
6dd5f01
to
ab85fcb
Compare
@wb9688 rebased and squashed some commits (in particular, I squashed all commits related to tests into only one, while living fixes into their separate commits). I learned how to rebase interactively :-D |
ab85fcb
to
505f19c
Compare
I rebased |
505f19c
to
e4ace2b
Compare
Rebased |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're missing license, etc. Other than that and these small things, it seems to be good. You also need to rebase again. Also, I got the following error for SoundcloudStreamExtractorTest$LilUziVertDoWhatIWant
:
expected:<java.util.GregorianCalendar[time=1469981887000,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="GMT",offset=0,dstSavings=0,useDaylight=false,transitions=0,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2016,MONTH=6,WEEK_OF_YEAR=32,WEEK_OF_MONTH=6,DAY_OF_MONTH=31,DAY_OF_YEAR=213,DAY_OF_WEEK=1,DAY_OF_WEEK_IN_MONTH=5,AM_PM=1,HOUR=4,HOUR_OF_DAY=16,MINUTE=18,SECOND=7,MILLISECOND=0,ZONE_OFFSET=0,DST_OFFSET=0]> but was:<java.util.GregorianCalendar[time=1469989087000,areFieldsSet=false,areAllFieldsSet=false,lenient=true,zone=sun.util.calendar.ZoneInfo[id="GMT",offset=0,dstSavings=0,useDaylight=false,transitions=0,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2016,MONTH=6,WEEK_OF_YEAR=32,WEEK_OF_MONTH=6,DAY_OF_MONTH=31,DAY_OF_YEAR=213,DAY_OF_WEEK=1,DAY_OF_WEEK_IN_MONTH=5,AM_PM=1,HOUR=8,HOUR_OF_DAY=20,MINUTE=18,SECOND=7,MILLISECOND=0,ZONE_OFFSET=3600000,DST_OFFSET=3600000]>
Expected :java.util.GregorianCalendar[time=1469981887000,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="GMT",offset=0,dstSavings=0,useDaylight=false,transitions=0,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2016,MONTH=6,WEEK_OF_YEAR=32,WEEK_OF_MONTH=6,DAY_OF_MONTH=31,DAY_OF_YEAR=213,DAY_OF_WEEK=1,DAY_OF_WEEK_IN_MONTH=5,AM_PM=1,HOUR=4,HOUR_OF_DAY=16,MINUTE=18,SECOND=7,MILLISECOND=0,ZONE_OFFSET=0,DST_OFFSET=0]
Actual :java.util.GregorianCalendar[time=1469989087000,areFieldsSet=false,areAllFieldsSet=false,lenient=true,zone=sun.util.calendar.ZoneInfo[id="GMT",offset=0,dstSavings=0,useDaylight=false,transitions=0,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2016,MONTH=6,WEEK_OF_YEAR=32,WEEK_OF_MONTH=6,DAY_OF_MONTH=31,DAY_OF_YEAR=213,DAY_OF_WEEK=1,DAY_OF_WEEK_IN_MONTH=5,AM_PM=1,HOUR=8,HOUR_OF_DAY=20,MINUTE=18,SECOND=7,MILLISECOND=0,ZONE_OFFSET=3600000,DST_OFFSET=3600000]
<Click to see difference>
java.lang.AssertionError: expected:<java.util.GregorianCalendar[time=1469981887000,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="GMT",offset=0,dstSavings=0,useDaylight=false,transitions=0,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2016,MONTH=6,WEEK_OF_YEAR=32,WEEK_OF_MONTH=6,DAY_OF_MONTH=31,DAY_OF_YEAR=213,DAY_OF_WEEK=1,DAY_OF_WEEK_IN_MONTH=5,AM_PM=1,HOUR=4,HOUR_OF_DAY=16,MINUTE=18,SECOND=7,MILLISECOND=0,ZONE_OFFSET=0,DST_OFFSET=0]> but was:<java.util.GregorianCalendar[time=1469989087000,areFieldsSet=false,areAllFieldsSet=false,lenient=true,zone=sun.util.calendar.ZoneInfo[id="GMT",offset=0,dstSavings=0,useDaylight=false,transitions=0,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2016,MONTH=6,WEEK_OF_YEAR=32,WEEK_OF_MONTH=6,DAY_OF_MONTH=31,DAY_OF_YEAR=213,DAY_OF_WEEK=1,DAY_OF_WEEK_IN_MONTH=5,AM_PM=1,HOUR=8,HOUR_OF_DAY=20,MINUTE=18,SECOND=7,MILLISECOND=0,ZONE_OFFSET=3600000,DST_OFFSET=3600000]>
at org.junit.Assert.fail(Assert.java:88)
at org.junit.Assert.failNotEquals(Assert.java:834)
at org.junit.Assert.assertEquals(Assert.java:118)
at org.junit.Assert.assertEquals(Assert.java:144)
at org.schabi.newpipe.extractor.services.DefaultStreamExtractorTest.testUploadDate(DefaultStreamExtractorTest.java:139)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38)
at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62)
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:118)
at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:175)
at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:157)
at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:404)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.lang.Thread.run(Thread.java:748)
extractor/src/test/java/org/schabi/newpipe/extractor/services/DefaultStreamExtractorTest.java
Outdated
Show resolved
Hide resolved
extractor/src/test/java/org/schabi/newpipe/extractor/services/DefaultStreamExtractorTest.java
Outdated
Show resolved
Hide resolved
extractor/src/test/java/org/schabi/newpipe/extractor/services/DefaultStreamExtractorTest.java
Outdated
Show resolved
Hide resolved
extractor/src/test/java/org/schabi/newpipe/extractor/services/DefaultStreamExtractorTest.java
Outdated
Show resolved
Hide resolved
extractor/src/test/java/org/schabi/newpipe/extractor/services/DefaultStreamExtractorTest.java
Outdated
Show resolved
Hide resolved
extractor/src/test/java/org/schabi/newpipe/extractor/services/DefaultStreamExtractorTest.java
Outdated
Show resolved
Hide resolved
fa29b78
to
d22a963
Compare
@wb9688 fixed the failing test (for some reason SoundCloud started serving a date as |
d216b05
to
95367dd
Compare
I thought the problem lied in PeerTube and SoundCloud date parsers, but actually this problem had to do with Youtube: the upload date wasn't being parsed as a GMT date, but using the device timezone, thus leading to inconsistencies. Tests were also wrong, because they tested dates using the device timezone (I did try to prevent this, but I put the correct statement on the wrong line ;-/) Now everything seems to work, both on my end and on tarvis. It's incredible how 1085 tests succeed ;-D |
Could you rebase? |
95367dd
to
1ef0687
Compare
Done. I'll soon also push a test for the DashMpd url that you recently fixed |
Done |
Refactorings on `throws` clause
The old one wasn't available anymore
The old video was made private, and this video (wedding) is probably never going to be removed.
0ffd6ec
to
f11fe87
Compare
I rebased. There are many failing tests, but all seem to be unrelated from the changes here, since they are caused by "YouTube did not provide player config even after three attempts", PeerTube accounts/channels not providing related items, SoundCloud channels & playlists with some outdated data, youtube channels with no Videos tab, YouTube comments extractor (all not touched by this PR). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
We could make a bunch of vars and arguments final, but that can wait
...n/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCParsingHelper.java
Outdated
Show resolved
Hide resolved
extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelper.java
Outdated
Show resolved
Hide resolved
@TobiGr done ;-) |
...java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCStreamExtractor.java
Show resolved
Hide resolved
extractor/src/test/java/org/schabi/newpipe/extractor/services/DefaultStreamExtractorTest.java
Show resolved
Hide resolved
d007fb3
to
cd32e74
Compare
cd32e74
to
57e7994
Compare
@B0pol done everything |
Testing apk: app-debug.zip |
This PR makes all stream extractor tests consistent by having them all extend the same default base class. I took inspiration from @mauriciocolli's work in #296.
Note that I didn't add tests for metadata properties, that will fit in another PR after both this pr and #306 are merged.List of test improvements:
assertSecureUrl
, but not compared, since they could change I think. In MediaCCC, where they were being tested before, I left those tests there untouched.*StreamExtractorDefaultTest
into*StreamExtractorTest
for services when there is only one file containing stream tests (that's obviously the default one ;-) )assertAtLeast
method to utilsList of fixes (taken from commit messages):
NullPointerException
on obtaining error message when there is none: return null instead, as per javadoc-2
(that internally indicates that the regex failed to match), as per javadocreturn new ArrayList<>();
withreturn Collections.emptyList();
getAudioStreams()
getRelatedStreams()
, as per javadocgetOriginalUrl()
that does the same as the base onegetVideoOnlyStreams()