def test_adding(self):
        """
        :return:
        """
        _id = self.book.generateUniqueId(CONTENT_TYPE_BOOK_LOAN)

        intids = getUtility(IIntIds)

        _book = RelationValue(intids.getId(self.book))
        _student = RelationValue(intids.getId(self.student))
        _loan_duration = safe_unicode('2')
        _loan_status = safe_unicode('running')

        self.book.invokeFactory(CONTENT_TYPE_BOOK_LOAN, _id)
        loan = self.book[_id]

        self.assertTrue(IBookLoan.providedBy(loan))

        loan.student = _student
        loan.book = _book
        loan.loan_duration = _loan_duration
        loan.loan_status = _loan_status
        loan.reindexObject()

        # Let's manually triggers
        collective_datatable_book_loan_created(loan, None)

        result = self.portal.portal_catalog.searchResults(id=loan.id)

        self.assertEquals(1, len(result))
        self.assertEqual(self.book, loan.book.to_object)
        self.assertEqual(self.student, loan.student.to_object)
        # Make sure events fired
        self.assertFalse(loan.is_lock)
        self.assertEqual(self.book.number_of_loan_copy, 2)
    def test_factory(self):
        """
        :return:
        """
        fti = queryUtility(IDexterityFTI, name=CONTENT_TYPE_BOOK_LOAN)

        obj = createObject(fti.factory)

        self.assertTrue(IBookLoan.providedBy(obj))