예제 #1
0
    def test_db_mapping_branch(self):
        from emc.kb.mapping_db import Branch
        from emc.kb.mapping_db import Model
        from z3c.saconfig import Session

        import pdb
        pdb.set_trace()
        model = Model()
        model.xhdm = u"C9"
        model.xhmc = u"我的手机"
        Session.add(model)

        branch = Branch()
        branch.fxtdm = u"C91"
        branch.fxtmc = u"发射器"
        branch.fxtlb = u"fashe"

        branch.model = model
        Session.add(branch)
        Session.flush()

        self.assertTrue(branch.branchId is not None)
        self.assertTrue(model.modelId is not None)
        self.assertEqual(branch.modelId, model.modelId)
        self.assertEqual(branch.branchId, model.branches[0].branchId)
예제 #2
0
    def test_db_mapping_model(self):
        from emc.kb.mapping_db import Model
        from z3c.saconfig import Session

        model = Model()
        model.xhdm = u"C9"
        model.xhmc = u"我的手机"
        Session.add(model)
        Session.flush()
        self.assertTrue(model.modelId is not None)
예제 #3
0
    def test_db_mapping_model(self):
        from emc.kb.mapping_db import Model
        from z3c.saconfig import Session

        model = Model()
        model.xhdm = u"C9"
        model.xhmc = u"我的手机"
        Session.add(model)
        Session.flush()
        nums = Session.query(func.count(model.modelId)).scalar()
        self.assertTrue(model.modelId is not None)
        print model.xhdm
        print nums
예제 #4
0
파일: Addmodel.py 프로젝트: adam139/emc.kb
    def Addmodel(self,modelId,xhdm,xhmc):
        """parameters db model table"""
        model = Model()
        model.id = modelId
        model.xhdm = xhdm
        model.xhmc = xhmc

        kb_session.add(model)
        try:
            kb_session.commit()
        except:
            kb_session.rollback()
            raise
예제 #5
0
    def test_oracledb_model(self):
        from emc.kb.mapping_db import Model
        from emc.kb import pas_session as Session

        model = Model()
        import pdb
        pdb.set_trace()
        nums = Session.query(func.count(model.modelId)).scalar()
        if nums != 1:

            model.modelId = 100
            model.xhdm = u"C9"
            model.xhmc = u"my phone"
            Session.add(model)
            Session.commit()
            self.assertTrue(model.modelId is not None)

        self.assertTrue(nums is not None)
예제 #6
0
    def addModel(self, **kwargs):
        """parameters db model table"""
        model = Model()
        #         model.modelId = kwargs['modelId']
        model.xhdm = kwargs['xhdm']
        model.xhmc = kwargs['xhmc']
        # # registry db sources

        #
        #         saconnect = ISQLAlchemyConnectionStrings(getSite())
        # # Register z3c.saconfig utilities for mysql parameters db
        #         dbURI = saconnect['mysql']
        # # Register z3c.saconfig utilities for pas.plugins.sqlarchemy
        #         engine = EngineFactory(dbURI, echo=False, convert_unicode=False)
        #         provideUtility(engine, name=u"mysql.parameters")
        #         session = GloballyScopedSession(engine=u"mysql.parameters", twophase=False)
        #         provideUtility(session,name=u"mysql.parameters")
        kb_session.add(model)
        try:
            kb_session.commit()
        except:
            kb_session.rollback()
            pass
예제 #7
0
    def setUp(self):
        from emc.kb.mapping_db import Model
        from z3c.saconfig import Session

        model = Model()
        model.cinemaCode = u"ABC1"
        model.filmCode = u"DEF1"
        model.showTime = self.checkDate = datetime.datetime.now(
        ) + datetime.timedelta(days=1)
        model.remainingTickets = 10
        Session.add(model)

        model = Model()
        model.cinemaCode = u"ABC1"
        model.filmCode = u"DEF2"
        model.showTime = datetime.datetime.now() + datetime.timedelta(days=1)
        model.remainingTickets = 10
        Session.add(model)

        model = Model()
        model.cinemaCode = u"ABC1"
        model.filmCode = u"DEF2"
        model.showTime = datetime.datetime.now() + datetime.timedelta(days=-1)
        model.remainingTickets = 10
        Session.add(model)

        Session.flush()

        portal = self.layer['portal']
        setRoles(portal, TEST_USER_ID, ('Manager', ))

        portal.invokeFactory('optilux.CinemaFolder',
                             'cinemas',
                             title=u"Cinemas")

        portal['cinemas'].invokeFactory(
            'optilux.Cinema',
            'cinema1',
            title=u"Cinema 1",
            description=u"First cinema",
            cinemaCode=u"ABC1",
        )
        portal['cinemas'].invokeFactory(
            'optilux.Cinema',
            'cinema2',
            title=u"Cinema 2",
            description=u"Second cinema",
            cinemaCode=u"ABC2",
        )

        portal.invokeFactory('optilux.FilmFolder', 'films', title=u"Films")

        portal['films'].invokeFactory(
            'optilux.Film',
            'film1',
            title=u"Film 1",
            description=u"First film",
            filmCode=u"DEF1",
            startDate=datetime.date.today(),
            endDate=datetime.date.today(),
        )
        portal['films'].invokeFactory(
            'optilux.Film',
            'film2',
            title=u"Film 2",
            description=u"Second film",
            filmCode=u"DEF2",
            startDate=datetime.date.today(),
            endDate=datetime.date.today(),
        )

        import transaction
        transaction.commit()