Revision 49cc29b2 kamaki/clients/pithos/test.py

b/kamaki/clients/pithos/test.py
1103 1103

  
1104 1104
    @patch('%s.get_object_hashmap' % pithos_pkg, return_value=object_hashmap)
1105 1105
    @patch('%s.object_get' % pithos_pkg, return_value=FR())
1106
    def test_download_to_string(self, GET, GOH):
1107
        FR.content = 'some sample content'
1108
        num_of_blocks = len(object_hashmap['hashes'])
1109
        r = self.client.download_to_string(obj)
1110
        expected_content = FR.content * num_of_blocks
1111
        self.assertEqual(expected_content, r)
1112
        self.assertEqual(len(GET.mock_calls), num_of_blocks)
1113
        self.assertEqual(GET.mock_calls[-1][1], (obj,))
1114

  
1115
        kwargs = dict(
1116
            version='version',
1117
            range_str='10-20',
1118
            if_match='if and only if',
1119
            if_none_match='if and only not',
1120
            if_modified_since='what if not?',
1121
            if_unmodified_since='this happens if not!')
1122
        expargs = dict(kwargs)
1123
        expargs.pop('range_str')
1124
        for k in expargs:
1125
            expargs[k] = None
1126
        GOH.assert_called_once_with(obj, **expargs)
1127

  
1128
        r = self.client.download_to_string(obj, **kwargs)
1129
        expargs['data_range'] = 'bytes=%s' % kwargs['range_str']
1130
        for k, v in expargs.items():
1131
            self.assertEqual(
1132
                GET.mock_calls[-1][2][k],
1133
                v or kwargs.get(k))
1134

  
1135
    @patch('%s.get_object_hashmap' % pithos_pkg, return_value=object_hashmap)
1136
    @patch('%s.object_get' % pithos_pkg, return_value=FR())
1106 1137
    def test_download_object(self, GET, GOH):
1107 1138
        num_of_blocks = 8
1108 1139
        tmpFile = self._create_temp_file(num_of_blocks)

Also available in: Unified diff