~gary-lasker/software-center/recommendations-string-change-lp986437-for-5.2

« back to all changes in this revision

Viewing changes to test/test_scagent.py

  • Committer: Gary Lasker
  • Date: 2012-05-31 05:01:54 UTC
  • mfrom: (3035.2.4 client-lp1004417)
  • Revision ID: gary.lasker@canonical.com-20120531050154-jexrutl6mddge31m
* lp:~mvo/software-center/client-lp1004417:
  - client side fix for when exhibit package names contain
    extra whitespace (LP: #1004417)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/python
2
2
 
3
3
from gi.repository import GObject
4
 
from mock import patch
 
4
from mock import Mock, patch
5
5
import unittest
6
6
 
7
7
from testutils import setup_test_env
52
52
                'SoftwareCenterAgentAPI', 'subscriptions_for_me',
53
53
                complete_only=True)
54
54
 
 
55
    def test_regression_lp1004417(self):
 
56
        mock_ex = Mock()
 
57
        mock_ex.package_names = "foo,bar\n\r"
 
58
        results = [mock_ex]
 
59
        sca = SoftwareCenterAgent()
 
60
        sca.emit = Mock()
 
61
        sca._on_exhibits_data_available(None, results)
 
62
        self.assertTrue(sca.emit.called)
 
63
        # get the args to "emit()"
 
64
        args, kwargs = sca.emit.call_args
 
65
        # split the args up
 
66
        scagent, exhibit_list = args
 
67
        # and ensure we get the right list len
 
68
        self.assertEqual(len(exhibit_list), 1)
 
69
        # and the right data in the list
 
70
        exhibit = exhibit_list[0]
 
71
        self.assertEqual(exhibit.package_names, "foo,bar")
 
72
        self.assertFalse(exhibit.package_names.endswith("\n\r"))
55
73
 
56
74
if __name__ == "__main__":
57
75
    import logging