def test_post_position_last_next(self, request): """Test that moving the last subject down does nothing.""" request.json = dict(position="next") self.assertEqual( dict(ok=True), post_subject_attribute(SUBJECT_ID2, "position", self.database)) self.database.reports.insert.assert_not_called() self.assertEqual([SUBJECT_ID, SUBJECT_ID2], list(self.report["subjects"].keys()))
def test_post_subject_name(self, request): """Test that the subject name can be changed.""" request.json = dict(name="new name") self.assertEqual( dict(ok=True), post_subject_attribute(SUBJECT_ID, "name", self.database)) self.database.reports.insert.assert_called_once_with(self.report) self.assert_delta( "name of subject 'subject1' in report 'Report' from 'subject1' to 'new name'", SUBJECT_ID)
def test_post_position_first(self, request): """Test that a subject can be moved to the top.""" request.json = dict(position="first") self.assertEqual( dict(ok=True), post_subject_attribute(SUBJECT_ID2, "position", self.database)) self.database.reports.insert.assert_called_once_with(self.report) self.assertEqual([SUBJECT_ID2, SUBJECT_ID], list(self.report["subjects"].keys())) self.assert_delta( "position of subject 'subject2' in report 'Report' from '1' to '0'", SUBJECT_ID2)
def test_post_subject_name(self, request): """Test that the subject name can be changed.""" request.json = dict(name="new name") self.assertEqual( dict(ok=True), post_subject_attribute(SUBJECT_ID, "name", self.database)) self.database.reports.insert.assert_called_once_with(self.report) self.assertEqual( dict( uuids=[REPORT_ID, SUBJECT_ID], email=self.email, description= "John changed the name of subject 'subject1' in report 'Report' from 'subject1' to " "'new name'."), self.report["delta"])
def test_post_position_next(self, request): """Test that a subject can be moved down.""" request.json = dict(position="next") self.assertEqual( dict(ok=True), post_subject_attribute(SUBJECT_ID, "position", self.database)) self.database.reports.insert.assert_called_once_with(self.report) self.assertEqual([SUBJECT_ID2, SUBJECT_ID], list(self.report["subjects"].keys())) self.assertEqual( dict( uuids=[REPORT_ID, SUBJECT_ID], email=self.email, description= "John changed the position of subject 'subject1' in report 'Report' from '0' to '1'." ), self.report["delta"])