~ps-jenkins/unity-scope-yelp/latestsnapshot-0.1daily13.06.05-0ubuntu1

« back to all changes in this revision

Viewing changes to tests/test_yelp.py

  • Committer: Tarmac
  • Author(s): James Henstridge
  • Date: 2013-05-13 09:03:50 UTC
  • mfrom: (27.1.2 unity-scope-yelp)
  • Revision ID: tarmac-20130513090350-8nhqtzgv1jcoq02a
Add a simple preview to the scope, and correctly discover documentation in the fallback "C" directory when there are localised manuals.

Approved by David Callé, PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
 
45
45
    def test_questions_search(self):
46
46
        self.scope_module.HELP_DIR = 'tests/data/'
47
 
        expected_results = ["tests/data/C/sample_help/mock_yelp_file",
48
 
                            "A visual introduction to the Unity desktop."]
 
47
        expected_results = ["tests/data/C/sample_help/mock_yelp_file.page",
 
48
                            "Welcome to Ubuntu"]
49
49
        results = []
50
 
        for s in ['unity']:
51
 
            result_set = self.perform_query(s)
52
 
            results.append(result_set.results[0]['uri'])
53
 
            results.append(result_set.results[0]['title'])
54
 
        self.assertEqual(results, expected_results)
 
50
        result_set = self.perform_query('unity')
 
51
        self.assertEqual(len(result_set.results), 1)
 
52
        result = result_set.results[0]
 
53
        self.assertEqual(
 
54
            result['uri'], "tests/data/C/sample_help/mock_yelp_file.page")
 
55
        self.assertEqual(result['title'], "Welcome to Ubuntu")
 
56
        self.assertEqual(
 
57
            result['comment'], "A visual introduction to the Unity desktop.")
 
58
        self.assertEqual(result['icon'], 'sample_help')
55
59
 
56
60
    def test_questions_failing_search(self):
57
61
        self.scope_module.HELP_DIR = 'tests/data/'
58
 
        for s in ['upnriitnyt']:
59
 
            result_set = self.perform_query(s)
60
 
            self.assertEqual(len(result_set.results), 0)
 
62
        result_set = self.perform_query('upnriitnyt')
 
63
        self.assertEqual(len(result_set.results), 0)
 
64
 
 
65
    def test_preview(self):
 
66
        result = Unity.ScopeResult()
 
67
        result.uri = "tests/data/C/sample_help/mock_yelp_file.page"
 
68
        result.title = "Welcome to Ubuntu"
 
69
        result.comment = "A visual introduction to the Unity desktop."
 
70
        result.icon_hint = 'sample_help'
 
71
 
 
72
        previewer = self.scope.create_previewer(result, Unity.SearchMetadata())
 
73
        preview = previewer.run()
 
74
        self.assertEqual(preview.props.title, "Welcome to Ubuntu")
 
75
        self.assertEqual(preview.props.description_markup,
 
76
                         "A visual introduction to the Unity desktop.")
 
77
        self.assertNotEqual(preview.props.image, None)
 
78
        self.assertEqual(preview.props.image.get_names(), ['sample_help'])
61
79
 
62
80
    def test_activation(self):
63
81
        result = Unity.ScopeResult()
64
 
        result.uri = "tests/data/C/sample_help/mock_yelp_file"
 
82
        result.uri = "tests/data/C/sample_help/mock_yelp_file.page"
65
83
        activation = self.scope.activate(result, Unity.SearchMetadata(), None)
66
84
        self.assertEqual(activation.props.goto_uri, None)
67
85
        self.assertEqual(activation.props.handled, Unity.HandledType.HIDE_DASH)