# coding: utf-8

"""
    Aspose.Storage for Cloud API

    No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)

    OpenAPI spec version: 1.0
    
    Generated by: https://github.com/swagger-api/swagger-codegen.git
"""


from __future__ import absolute_import

import os
import sys
import unittest

import asposestoragecloud
from asposestoragecloud.rest import ApiException
from asposestoragecloud.apis.storage_api import StorageApi
from asposestoragecloud.api_client import ApiClient

class TestStorageApi(unittest.TestCase):
    """ StorageApi unit test stubs """

    def setUp(self):
        ABSPATH = os.path.abspath(os.path.realpath(os.path.dirname(__file__)) + "/..")
        self.dataFolder = os.path.join(ABSPATH, "Data")
        
        self.apiClient = ApiClient(apiKey='xxxx', appSid='xxxx-xxxx-xxxx-xxxxxx')
        self.api = asposestoragecloud.apis.storage_api.StorageApi(self.apiClient)

    def tearDown(self):
        pass

    # File APIs Test Cases
    def test_put_create(self):
        """
        Test case for put_create

        Upload a specific file 
        """
        fileName = "Aspose_test.png" #"testfile.txt"
        filePath = os.path.join(self.dataFolder, fileName)
        with open(filePath, 'rb') as fp:
            fileData = fp.read()
        response = self.api.put_create(fileName, fileData)
        self.assertTrue(response)

    def test_get_download(self):
        """
        Test case for get_download
        
        Download a specific file
        """
        fileName = 'testfile.txt'
        response = self.api.get_download(fileName)
        self.assertTrue(response)

    def test_post_move_file(self):
        """
        Test case for post_move_file
        
        Move a specific file
        """
        src =  "testfile.txt"
        dest = os.path.join("Documents", "testfile.txt")
        response = self.api.post_move_file(src, dest)
        self.assertTrue(response)

    def test_delete_file(self):
        """
        Test case for delete_file
        
        Remove a specific file
        """
        fileName = 'testfile.txt'
        response = self.api.delete_file(fileName)
        self.assertTrue(response['Code'] == 200)


    # Folder APIs Test Cases
    def test_get_list_files(self):
        """
        Test case for get_list_files
        
        Get the file listing of a specific folder
        """
        response = self.api.get_list_files()
        self.assertTrue(response)

    def test_put_create_folder(self):
        """
        Test case for put_create_folder

        Create the folder 
        """
        folderName = "My Documents"
        response = self.api.put_create_folder(folderName)
        self.assertTrue(response)

    def test_post_move_folder(self):
        """
        Test case for post_move_folder
        
        Move a specific folder
        """
        srcFolder = "moveFrom"
        destFolder = "moveTo"
            
        response = self.api.post_move_folder(srcFolder, destFolder)
        self.assertTrue(response)

    def test_delete_folder(self):
        """
        Test case for delete_folder
        
        Remove a specific folder
        """
        folderName = 'Pictures'
        response = self.api.delete_folder(folderName)
        self.assertTrue(response['Code'] == 200)

    def test_put_copy(self):
        """
        Test case for put_copy
        
        Copy a specific file
        """
        path = "testfile.txt"
        newdest = os.path.join("My Documents", "testfile.txt")
        response = self.api.put_copy(path, newdest)
        self.assertTrue(response)

    def test_put_copy_folder(self):
        """
        Test case for put_copy_folder
        
        Copy a folder
        """
        path = "Word Documents"
        newdest = os.path.join("My Documents", "Word Documents")
        response = self.api.put_copy_folder(path, newdest)
        self.assertTrue(response)

    # Storage APIs Test Cases
    def test_get_is_storage_exist(self):
        """
        Test case for get_is_storage_exist
        
        Check if storage exists
        """
        storageName = "MyDropboxStorage"
        response = self.api.get_is_storage_exist(storageName)
        self.assertTrue(response)

    def test_get_is_exist(self):
        """
        Test case for get_is_exist
        
        Check if a specific file or folder exists
        """
        response = self.api.get_is_exist('testfile.txt')
        self.assertTrue(response.file_exist.is_exist)

    def test_get_disc_usage(self):
        """
        Test case for get_disc_usage
        
        Check the disk usage of the current account
        """
        response = self.api.get_disc_usage()
        self.assertTrue(response)

    def test_get_list_file_versions(self):
        """
        Test case for get_list_file_versions
        
        Get the file's versions list
        """
        fileName = 'testfile.txt'
        response = self.api.get_list_file_versions(fileName)
        self.assertTrue(response)

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