Esempio n. 1
0
    def case_update_record(self, refresh_db_before):
        """ Create test record in Admin table and then update it."""
        original_name = "admin3"
        update_name = "admin33"

        original_admin = AdminOp.add(original_name)

        updated_admin_local = AdminOp.update(original_admin, update_name)

        self.assertEqual(updated_admin_local.name, update_name)

        updated_admin_get = AdminOp.get(name=update_name)

        self.assertTrue(len(updated_admin_get) is 1)
        self.assertEqual(updated_admin_get[0].name, update_name)
        self.assertEqual(updated_admin_get[0].id, original_admin.id)
Esempio n. 2
0
    def test_update(self, mock_admin, mock_val_name, mock_db):
        """ Assumptions:
                - update method run
        """
        new_name = "Test Name"
        admin_obj = mock_admin()

        updated_admin = AdminOp.update(admin_obj, new_name)

        self.assertTrue(mock_val_name.called)

        db_exp_calls = [
            mock.call.session.add(updated_admin),
            mock.call.session.commit(),
        ]

        mock_db.assert_has_calls(db_exp_calls)