~submarine/unity-scope-manpages/trunk

« back to all changes in this revision

Viewing changes to tests/test_manpages.py

  • Committer: Mark Tully
  • Date: 2013-01-17 00:34:19 UTC
  • Revision ID: markjtully@gmail.com-20130117003419-bwlbnvfol6vlll80
Initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
 
 
3
from gi.repository import Dee
 
4
from unittest import TestCase, main
 
5
from src import unity_manpages_daemon as scope
 
6
 
 
7
d = scope.Daemon()
 
8
searches = ['submarine']
 
9
mock_data = {'should_pass': 'file:tests/data/mock_manpages_pass#',
 
10
             'should_fail': 'file:tests/data/mock_manpages_fail#'}
 
11
 
 
12
class TestManpages(TestCase):
 
13
 
 
14
    def test_search(self):
 
15
        scope.SEARCH_URI = mock_data['should_pass']
 
16
        model = Dee.SequenceModel.new()
 
17
        model.set_schema('s', 's', 'u', 'u', 's', 's', 's', 's')
 
18
        model.set_column_names('uri', 'icon_hint', 'category', 'result_type',
 
19
                               'mimetype', 'title', 'comment', 'dnd_uri')
 
20
        scope.Daemon.update_results_model(d, searches[0], model)
 
21
        self.assertEqual(model[0][0],
 
22
                         '')
 
23
        self.assertEqual(model[0][1],
 
24
                         '')
 
25
        self.assertEqual(model[0][5],
 
26
                         '')
 
27
        self.assertEqual(model[0][6],
 
28
                         '')
 
29
 
 
30
    def test_failing_search(self):
 
31
        scope.SEARCH_URI = mock_data['should_fail']
 
32
        model = Dee.SequenceModel.new()
 
33
        model.set_schema('s', 's', 'u', 'u', 's', 's', 's', 's')
 
34
        model.set_column_names('uri', 'icon_hint', 'category', 'result_type',
 
35
                               'mimetype', 'title', 'comment', 'dnd_uri')
 
36
        scope.Daemon.update_results_model(d, searches[0], model)
 
37
        self.assertEqual(len(model), 0)
 
38
 
 
39
if __name__ == '__main__':
 
40
    main()