Esempio n. 1
0
def bindInternationalizationSession(proxy): bindSession(proxy, alchemySessionCreator())
def bindInternationalizationValidations(proxy): bindValidations(proxy, mappingsOf(meta))
Esempio n. 2
0
    def test(self):
        articleTypeService = createProxy(IArticleTypeService)(ProxyWrapper(ArticleTypeServiceAlchemy()))
        assert isinstance(articleTypeService, IArticleTypeService)

        bindSession(articleTypeService, self.sessionCreate)
        bindValidations(articleTypeService, mappingsOf(meta))

        setKeepAlive(True)

        at = ArticleType()
        at.Name = 'Test Type 1'
        articleTypeService.insert(at)
        self.assertEqual(at.Id, 1)

        at.Id = 20
        # Validate auto id.
        self.assertRaisesRegex(InputError, "(ArticleType.Id='No value expected')", articleTypeService.insert, at)

        del at.Id
        at.Name = 'Test Type 2'
        articleTypeService.insert(at)
        self.assertEqual(at.Id, 2)

        endSessions(commit)

        at = ArticleType()
        at.Name = 'Test Type 1'
        # Validate unique id.
        self.assertRaisesRegex(InputError, "(ArticleType.Name='Already an entry with this value')",
                               articleTypeService.insert, at)

        at = ArticleType()
        at.Name = 'Test Type 3'
        articleTypeService.insert(at)
        self.assertEqual(at.Id, 3)

        endSessions(commit)

        at = articleTypeService.getById(2)
        at.Name = 'Invalid'
        endSessions(commit)
        at = articleTypeService.getById(2)
        self.assertEqual(at.Name, 'Test Type 2')

        endSessions(commit)

        at = articleTypeService.getById(2)
        at.Name = 'Invalid'
        articleTypeService.update(at)
        endSessions(commit)
        at = articleTypeService.getById(2)
        self.assertEqual(at.Name, 'Invalid')

        articleTypeService.delete(at.Id)
        self.assertRaisesRegex(InputError, "(ArticleType.Id='Unknown id')", articleTypeService.getById, at.Id)

        articleService = createProxy(IArticleService)(ProxyWrapper(ArticleServiceAlchemy()))
        assert isinstance(articleService, IArticleService)

        bindSession(articleService, self.sessionCreate)
        bindValidations(articleService, mappingsOf(meta))

        a = Article()
        a.Name = 'Article 1'
        a.Type = 1
        articleService.insert(a)
        self.assertEqual(a.Id, 1)

        a = Article()
        a.Name = 'Article 2'
        a.Type = 12
        # Invalid foreign key
        self.assertRaisesRegex(InputError, "(Article.Type='Unknown foreign id')", articleService.insert, a)

        endSessions(commit)

        a = articleService.getById(1)
        self.assertEqual(a.Id, 1)
        self.assertEqual(a.Name, 'Article 1')
        self.assertEqual(a.Type, 1)
        at = articleTypeService.getById(a.Type)
        self.assertEqual(at.Id, 1)
        self.assertEqual(at.Name, 'Test Type 1')

        endSessions(commit)

        q = QArticleType()
        q.name.orderDesc()
        self.assertEqual([e.Id for e in articleTypeService.getAll(q=q)], [3, 1])
        q = QArticleType()
        q.name.orderAsc()
        self.assertEqual([e.Id for e in articleTypeService.getAll(q=q)], [1, 3])
        q = QArticleType(name='%1')
        self.assertEqual([e.Id for e in articleTypeService.getAll(q=q)], [1])
Esempio n. 3
0
def userService() -> IUserService:
    b = UserService()
    proxy = createProxy(IUserService)(ProxyWrapper(b))
    bindSession(proxy, alchemySessionCreator())
    return proxy
Esempio n. 4
0
def userService() -> IUserService:
    b = UserService()
    proxy = createProxy(IUserService)(ProxyWrapper(b))
    bindSession(proxy, alchemySessionCreator())
    return proxy
Esempio n. 5
0
def bindSuperdeskSession(proxy): bindSession(proxy, alchemySessionCreator())
def bindSuperdeskValidations(proxy): bindValidations(proxy, mappingsOf(meta))
Esempio n. 6
0
def bindSecuritySession(proxy): bindSession(proxy, alchemySessionCreator())
def bindSecurityValidations(proxy): bindValidations(proxy, mappingsOf(meta))
Esempio n. 7
0
def bindSampleSession(proxy): bindSession(proxy, alchemySessionCreator())
support.listenToEntities(IMPL, listeners=addService(bindSampleSession,))
Esempio n. 8
0
def bindSecuritySession(proxy):
    bindSession(proxy, alchemySessionCreator())
Esempio n. 9
0
def bindExampleSession(proxy):
    bindSession(proxy, alchemySessionCreator())
Esempio n. 10
0
def bindSecuritySession(proxy):
    bindSession(proxy, alchemySessionCreator())
Esempio n. 11
0
def bindInternationalizationSession(proxy):
    bindSession(proxy, alchemySessionCreator())