Source

cloudster / api / storages / adapters / box / test.py

Full commit
import unittest
from api.storages.adapters.box import adapter
from api.storages.adapters import events

class BoxAdapterTest(unittest.TestCase):


    def setUp(self):

        f = open('test_data/box_account.json','r')
        data = f.read()

        account_data = adapter.BoxAccountData(data)

        self._client = adapter.BoxClient(account_data)
        self._client.connect()


    @unittest.skip("test_001_write: Skipped until upload service is up again")
    def test_001_write(self):
        self._client.write('/Cryptography/Week1/cloudster/mytestdoc.pdf','/home/guillermo/development/workspace/cloudster/api/storages/clients/box/test_data/panificadora.pdf')

    @unittest.skip("test_002_list: Skipped until upload service is up again")
    def test_002_list(self):
        self._client.list('/Cryptography/Week1')
        self._client.list('/LinuxJournal/201101.pdf')

    #@unittest.skip("test_003_read: Skipped until upload service is up again")
    def test_003_read(self):
        self._client.read('/LinuxJournal/201101.pdf','/home/guillermo/test.pdf')

    @unittest.skip("test_004_remove: Skipped until upload service is up again")
    def test_004_remove(self):
        self._client.remove('/Cryptography/Week1/cloudster/README')

    @unittest.skip("Not fully implemented yet")
    def test_005_translateEvents(self):

        print 'Testing events translations....'

        current_events = self._client.events()

        self.assertIsInstance(current_events, events.EventsBrowser,'Events list is not an api.storages.adapters.events.EventsBrowser instance')

        for event in current_events:
            print 'Current event is %(event)s' % {"event":event}

    if __name__ == '__main__':
        unittest.main()