Page MenuHomeSoftware Heritage

tests.BaseLoaderStorageTest: Remove count checks in assert*Contain methods
ClosedPublic

Authored by anlambert on Mar 28 2019, 2:48 PM.

Details

Summary

Those methods aim to check if some objects are present in the archive.
So no count checks should be performed here as there is no guarantee that
the numbers of objects in the archive will be the same as the number of
objects to test existence.

Diff Detail

Repository
rDLDBASE Generic VCS/Package Loader
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

as there is no guarantee that the numbers of objects in the archive will be the same as the number of objects to test existence.

Why not?

as there is no guarantee that the numbers of objects in the archive will be the same as the number of objects to test existence.

Why not?

I think there's value in having some asserts to test object set inclusion rather than object set equality.

If we really want to keep a strict check as well, we could rename them assert<ObjectType>OnlyContains or somesuch.

Consider this test case that I am currently implementing for the npm loader: I want to simulate the multiple visits of a package.

I use a single loader instance instead of creating a new one for each test as I want to test the number of new objects sent
by the loader to the test storage. For the first visit, the test storage is empty so the count checks will pass. But for the second visit,
the test storage is not empty so the count checks will fail.

If we really want to keep a strict check as well, we could rename them assert<ObjectType>OnlyContains or somesuch.

Or simply use the following test combinations:

objects = [...]
self.assertCount<ObjectType>(len(objects))
self.assert<ObjectType>Contain(objects)
This revision is now accepted and ready to land.Mar 29 2019, 10:50 AM
This revision was automatically updated to reflect the committed changes.