Пример #1
0
    def test_list_assign_compound(self):
        m = UserProfilePhotos()

        m.total_count = 5  # Set wrong length
        m.photos[0].file_id = 'foo.png'
        m.photos[0].width = 320
        m.photos[0].height = 200

        m.photos[1].file_id = 'bar.png'
        m.photos[1].width = 640
        m.photos[1].height = 400

        r = m._to_raw()

        ex = {
            'photos': [{
                'file_id': 'foo.png',
                'height': 200,
                'width': 320
            }, {
                'file_id': 'bar.png',
                'height': 400,
                'width': 640
            }],
            'total_count':
            2
        }  # Verify that UserProfilePhotos sets total_count
        self.assertEquals(ex, r)
Пример #2
0
    def test_list_assign_compound_missing(self):
        m = UserProfilePhotos()

        m.total_count = 3
        m.photos[2].file_id = 'foo.png'
        m.photos[2].width = 320
        m.photos[2].height = 200

        m.photos[0].file_id = 'bar.png'
        m.photos[0].width = 640
        m.photos[0].height = 400

        self.assertRaises(IndexError, m._to_raw)
Пример #3
0
    def test_list_assign_compound_missing(self):
        m = UserProfilePhotos()

        m.total_count = 3
        m.photos[2].file_id = 'foo.png'
        m.photos[2].width = 320
        m.photos[2].height = 200

        m.photos[0].file_id = 'bar.png'
        m.photos[0].width = 640
        m.photos[0].height = 400

        self.assertRaises(IndexError, m._to_raw)
Пример #4
0
    def test_bad_list_index(self):
        m = UserProfilePhotos()

        def g():
            return m.photos[2][0]

        self.assertRaises(AttributeError, g)
Пример #5
0
    def test_list_assign_compound(self):
        m = UserProfilePhotos()

        m.total_count = 5  # Set wrong length
        m.photos[0].file_id = 'foo.png'
        m.photos[0].width = 320
        m.photos[0].height = 200

        m.photos[1].file_id = 'bar.png'
        m.photos[1].width = 640
        m.photos[1].height = 400

        r = m._to_raw()

        ex = {'photos': [{'file_id': 'foo.png', 'height': 200, 'width': 320},
                         {'file_id': 'bar.png', 'height': 400, 'width': 640}
                         ],
              'total_count': 2}  # Verify that UserProfilePhotos sets total_count
        self.assertEquals(ex, r)