Skip to content

Commit

Permalink
Rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
Noah Vesely committed Dec 19, 2016
1 parent c51e284 commit c1cdae0
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions securedrop/tests/test_unit_journalist.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,35 +477,29 @@ def test_edit_hotp(self):
self.assertRedirects(res, url_for('account_new_two_factor'))

def test_change_assignment(self):
source, _ = utils.db_helper.init_source()
self._login_user()

sid = 'EQZGCJBRGISGOTC2NZVWG6LILJBHEV3CINNEWSCLLFTUWZJPKJFECLS2NZ4G4U3QOZCFKTTPNZMVIWDCJBBHMUDBGFHXCQ3R'
source = Source(sid, crypto_util.display_id())
db_session.add(source)
db_session.commit()
s

resp = self.client.post(url_for('change_assignment', sid=sid),
data=dict(journalist=self.user.username))
self.assertRedirects(res, url_for('index'))
resp = self.client.post(
url_for('change_assignment', sid=source.filesystem_id),
data=dict(journalist=self.user.username))

self.assertRedirects(resp, url_for('index'))
# Check that source is indeed assigned to self.user.username in the db
source_assigned = db_session.query(Source).filter(source.filesystem_id == sid).one()
source_assigned = db_session.query(Source).filter(source.filesystem_id
==
source.filesystem_id).one()
self.assertEqual(self.user.username, source_assigned.journalist.username)


def test_delete_source_deletes_submissions(self):
"""Verify that when a source is deleted, the submissions that
correspond to them are also deleted."""

source, files = self.add_source_and_submissions()

journalist.delete_collection(source.filesystem_id)
self._delete_collection_setup()
journalist.delete_collection(self.source.filesystem_id)

# Source should be gone
results = db_session.query(Source).filter(Source.id == source.id).all()
resp = self.client.post(url)
self.assertStatus(resp, 302)
results = db_session.query(Source).filter(Source.id == self.source.id).all()

def _delete_collection_setup(self):
self.source, _ = utils.db_helper.init_source()
Expand Down

0 comments on commit c1cdae0

Please sign in to comment.