~ubuntu-branches/ubuntu/raring/software-center/raring-proposed

« back to all changes in this revision

Viewing changes to tests/test_scagent.py

  • Committer: Package Import Robot
  • Author(s): Michael Vogt
  • Date: 2012-10-11 15:33:05 UTC
  • mfrom: (195.1.18 quantal)
  • Revision ID: package-import@ubuntu.com-20121011153305-fm5ln7if3rpzts4n
Tags: 5.4.1.1
* lp:~mvo/software-center/reinstall-previous-purchase-token-fix:
  - fix reinstall previous purchases that have a system-wide
    license key LP: #1065481
* lp:~mvo/software-center/lp1060106:
  - Add missing gettext init for utils/update-software-center-agent
    (LP: #1060106)

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
                'SoftwareCenterAgentAPI', 'subscriptions_for_me',
54
54
                complete_only=True)
55
55
 
 
56
 
 
57
class RegressionsTestCase(unittest.TestCase):
 
58
 
 
59
    def setUp(self):
 
60
        self.sca = SoftwareCenterAgent()
 
61
        self.sca.emit = Mock()
 
62
        
 
63
    def _get_exhibit_list_from_emit_call(self):
 
64
        args, kwargs = self.sca.emit.call_args
 
65
        scagent, exhibit_list = args
 
66
        return exhibit_list
 
67
 
56
68
    def test_regression_lp1004417(self):
57
69
        mock_ex = Mock()
58
70
        mock_ex.package_names = "foo,bar\n\r"
59
71
        results = [mock_ex]
60
 
        sca = SoftwareCenterAgent()
61
 
        sca.emit = Mock()
62
 
        sca._on_exhibits_data_available(None, results)
63
 
        self.assertTrue(sca.emit.called)
64
 
        # get the args to "emit()"
65
 
        args, kwargs = sca.emit.call_args
66
 
        # split the args up
67
 
        scagent, exhibit_list = args
 
72
        self.sca._on_exhibits_data_available(None, results)
 
73
        self.assertTrue(self.sca.emit.called)
68
74
        # and ensure we get the right list len
 
75
        exhibit_list = self._get_exhibit_list_from_emit_call()
69
76
        self.assertEqual(len(exhibit_list), 1)
70
77
        # and the right data in the list
71
78
        exhibit = exhibit_list[0]
72
79
        self.assertEqual(exhibit.package_names, "foo,bar")
73
80
        self.assertFalse(exhibit.package_names.endswith("\n\r"))
74
81
 
 
82
    def test_regression_lp1043152(self):
 
83
        mock_ex = Mock()
 
84
        mock_ex.package_names = "moo, baa, lalala"
 
85
        results = [mock_ex]
 
86
        self.sca._on_exhibits_data_available(None, results)
 
87
        # ensure that the right data in the list
 
88
        exhibit = self._get_exhibit_list_from_emit_call()[0]
 
89
        self.assertEqual(exhibit.package_names, "moo,baa,lalala")
 
90
 
75
91
if __name__ == "__main__":
76
92
    unittest.main()