Exemple #1
0
 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*')))
Exemple #2
0
 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'])
Exemple #3
0
 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'])
Exemple #4
0
 def test_prefixes_existence_missing_different_values(self):
     bucket = PrefixedBucket('nope', self._mock_bucket)
     self.assertFalse(bucket.exists('box'))
Exemple #5
0
 def test_prefixes_existence_missing(self):
     bucket = PrefixedBucket('hello', self._mock_bucket)
     self.assertFalse(bucket.exists('some_string'))
Exemple #6
0
 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'))
Exemple #7
0
 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'))
Exemple #8
0
 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())
Exemple #9
0
 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'])
Exemple #10
0
 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'))
Exemple #11
0
 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'))
Exemple #12
0
 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'))
Exemple #13
0
 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'))
Exemple #14
0
 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('*')))
Exemple #15
0
 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'))
Exemple #16
0
 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'])
Exemple #17
0
 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'))
Exemple #18
0
 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())