~paulliu/friends/add-twitter-contacts

« back to all changes in this revision

Viewing changes to friends/tests/test_avatars.py

  • Committer: Robert Bruce Park
  • Date: 2012-11-14 21:17:40 UTC
  • mfrom: (70.1.1 fix_avatars_dir_tests)
  • Revision ID: robert.park@canonical.com-20121114211740-jhujzgf1kpyqx4b7
Test fixups, thanks to Ken.

Show diffs side-by-side

added added

removed removed

Lines of Context:
75
75
            # The file has not yet been downloaded because the directory does
76
76
            # not yet exist.  It is created on demand.
77
77
            self.assertFalse(os.path.isdir(cache_dir))
 
78
            os.makedirs(cache_dir)
78
79
            Avatar.get_image('http://example.com')
79
80
            # Soup.Message() was called once.  Get the mock and check it.
80
81
            from friends.utils.http import Soup
111
112
                FakeSoupMessage('friends.tests.data', 'ubuntu.png'))
112
113
    def test_cache_file_contains_image(self):
113
114
        # The image is preserved in the cache file.
114
 
        with mock.patch('friends.utils.avatar.CACHE_DIR', self._avatar_cache):
 
115
        with mock.patch('friends.utils.avatar.CACHE_DIR',
 
116
                        self._avatar_cache) as cache_dir:
 
117
            os.makedirs(cache_dir)
115
118
            path = Avatar.get_image('http://example.com')
116
119
        # The image must have been downloaded at least once.
117
120
        pixbuf = GdkPixbuf.Pixbuf.new_from_file(path)