Add expectedDescriptionIsEmpty() to DefaultStreamExtractorTest

Also check if related streams are empty if they are expected to be empty.
This commit is contained in:
TobiGr 2021-02-21 21:19:54 +01:00 committed by TiA4f8R
parent f15d7837a1
commit 21158744b1
No known key found for this signature in database
GPG Key ID: E6D3E7F5949450DD
2 changed files with 12 additions and 3 deletions

View File

@ -48,6 +48,7 @@ public abstract class DefaultStreamExtractorTest extends DefaultExtractorTest<St
public boolean expectedUploaderVerified() { return false; } public boolean expectedUploaderVerified() { return false; }
public String expectedSubChannelName() { return ""; } // default: there is no subchannel public String expectedSubChannelName() { return ""; } // default: there is no subchannel
public String expectedSubChannelUrl() { return ""; } // default: there is no subchannel public String expectedSubChannelUrl() { return ""; } // default: there is no subchannel
public boolean expectedDescriptionIsEmpty() { return false; } // default: description is not empty
public abstract List<String> expectedDescriptionContains(); // e.g. for full links public abstract List<String> expectedDescriptionContains(); // e.g. for full links
public abstract long expectedLength(); public abstract long expectedLength();
public long expectedTimestamp() { return 0; } // default: there is no timestamp public long expectedTimestamp() { return 0; } // default: there is no timestamp
@ -146,7 +147,12 @@ public abstract class DefaultStreamExtractorTest extends DefaultExtractorTest<St
public void testDescription() throws Exception { public void testDescription() throws Exception {
final Description description = extractor().getDescription(); final Description description = extractor().getDescription();
assertNotNull(description); assertNotNull(description);
if (expectedDescriptionIsEmpty()) {
assertTrue("description is not empty", description.getContent().isEmpty());
} else {
assertFalse("description is empty", description.getContent().isEmpty()); assertFalse("description is empty", description.getContent().isEmpty());
}
for (final String s : expectedDescriptionContains()) { for (final String s : expectedDescriptionContains()) {
assertThat(description.getContent(), containsString(s)); assertThat(description.getContent(), containsString(s));
@ -225,7 +231,7 @@ public abstract class DefaultStreamExtractorTest extends DefaultExtractorTest<St
defaultTestListOfItems(extractor().getService(), relatedStreams.getItems(), defaultTestListOfItems(extractor().getService(), relatedStreams.getItems(),
relatedStreams.getErrors()); relatedStreams.getErrors());
} else { } else {
assertNull(relatedStreams); assertTrue(relatedStreams == null || relatedStreams.getItems().isEmpty());
} }
} }

View File

@ -48,6 +48,7 @@ public class SoundcloudStreamExtractorTest {
@Override public String expectedUploaderName() { return "Jess Glynne"; } @Override public String expectedUploaderName() { return "Jess Glynne"; }
@Override public String expectedUploaderUrl() { return UPLOADER; } @Override public String expectedUploaderUrl() { return UPLOADER; }
@Override public boolean expectedUploaderVerified() { return true; } @Override public boolean expectedUploaderVerified() { return true; }
@Override public boolean expectedDescriptionIsEmpty() { return true; }
@Override public List<String> expectedDescriptionContains() { return Collections.emptyList(); } @Override public List<String> expectedDescriptionContains() { return Collections.emptyList(); }
@Override public long expectedLength() { return 197; } @Override public long expectedLength() { return 197; }
@Override public long expectedTimestamp() { return TIMESTAMP; } @Override public long expectedTimestamp() { return TIMESTAMP; }
@ -60,6 +61,7 @@ public class SoundcloudStreamExtractorTest {
@Override public boolean expectedHasSubtitles() { return false; } @Override public boolean expectedHasSubtitles() { return false; }
@Override public boolean expectedHasFrames() { return false; } @Override public boolean expectedHasFrames() { return false; }
@Override public int expectedStreamSegmentsCount() { return 0; } @Override public int expectedStreamSegmentsCount() { return 0; }
@Override public boolean expectedHasRelatedStreams() { return false; }
} }
public static class SoundcloudGoPlusTrack extends DefaultStreamExtractorTest { public static class SoundcloudGoPlusTrack extends DefaultStreamExtractorTest {
@ -87,7 +89,8 @@ public class SoundcloudStreamExtractorTest {
@Override public String expectedUploaderName() { return "martinsolveig"; } @Override public String expectedUploaderName() { return "martinsolveig"; }
@Override public String expectedUploaderUrl() { return UPLOADER; } @Override public String expectedUploaderUrl() { return UPLOADER; }
@Override public boolean expectedUploaderVerified() { return true; } @Override public boolean expectedUploaderVerified() { return true; }
@Override public List<String> expectedDescriptionContains() { return Collections.singletonList(""); } @Override public boolean expectedDescriptionIsEmpty() { return true; }
@Override public List<String> expectedDescriptionContains() { return Collections.emptyList(); }
@Override public long expectedLength() { return 30; } @Override public long expectedLength() { return 30; }
@Override public long expectedTimestamp() { return TIMESTAMP; } @Override public long expectedTimestamp() { return TIMESTAMP; }
@Override public long expectedViewCountAtLeast() { return 386000; } @Override public long expectedViewCountAtLeast() { return 386000; }