-
Notifications
You must be signed in to change notification settings - Fork 696
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
Download unread/ all selected sources #1467
Conversation
5f522a8
to
df7a73d
Compare
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.
Left one small comment, but besides that, this looks great!
|
||
# Set environment variable so config.py uses a test environment | ||
os.environ['SECUREDROP_ENV'] = 'test' | ||
import config |
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.
Where is config being called? Or is this simply for making sure the flask settings are set?
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.
Currently, the securedrop/config.py
modules reads the environment variable SECUREDROP_ENV
, and sets the configuration differently based on its value. We'd like to deprecate the reading/ setting of environment variables in our code entirely, and instead be read from static INI files.
Although I'm still considering how to do this, I believe that we need to create a separate module for each INI file, for each environment setting. This will involve breaking up securedrop/manage.py
. Each new module will read only a single INI file. All functionality it provides will involve calls to generators of other modules with initialization arguments, so that no other modules besides these are actually reading from a configuration file.
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.
Currently, the securedrop/config.py modules reads the environment variable SECUREDROP_ENV, and sets the configuration differently based on its value.
Ok awesome. Could I suggest leaving a comment explaining that its needed even though it is not directly called?
We'd like to deprecate the reading/ setting of environment variables in our code entirely, and instead be read from static INI files.
👍 makes complete sense. Only thing to consider is that environment variables are much easier to work with when it comes to Docker / containers than INI files in my experience.
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.
Ah, I see now. We don't actually access any of the attributes in config directly in this module. I have to refresh my memory on what happens if we import some other modules which import config before setting this environment variable. I think that could be bad, but need to confirm.
Want this one to get at least one more review @redshiftzero @garrettr |
Note: blocking on #1440. |
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! Just rebase on current develop and then this should be ready to merge.
@@ -85,7 +85,7 @@ | |||
<input name="csrf_token" type="hidden" value="{{ csrf_token() }}"/> | |||
<input type="hidden" name="sid" value="{{ sid }}"/> | |||
<input type="hidden" name="col_name" value="{{ source.journalist_designation }}"/> | |||
<button type="submit" class="danger"><i class="fa fa-times"></i> Delete collection</button> | |||
<button type="submit" class="danger"><i class="fa fa-trash-o"></i> Delete Collection</button> |
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.
Good call on changing these icons!
sid = 'EQZGCJBRGISGOTC2NZVWG6LILJBHEV3CINNEWSCLLFTUWZJPKJFECLS2NZ4G4U3QOZCFKTTPNZMVIWDCJBBHMUDBGFHXCQ3R' | ||
source = Source(sid, crypto_util.display_id()) | ||
db_session.add(source) | ||
db_session.commit() | ||
files = ['1-abc1-msg.gpg', '2-abc2-msg.gpg'] | ||
filenames = common.setup_test_docs(sid, files) | ||
files = ['1-abc1-msg.gpg', '2-abc2-msg.gpg', '3-abc3-msg.gpg', '4-abc4-msg.gpg'] |
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 can adapt add_source_and_submissions()
in #1440 (once it's merged in) here
df7a73d
to
0385b82
Compare
Hmm, all tests were passing on my machine. I'll have to retry with a clean branch and VM. |
Button type 1. Address comments for Button 1. Button 2. Might be buggy. Extend and improve bulk download unit test This improves the bulk download unit test by having it check that only selected files are downloaded and not unselected files. It extends the unit test to include a test for downloading all present files. Add unit test for download_all_unread
Clean up action checking and get tests passing Extend test coverage to all new code in download all PR Style cleanup in test_unit_journalist.py Fixes based on code review Fix test for removal of g.user.username from all_unread
0385b82
to
cb1a028
Compare
Okay, still everything passes locally. I rebased and pushed again--we'll see if it passes on Travis this time. |
1f11a35
to
0307265
Compare
@redshiftzero Can you pull this one down and test locally? I'm not sure why Travis is running into |
Hmm - all tests are passing locally for me as well... |
Also: I see you added a commit with a major refactor of the test suite - can we maybe put this refactor in a separate PR? Else the merging of this PR will be delayed as those changes definitely warrants a careful re-review... up to you |
@redshiftzero Problem is I'd have to rewrite the tests for download functionalities with the current test structures, which are now soon (hopefully) going to be outdated anyway. Alternatively, if you think this is an okay idea, we could also make an exception here and merge this without tests, since I've already written two passing* sets of tests for the functionality that you've been able to confirm--the ones I wrote pre-#1440 and the ones introduced in 0307265.
I really don't want to write a 3rd set of tests for this functionality, that is just going to be replaced days later by my 2nd set. |
Maybe let's figure out Travis first? |
Oh sorry - I wasn't suggesting writing of a third set of tests, instead just moving the last commit into a separate PR, rebase this one on develop as is since the first three commits are already reviewed and approved. Then we merge this one in (assuming we get a passing Travis build on the first three commits - which at least was the case when I reviewed this last week). |
I think rebasing will require me to rewrite tests because #1440 changed some things. |
Ah, nvm. |
0307265
to
c0cf7da
Compare
Okay, that worked. My mistake. Split into two PRs. |
import datetime | ||
|
||
from flask_testing import TestCase | ||
from flask import url_for, escape | ||
|
||
# Set environment variable so config.py uses a test environment | ||
os.environ['SECUREDROP_ENV'] = 'test' |
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.
Need to move os import above this line
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.
I swear I ran this locally after git reset HEAD~1 --hard
, but before pushing, and it succeeded. Probably just stepped in to a parallel universe where that happened, or ran on another branch by accident.
c0cf7da
to
6aec0c0
Compare
Introduce download selection btns, better icons Improve document interface download functionality * User can now download all or just unread messages from a selection of sources. * Backend cleanup. * Small CSS bug introduced in last commit fixed. Minor fixes--fn to download single submission Add unit tests for new download functionality Remove unused g import
6aec0c0
to
ac02336
Compare
@redshiftzero Ready for re-review. |
Okay, I've gotten 3 approved reviews, and all 3 checks have passed. Going to merge this one myself in this case because I don't want to block #1460 any longer, which has already been open for 10 days. |
Since the git history is messy on this one, but I still want all 3 of us to get credit, I'm going to rebase this PR into 3 commits: one from each of us.