Example #1
0
    def test_model(self):
        self.service.object.execute.side_effect = self.obj_exec

        self.assertTrue(self.client.models('foo.bar'))
        self.assertCalls(
            OBJ('ir.model', 'search', [('model', 'like', 'foo.bar')]),
            OBJ('ir.model', 'read', [ID2, ID1], ('model', )),
        )
        self.assertOutput('')

        self.assertRaises(erppeek.Error, self.client.model, 'foo.bar')
        self.assertCalls(
            OBJ('ir.model', 'search', [('model', 'like', 'foo.bar')]),
            OBJ('ir.model', 'read', [ID2, ID1], ('model', )),
        )
        self.assertOutput('')

        self.service.object.execute.side_effect = [
            sentinel.IDS, [{
                'id': 13,
                'model': 'foo.bar'
            }]
        ]
        self.assertIsInstance(self.client.model('foo.bar'), erppeek.Model)
        self.assertIs(self.client.model('foo.bar'),
                      erppeek.Model(self.client, 'foo.bar'))
        self.assertIs(self.client.model('foo.bar'), self.client.FooBar)
        self.assertCalls(
            OBJ('ir.model', 'search', [('model', 'like', 'foo.bar')]),
            OBJ('ir.model', 'read', sentinel.IDS, ('model', )),
        )
        self.assertOutput('')
Example #2
0
    def test_model(self):
        # Reset cache for this test
        self.client._models.clear()

        self.assertRaises(erppeek.Error, self.client.model, 'mic.mac')
        self.assertRaises(erppeek.Error, getattr, self.client, 'MicMac')
        self.assertCalls(ANY, ANY, ANY, ANY)
        self.assertOutput('')

        self.assertIs(self.client.model('foo.bar'),
                      erppeek.Model(self.client, 'foo.bar'))
        self.assertIs(self.client.model('foo.bar'), self.client.FooBar)
        self.assertCalls(
            OBJ('ir.model', 'search', [('model', 'like', 'foo.bar')]),
            OBJ('ir.model', 'read', sentinel.FOO, ('model', )),
        )
        self.assertOutput('')
Example #3
0
    def test_model(self):
        # Reset cache for this test
        self.client._models.clear()

        self.assertIsNone(self.client.model('mic.mac'))
        self.assertIsNone(self.client.MicMac)
        self.assertCalls(ANY, ANY, ANY, ANY)
        self.assertIn('Model not found', self.stdout.popvalue())
        self.assertOutput('')

        self.assertIs(self.client.model('foo.bar'),
                      erppeek.Model(self.client, 'foo.bar'))
        self.assertIs(self.client.model('foo.bar'),
                      self.client.FooBar)
        self.assertCalls(
            OBJ('ir.model', 'search', [('model', 'like', 'foo.bar')]),
            OBJ('ir.model', 'read', sentinel.FOO, ('model',)),
        )
        self.assertOutput('')