示例#1
0
    def setUpClass(cls):
        c = models.C(id=1)
        c.bs.append(models.B(id=1))
        c.bs.append(models.B(id=2))
        cls.c = c
        cls.c_path = "bs.id"

        b = models.B(id=1)
        b.c = models.C(id=1)
        cls.b = b
        cls.b_path = "c.id"
示例#2
0
    def test_extraquery(self, mock):
        mock.getboolean.return_value = False
        searchentity_b = E(models.B, [F("id", "id")],
                           1.0,
                           extraquery=self.filter_query)

        # Add some objects
        session = self.session
        session.add_all([models.B(id=i) for i in range(1, 30)])
        session.commit()

        # Retrieve them and make sure we only get 20
        query = searchentity_b.query.with_session(session)
        self.assertEqual(len(query.all()), self.FILTER_MAX)
示例#3
0
 def setUp(self):
     config_patcher = mock.patch("sir.config.CFG")
     self.addCleanup(config_patcher.stop)
     instance = config_patcher.start()
     instance.getboolean.return_value = True
     self.entity = E(models.B, [
         F("id", "id"),
         F("c_bar", "c.bar"),
         F("c_bar_trans",
           "c.bar",
           transformfunc=lambda v: v.union(set(["yay"])))
     ], 1.1)
     self.expected = {
         "id": 1,
         "c_bar": "foo",
         "c_bar_trans": ["foo", "yay"],
     }
     c = models.C(id=2, bar="foo")
     self.val = models.B(id=1, c=c)