def test_set_return_value(self): """Test setting the return value of a query method.""" query = quack.MockQuery() query.filter_by.return_value = 'test' self.assertIs(query.filter_by(), 'test')
def test_all_override(self): """Test overriding all.""" query = quack.MockQuery() query.all.return_value = 'fart' self.assertIs(query.all(), 'fart')
def test_all_no_model_class(self): """Test calling query.all with no model class.""" query = quack.MockQuery() items = query.all() self.assertIs(items, query.all.return_value)
def test_call(self): """Test that MockQuery returns itself when methods are called.""" query = quack.MockQuery() self.assertIs(query.filter(), query) self.assertIs(query.options(), query) self.assertIs(query.having(), query) self.assertIs(query.join(), query)
def setUp(self): self.query = quack.MockQuery(TestClass)
def test_init(self): """Test that MockQuery uses Query as its spec.""" query = quack.MockQuery() self.assertIsInstance(query, Query)
def test_one_no_model_class(self): """Test one with no model class.""" query = quack.MockQuery() self.assertIs(query.one(), query.one.return_value)
def test_get_no_model_class(self): """Test get with no model class.""" query = quack.MockQuery() self.assertIs(query.get('test'), query.get.return_value)
def test_first_no_model_class(self): """Test first with no model class.""" query = quack.MockQuery() self.assertIs(query.first(), query.first.return_value)