Page MenuHomeSoftware Heritage

Add test to ensure that an exception is raised if unique_key isn't implemented
ClosedPublic

Authored by KShivendu on Apr 14 2021, 8:34 PM.

Details

Summary

In-memory Kafka writer didn't have any test. I'm adding a test that ensures that an exception is raised if the object doesn't have a unique_key when passed to the write_addition function.

For this, I have passed BaseModel(which doesn't have unique_key implemented) to the write_addition function and I'm checking if it raises a NotImplemented exception.

Related T2823

Diff Detail

Repository
rDJNL Journal infrastructure
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Build is green

Patch application report for D5529 (id=19721)

Rebasing onto fe820a2220...

First, rewinding head to replay your work on top of it...
Applying: inmemory: Add test to detect error in object unique_key
Changes applied before test
commit c4e8cda26fd8a195945509757371558a915ecd39
Author: KShivendu <shivendu@iitbhilai.ac.in>
Date:   Wed Apr 14 23:55:22 2021 +0530

    inmemory: Add test to detect error in object unique_key

See https://jenkins.softwareheritage.org/job/DJNL/job/tests-on-diff/154/ for more details.

Thanks. One suggestion inline.

swh/journal/tests/test_inmemory.py
9

Add a docstring to explicit what the test is about.
I had to follow through the linked task then the linked diff
from the task to start understanding what this is about.

My docstring suggestion is rather technical but nothing better comes to mind so...
@vlorentz might have a better one though ;)

swh/journal/tests/test_inmemory.py
9

No need for the docstring if you rename it test_write_addition_errors_without_unique_key

This revision now requires changes to proceed.Apr 15 2021, 2:09 PM

oh and actually, there is no reason for this test to be specific to the in-memory implementation. Add it to the regular test suite

KShivendu retitled this revision from inmemory: Add test to detect exception in object unique_key to Add test to ensure that an exception is raised if unique_key isn't implemented.Apr 16 2021, 6:47 AM
KShivendu edited the summary of this revision. (Show Details)
KShivendu edited the summary of this revision. (Show Details)
KShivendu edited the summary of this revision. (Show Details)

Add same test for regular kafka writer

Build is green

Patch application report for D5529 (id=19781)

Rebasing onto fe820a2220...

First, rewinding head to replay your work on top of it...
Applying: test: Catch errors in write_addition if unique_key isn't implemented
Changes applied before test
commit 80b533bdd939d2da2370b248b7093d8952a9ce11
Author: KShivendu <shivendu@iitbhilai.ac.in>
Date:   Wed Apr 14 23:55:22 2021 +0530

    test: Catch errors in write_addition if unique_key isn't implemented
    
    Adding a test that ensures that an exception is raised if the
    object passed to write_addition function doesn't have a unique_key.

See https://jenkins.softwareheritage.org/job/DJNL/job/tests-on-diff/155/ for more details.

This revision is now accepted and ready to land.Apr 16 2021, 9:05 AM

Should I add the names of other contributors as well?

Build is green

Patch application report for D5529 (id=19782)

Rebasing onto fe820a2220...

Current branch diff-target is up to date.
Changes applied before test
commit 236a00262e4f1751cd084d5b80af5885fec13c97
Author: KShivendu <shivendu@iitbhilai.ac.in>
Date:   Wed Apr 14 23:55:22 2021 +0530

    test: Catch errors in write_addition if unique_key isn't implemented
    
    Adding a test that ensures that an exception is raised if the
    object passed to write_addition function doesn't have a unique_key.

See https://jenkins.softwareheritage.org/job/DJNL/job/tests-on-diff/156/ for more details.

Should I add the names of other contributors as well?

It feels weird adding my name when I've done nothing compared to everyone else. What should I do?

Should I add the names of other contributors as well?

It feels weird adding my name when I've done nothing compared to everyone else. What should I do?

You did contribute this test.
So it's fine as it is ;)