Beispiel #1
0
 def test_it_all_crazy_madness_wohoo(self):
     # Sanity check, can we load everything, export it, delete, and reload it all without error.
     self.construct_everything()
     data = self.get_export()
     clean_db(db)
     db.session.commit()
     self.load_database(data)
Beispiel #2
0
    def test_insert_user_with_participant(self):
        u = self.construct_user()
        u._password = b"xxxxx"
        u.email_verified = True

        role = u.role
        email_verified = u.email_verified
        orig_u_date = u.last_updated

        orig_user_dict = UserSchema().dump(u).data  # Use standard schema
        p = self.construct_participant(user=u, relationship=Relationship.self_participant)
        orig_p_dict = ParticipantSchema().dump(p).data  # Use standard schema
        orig_p_date = p.last_updated
        db.session.commit()

        data = self.get_export()
        clean_db(db)
        db.session.commit()
        self.load_database(data)

        db_user = db.session.query(User).filter_by(id=orig_user_dict["id"]).first()
        self.assertIsNotNone(db_user, msg="User is recreated.")
        self.assertNotEqual(orig_user_dict["email"], db_user.email, msg="Email should be obfuscated")
        self.assertEqual(db_user.last_updated, orig_u_date, msg="Dates are kept in tact")
        self.assertEqual(db_user.role, role)
        self.assertEqual(db_user.email_verified, email_verified)
        self.assertEqual(None, db_user._password, msg="Passwords should not be exported.")

        db_par = db.session.query(Participant).filter_by(id=orig_p_dict["id"]).first()
        self.assertIsNotNone(db_par, msg="Participant is recreated.")
        self.assertEqual(db_par.user, db_user, msg="Relationship in tact")
        self.assertEqual(db_par.last_updated, orig_p_date, msg="Dates are kept in tact")
Beispiel #3
0
    def test_identifying_questionnaire_does_not_export(self):

        # Construct the base user.
        u = self.construct_user()
        p = self.construct_participant(user=u, relationship=Relationship.self_participant)
        iq = self.construct_identification_questionnaire(user=u, participant=p)
        id = u.id
        db.session.commit()

        data = self.get_export()
        clean_db(db)
        db.session.commit()
        self.load_database(data)

        self.assertEqual(ExportService.TYPE_IDENTIFYING,
                         IdentificationQuestionnaire().__question_type__)
        self.assertEqual(0, len(db.session.query(IdentificationQuestionnaire).all()),
                         msg="Identifying Questionnaires should not import.")
Beispiel #4
0
    def test_re_insert_user_with_modifications(self):
        # Construct the base user.
        u = self.construct_user()
        id = u.id
        db.session.commit()

        data = self.get_export()
        clean_db(db)
        db.session.commit()
        self.load_database(data)

        db_user = db.session.query(User).filter_by(id=id).first()
        self.assertFalse(db_user.email_verified, msg="Email should start off unverified")

        # Modify the exported data slightly, and reload
        for user in data['User']:
            user['email_verified'] = True
        self.load_database(data)

        db_user = db.session.query(User).filter_by(id=id).first()
        self.assertTrue(db_user.email_verified, msg="Email should now be verified.")
Beispiel #5
0
 def setUp(self):
     self.ctx.push()
     clean_db(db)
     elastic_index.clear()
     self.auths = {}