Check placeholder records and handle validation#129
Conversation
peterwilsoncc
left a comment
There was a problem hiding this comment.
@ankitrox Thanks for the pull request.
Rather than use a static, would it be possible to check if both placeholder and valid records exist within the save function?
Lines 34 to 46 in a00bdce
Statics can be difficult to check and while testing the changes with the test_validate_line function, I discovered the static was affecting other tests.
|
@ankitrox any chance you're able to handle the code review item above? |
|
@peterwilsoncc Thanks for the review :) I wanted those couple of variables to be persistent across multiple function calls, but I agree that static may not be the idea ones as far as unit tests are concerned. I have changed it to use options table in order for them to be persistent. This will also be handy for unit tests. |
peterwilsoncc
left a comment
There was a problem hiding this comment.
I've added quite a few suggestions inline to avoid thrashing the database with option updates.
To record the line number, I've switch from an option to a static variable. (This may need further thought)
To record the presence of a placeholder, I've added a value to the returned array in validate_line().
While testing, I noticed that the order of lines affects the warnings shown. If I place a valid record above the placeholder record I am shown the warning "Your ads.txt indicates no authorized advertising sellers."
If I place the two lines in the reverse order, I also get a message that "Ads.txt contains placeholder record with another records."
Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com>
Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com>
Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com>
Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com>
Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com>
Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com>
Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com>
Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com>
Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com>
|
I just tested this and am still seeing the no authorized resellers warning when the file contains both a placeholder and a valid record. I did some testing to see if I could come up with an approach that worked but comment lines ended up suppressing the error if the file contained placeholders and comments (which is just as bad, if not worse). My thoughts are:
We'll need to account for:
|
|
Thank you @peterwilsoncc I have added the fix as per Peter's suggestion and it seems to be working fine. Also, added the unit test for the placeholder record. CC: @jeffpaul |

Description of the Change
Closes #78
How to test the Change
Changelog Entry
Credits
Props @peterwilsoncc
Checklist: