コード例 #1
0
    def test_to_from_JSON(self):
        session = SearchSession('some_query')
        for i in range(self.RANK_MAX):
            result = SearchResult('doc%d' % i, i % 2)
            session.web_results.append(result)
        session_encoded = session.to_JSON()
        session_decoded = SearchSession.from_JSON(session_encoded)

        self.assertEqual(session.query, session_decoded.query)
        for i in range(len(session.web_results)):
            self.assertEqual(session.web_results[i].__dict__, session_decoded.web_results[i].__dict__)
コード例 #2
0
 def test_get_last_click_rank(self, name, clicks, expected):
     session = SearchSession('some_query')
     for i in range(self.RANK_MAX):
         result = SearchResult('doc%d' % i, clicks[i])
         session.web_results.append(result)
     self.assertEqual(session.get_last_click_rank(), expected)