def test_list_files_different_values(self): bucket = PrefixedBucket('hello', self._mock_bucket) self._mock_bucket().upload_from_string('hello/a', 'b') self._mock_bucket().upload_from_string('hello/c', 'd') self._mock_bucket().upload_from_string('hello/d', 'd') self._mock_bucket().upload_from_string('hello/dead', 'd') self.assertEqual(set(['d', 'dead']), set(bucket.list_files('d*')))
def test_prefixes_file_upload_different_values(self): bucket = PrefixedBucket('goodbye', self._mock_bucket) with self._make_temp_file() as file: file.write_and_flush('hello') file.seek(0) bucket.upload_from_file('some_float', file) self.assertEqual('hello', self._mock_bucket().data['goodbye/some_float'])
def test_prefixes_file_upload(self): bucket = PrefixedBucket('hello', self._mock_bucket) with self._make_temp_file() as file: file.write_and_flush('potatoes') file.seek(0) bucket.upload_from_file('some_number', file) self.assertEqual('potatoes', self._mock_bucket().data['hello/some_number'])
def test_prefixes_existence_missing_different_values(self): bucket = PrefixedBucket('nope', self._mock_bucket) self.assertFalse(bucket.exists('box'))
def test_prefixes_existence_missing(self): bucket = PrefixedBucket('hello', self._mock_bucket) self.assertFalse(bucket.exists('some_string'))
def test_prefixes_existence_different_values(self): bucket = PrefixedBucket('nope', self._mock_bucket) self._mock_bucket().upload_from_string('nope/box', 'knife') self.assertTrue(bucket.exists('box'))
def test_prefixes_existence(self): bucket = PrefixedBucket('hello', self._mock_bucket) self._mock_bucket().upload_from_string('hello/some_string', 'yup') self.assertTrue(bucket.exists('some_string'))
def test_prefixes_file_download_different_values(self): bucket = PrefixedBucket('plastic', self._mock_bucket) self._mock_bucket().upload_from_string('plastic/bags', 'are dangerous') with self._make_temp_file() as file: bucket.download_to_file('bags', file) self.assertEqual('are dangerous', file.read())
def test_prefixes_string_upload(self): bucket = PrefixedBucket('hello', self._mock_bucket) bucket.upload_from_string('some_number', 12323) self.assertEqual(12323, self._mock_bucket().data['hello/some_number'])
def test_moves_file_different_name(self): bucket = PrefixedBucket('also_dunno', self._mock_bucket) bucket.upload_from_string('some_float', 12.33) bucket.move('some_float', 'some_other_float') self.assertEqual(12.33, bucket.download_as_string('some_other_float'))
def test_moves_file(self): bucket = PrefixedBucket('hello', self._mock_bucket) bucket.upload_from_string('some_number', 12323) bucket.move('some_number', 'some_other_number') self.assertEqual(12323, bucket.download_as_string('some_other_number'))
def test_removes_file_different_values(self): bucket = PrefixedBucket('dunno', self._mock_bucket) bucket.upload_from_string('some_other_number', 12323) bucket.remove('some_other_number') self.assertFalse(bucket.exists('some_other_number'))
def test_removes_file(self): bucket = PrefixedBucket('hello', self._mock_bucket) bucket.upload_from_string('some_number', 12323) bucket.remove('some_number') self.assertFalse(bucket.exists('some_number'))
def test_list_files(self): bucket = PrefixedBucket('hello', self._mock_bucket) self._mock_bucket().upload_from_string('hello/a', 'b') self._mock_bucket().upload_from_string('hello/c', 'd') self.assertEqual(set(['a', 'c']), set(bucket.list_files('*')))
def test_prefixes_string_download(self): bucket = PrefixedBucket('hello', self._mock_bucket) self._mock_bucket().upload_from_string('hello/some_number', 12323) self.assertEqual(12323, bucket.download_as_string('some_number'))
def test_prefixes_string_upload_different_values(self): bucket = PrefixedBucket('goodbye', self._mock_bucket) bucket.upload_from_string('some_float', 12.3) self.assertEqual(12.3, self._mock_bucket().data['goodbye/some_float'])
def test_prefixes_string_download_different_values(self): bucket = PrefixedBucket('nope', self._mock_bucket) self._mock_bucket().upload_from_string('nope/some_string', 'yup') self.assertEqual('yup', bucket.download_as_string('some_string'))
def test_prefixes_file_download(self): bucket = PrefixedBucket('nope', self._mock_bucket) self._mock_bucket().upload_from_string('nope/some_string', 'yup') with self._make_temp_file() as file: bucket.download_to_file('some_string', file) self.assertEqual('yup', file.read())