~nik90/ubuntu/precise/software-center/add_keywords

« back to all changes in this revision

Viewing changes to test/test_recagent.py

  • Committer: Package Import Robot
  • Author(s): Michael Vogt, Michael Vogt, Brendan Donegan, Gary Lasker
  • Date: 2012-02-03 18:34:43 UTC
  • Revision ID: package-import@ubuntu.com-20120203183443-1r39x52ozrb1revz
Tags: 5.1.8
[ Michael Vogt ]
* softwarecenter/db/update.py:
  - trivial fix to skip unreadable app-install-data files
* lp:~mvo/software-center/device-profiles:
  - implement the hardware-requirements display in
    the detailsview
* lp:~mvo/software-center/arb-partner-channels:
  - add support for extras.ubuntu.com and archive.canonical.com
    channel detection and adding via software-center-agent
* data/software-center.menu.in:
  - do not show "X-Publishing" in education because the
    software-center-agent will send "X-Publishing;Education" for
    compatibility with the old clients
* lp:~mvo/software-center/fix-cachedir-for-public-api:
  - add missing cachedir argument
* lp:~mvo/software-center/region-support:
  - add support for a region tag and display a warning to
    the user if an application is not suitable for their
    region

[ Brendan Donegan ]
* lp:~brendan-donegan/software-center/test_utils_get_nice_date_string:
  - add a test function in test_utils.py which covers all of
    get_nice_date_string

[ Gary Lasker ]
* lp:~gary-lasker/software-center/launcher-integration-lp761851:
  - update to the Unity launcher integration implementation to
    support the revamped functionality on the Unity side (LP: #761851) 
* lp:~gary-lasker/software-center/recommends-ui-lobby:
  - initial recommends UI implementation, limited to non-personalized
    recommends currently
* lp:~gary-lasker/software-center/appdetailsview-button-focus-fix:
  - make sure the action button in the applications details view
    always gets the initial focus (LP: #925613)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
 
 
3
from gi.repository import GObject
 
4
import unittest
 
5
import os
 
6
 
 
7
from testutils import setup_test_env
 
8
setup_test_env()
 
9
 
 
10
from softwarecenter.backend.recommends import RecommenderAgent
 
11
 
 
12
class TestRecommenderAgent(unittest.TestCase):
 
13
    """ tests the recommender agent """
 
14
 
 
15
    def setUp(self):
 
16
        self.loop = GObject.MainLoop(GObject.main_context_default())
 
17
        self.error = False
 
18
 
 
19
    def on_query_done(self, recagent, data):
 
20
        print "query done, data: '%s'" % data
 
21
        self.loop.quit()
 
22
        
 
23
    def on_query_error(self, recagent, error):
 
24
        self.loop.quit()
 
25
        self.error = True
 
26
        
 
27
    # disabled as the server returns 503 currently
 
28
    def disabled_test_recagent_query_recommend_top(self):
 
29
        # NOTE: This requires a working recommender host that is reachable
 
30
        os.environ["SOFTWARE_CENTER_RECOMMENDER_HOST"] = "https://rec.staging.ubuntu.com/"
 
31
        recommender_agent = RecommenderAgent()
 
32
        recommender_agent.connect("recommend-top", self.on_query_done)
 
33
        recommender_agent.connect("error", self.on_query_error)
 
34
        recommender_agent.query_recommend_top()
 
35
        self.loop.run()
 
36
        self.assertFalse(self.error)
 
37
        del os.environ["SOFTWARE_CENTER_RECOMMENDER_HOST"]
 
38
        
 
39
#    def test_recagent_query_recommend_me(self):
 
40
#        os.environ["SOFTWARE_CENTER_RECOMMENDER_HOST"] = "https://rec.staging.ubuntu.com/"
 
41
#        recommender_agent = RecommenderAgent()
 
42
#        recommender_agent.connect("recommend-me", self.on_query_done)
 
43
#        recommender_agent.connect("error", self.on_query_error)
 
44
#        recommender_agent.query_recommend_me()
 
45
#        self.loop.run()
 
46
#        self.assertFalse(self.error)
 
47
#        del os.environ["SOFTWARE_CENTER_RECOMMENDER_HOST"]
 
48
        
 
49
    def test_recagent_query_error(self):
 
50
        # there definitely ain't no server here
 
51
        os.environ["SOFTWARE_CENTER_RECOMMENDER_HOST"] = "https://orange.staging.ubuntu.com/"
 
52
        recommender_agent = RecommenderAgent()
 
53
        recommender_agent.connect("recommend-top", self.on_query_done)
 
54
        recommender_agent.connect("error", self.on_query_error)
 
55
        recommender_agent.query_recommend_top()
 
56
        self.loop.run()
 
57
        self.assertTrue(self.error)
 
58
        
 
59
        del os.environ["SOFTWARE_CENTER_RECOMMENDER_HOST"]
 
60
 
 
61
 
 
62
if __name__ == "__main__":
 
63
    import logging
 
64
    logging.basicConfig(level=logging.DEBUG)
 
65
    unittest.main()