Esempio n. 1
0
    def test_create(self):

        data = 'some test data'
        md5 = hashlib.md5()
        md5.update(str.encode(data))
        data_md5 = base64.b64encode(md5.digest()).decode()
        sot = obj.Object(name='test-v1', data=data)

        mock_response = mock.Mock()
        mock_response.status_code = 200
        mock_response.content = ''
        mock_response.headers = {}

        self.sess.put.return_value = mock_response

        sot.create(
            self.sess,
            endpoint_override='epo',
            requests_auth=2)

        self.sess.put.assert_called_once_with(
            '/test-v1',
            data=data,
            endpoint_override='epo',
            requests_auth=2,
            headers={
                'Content-MD5': data_md5
            }
        )
Esempio n. 2
0
    def test_make_it(self):

        sot = obj.Object(**EXAMPLE)
        self.assertEqual(EXAMPLE['Key'], sot.id)
        self.assertEqual(EXAMPLE['Key'], sot.name)
        self.assertEqual(EXAMPLE['LastModified'], sot.last_modified)
        self.assertEqual(EXAMPLE['ETag'], sot.etag)
Esempio n. 3
0
    def test_basic(self):
        sot = obj.Object()

        self.assertEqual('/', sot.base_path)

        self.assertTrue(sot.allow_list)
        self.assertTrue(sot.allow_get)
        self.assertTrue(sot.allow_head)
        self.assertTrue(sot.allow_create)
        self.assertTrue(sot.allow_delete)
Esempio n. 4
0
    def test_list(self):

        sot = obj.Object()

        mock_response = mock.Mock()
        mock_response.status_code = 200
        mock_response.content = EXAMPLE_LIST

        self.sess.get.return_value = mock_response

        result = list(sot.list(self.sess, ))

        self.assertEqual(1, len(result))
        self.assertEqual('setup.py', result[0].name)
        self.assertEqual('9c24605289b49ad77a51ba7986425158', result[0].etag)
        self.assertEqual(1030, result[0].content_length)