<commit_before>#!/usr/bin/env python

from boto.s3.connection import S3Connection, OrdinaryCallingFormat
from boto.s3.key import Key
import unittest, time

KEY_ID="0"
SECRET_KEY="<KEY>"
HOST="127.0.0.1"
PORT=80
data = file("/dev/random").read(1024)


class ParityWithPrototypeTest(unittest.TestCase):
    def setUp(self):
        self.bucket_name = "parity-test"
        self.key_name = "parity-test"
        self.conn = S3Connection(KEY_ID, SECRET_KEY, is_secure=False, 
                                 host=HOST, port=PORT, debug=True, 
                                 calling_format=OrdinaryCallingFormat())


    def test_1_create_bucket(self):
        self.conn.create_bucket(self.bucket_name)

    def test_2_list_buckets(self):
        self.assertIn(self.bucket_name, 
                      [b.name for b in self.conn.get_all_buckets()])        

    def test_3_put_object(self):
        bucket = self.conn.get_bucket(self.bucket_name)
        k = Key(bucket)
        k.key = self.key_name
        k.set_contents_from_string("parity-test")

    def test_4_get_object(self):
        bucket = self.conn.get_bucket(self.bucket_name)
        k = Key(bucket)
        k.key = self.key_name        
        self.assertEqual(k.get_contents_as_string(), "parity-test")

    def test_5_list_bucket(self):
        bucket = self.conn.get_bucket(self.bucket_name)
        self.assertIn(self.key_name,
                      [k.key for k in bucket.get_all_keys()])

    def test_6_delete_object(self):
        bucket = self.conn.get_bucket(self.bucket_name)
        k = Key(bucket)
        k.key = self.key_name                
        k.delete()

    def test_7_list_bucket(self):
        time.sleep(3) # XXX HACK
        bucket = self.conn.get_bucket(self.bucket_name)
        self.assertNotIn(self.key_name,
                         [k.key for k in bucket.get_all_keys()])

    def test_8_delete_bucket(self):
        bucket = self.conn.get_bucket(self.bucket_name)
        bucket.delete()

    def test_9_list_buckets(self):
        self.assertNotIn(self.bucket_name, 
                         [b.name for b in self.conn.get_all_buckets()])                

if __name__ == "__main__":
    unittest.main()<commit_msg>test auth, use random data and key/bucket names<commit_after>#!/usr/bin/env python

from boto.exception import S3ResponseError
from boto.s3.connection import S3Connection, OrdinaryCallingFormat
from boto.s3.key import Key
import unittest, time, uuid

KEY_ID="0"
SECRET_KEY="<KEY>"
HOST="127.0.0.1"
PORT=80

class ParityWithPrototypeTest(unittest.TestCase):

    def make_connection(self, key_id=KEY_ID, secret_key=SECRET_KEY):
        return S3Connection(key_id, secret_key, is_secure=False, 
                            host=HOST, port=PORT, debug=True, 
                            calling_format=OrdinaryCallingFormat() )       
    @classmethod
    def setUpClass(self):
        self.bucket_name = str(uuid.uuid4())
        self.key_name = str(uuid.uuid4())
        self.data = file("/dev/random").read(1024)

    def setUp(self):
        self.conn = self.make_connection()

    def test_0_auth(self):
        conn = self.make_connection("BAD_ID", "BAD_KEY")
        self.assertRaises(S3ResponseError, conn.get_canonical_user_id)

    def test_1_create_bucket(self):
        self.conn.create_bucket(self.bucket_name)

    def test_2_list_buckets(self):
        self.assertIn(self.bucket_name, 
                      [b.name for b in self.conn.get_all_buckets()])        

    def test_3_put_object(self):
        bucket = self.conn.get_bucket(self.bucket_name)
        k = Key(bucket)
        k.key = self.key_name
        k.set_contents_from_string(self.data)

    def test_4_get_object(self):
        bucket = self.conn.get_bucket(self.bucket_name)
        k = Key(bucket)
        k.key = self.key_name        
        self.assertEqual(k.get_contents_as_string(), self.data)

    def test_5_list_bucket(self):
        bucket = self.conn.get_bucket(self.bucket_name)
        self.assertIn(self.key_name,
                      [k.key for k in bucket.get_all_keys()])

    def test_6_delete_object(self):
        bucket = self.conn.get_bucket(self.bucket_name)
        k = Key(bucket)
        k.key = self.key_name                
        k.delete()

    def test_7_list_bucket(self):
        time.sleep(3) # XXX HACK
        bucket = self.conn.get_bucket(self.bucket_name)
        self.assertNotIn(self.key_name,
                         [k.key for k in bucket.get_all_keys()])

    def test_8_delete_bucket(self):
        bucket = self.conn.get_bucket(self.bucket_name)
        bucket.delete()

    def test_9_list_buckets(self):
        self.assertNotIn(self.bucket_name, 
                         [b.name for b in self.conn.get_all_buckets()]) 
               

if __name__ == "__main__":
    unittest.main()
{'fraction_non_alphanumeric': 0.10644025678194242, 'fraction_numerical': 0.012217850486643197, 'mean_word_length': 2.361169102296451, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5254927', 'n_tokens_mistral': 1634, 'n_tokens_neox': 1576, 'n_words': 257}