def test_query_return_value(self): """Test overriding query's return value.""" session = quack.MockSession() session.query.return_value = 'test' self.assertIs(session.query(), 'test')
def test_mock_queries(self): """Test getting all queries performed with the session.""" session = quack.MockSession() query1 = session.query() query2 = session.query() self.assertSequenceEqual(session.mock_queries, (query1, query2))
def test_entities(self): """Test setting the query entites.""" session = quack.MockSession() query = session.query('test', 'another') self.assertSequenceEqual(query._mock_entities, ('test', 'another'))
def test_query_multiple(self): """Test that the same MockQuery is returned for every query call.""" session = quack.MockSession() self.assertIsNot(session.query(), session.query())
def test_query(self, mock_query): """Test that the query method returns a MockQuery.""" session = quack.MockSession() self.assertIs(session.query(), mock_query.return_value)
def test_init(self): """Test that MockSession uses Session as its spec.""" session = quack.MockSession() self.assertIsInstance(session, Session)