~ps-jenkins/unity-scope-yelp/latestsnapshot-0.1daily13.04.23ubuntu.unity.experimental.certified-0ubuntu1

« back to all changes in this revision

Viewing changes to tests/test_yelp.py

  • Committer: Tarmac
  • Author(s): Mark Tully
  • Date: 2013-04-21 08:33:33 UTC
  • mfrom: (22.2.6 yelp - limit results)
  • Revision ID: tarmac-20130421083333-i9ohljnmsvaj41ck
Changed DEFAULT_RESULT_MIMETYPE to text/html

Set maximum number of results returned to 25 (defined by MAX_RESULTS)

Added do_activate method to Scope to allow result to open in yelp when clicked.

Approved by PS Jenkins bot, David Callé.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
from gi.repository import Unity
4
4
from unittest import TestCase
5
5
import imp
 
6
import os
6
7
 
7
8
 
8
9
class ResultSet(Unity.ResultSet):
34
35
 
35
36
    def setUp(self):
36
37
        self.init_scope('src/unity_yelp_daemon.py')
 
38
        self.scope_module.YELP_EXECUTABLE = os.path.join(
 
39
            os.path.dirname(__file__), "fake-yelp.py")
37
40
 
38
41
    def tearDown(self):
39
42
        self.scope = None
50
53
            results.append(result_set.results[0]['title'])
51
54
        self.assertEqual(results, expected_results)
52
55
 
53
 
 
54
56
    def test_questions_failing_search(self):
55
57
        self.scope_module.HELP_DIR = 'tests/data/'
56
58
        for s in ['upnriitnyt']:
57
59
            result_set = self.perform_query(s)
58
60
            self.assertEqual(len(result_set.results), 0)
59
61
 
 
62
    def test_activation(self):
 
63
        result = Unity.ScopeResult()
 
64
        result.uri = "tests/data/C/sample_help/mock_yelp_file"
 
65
        activation = self.scope.activate(result, Unity.SearchMetadata(), None)
 
66
        self.assertEqual(activation.props.goto_uri, None)
 
67
        self.assertEqual(activation.props.handled, Unity.HandledType.HIDE_DASH)
 
68
 
 
69
 
60
70
if __name__ == '__main__':
61
71
    unittest.main()