def setUp(self):
        self.single_query_result = Mock()
        self.single_query_result.rows = fixtures.get_meme("john")
        self.single_query_result.count = 1

        self.multiple_query_result = Mock()
        self.multiple_query_result.rows = [fixtures.get_meme("mike"), fixtures.get_meme("danny")]
        self.multiple_query_result.count = 2
Exemple #2
0
 def setUp(self):
     self.single_query_result = Mock()
     self.single_query_result.rows = fixtures.get_meme('john')
     self.single_query_result.count = 1
     
     self.multiple_query_result = Mock()
     self.multiple_query_result.rows = [
         fixtures.get_meme('mike'),
         fixtures.get_meme('danny'),
     ]
     self.multiple_query_result.count = 2
    def test_should_search_memes(self):
        yql_query = 'SELECT * FROM meme.people(1) WHERE query = "foobar"'

        query_result = Mock()
        query_result.rows = fixtures.get_meme("fred")
        query_result.count = 1

        yql_mock = Mock()
        when(yql_mock).execute(yql_query).thenReturn(query_result)

        meme_repository = MemeRepository()
        meme_repository.yql = yql_mock

        memes = meme_repository.search("foobar", 1)
        assert len(memes) == 1
        assert memes[0].guid == "024"
        assert memes[0].title == "Search Fred"
        assert memes[0].follower_count == 20