Beispiel #1
0
    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')
Beispiel #2
0
    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))
Beispiel #3
0
    def test_entities(self):
        """Test setting the query entites."""
        session = quack.MockSession()
        query = session.query('test', 'another')

        self.assertSequenceEqual(query._mock_entities, ('test', 'another'))
Beispiel #4
0
    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())
Beispiel #5
0
    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)
Beispiel #6
0
    def test_init(self):
        """Test that MockSession uses Session as its spec."""
        session = quack.MockSession()

        self.assertIsInstance(session, Session)