コード例 #1
0
    def test_files_download(self):
        """ Test file copying from a remote to the local system
        """
        # Create a "remote" dummy file.
        tmp_file = self.create_remote_dummy_file()

        # Destination of downloaded file.
        local_file = "testfile.txt"

        try:
            local_uri = "http://localhost:{port}/".format(
                port=self.mock_server_port)
            agave = Agave(api_server=local_uri)
            agave.token = "mock-access-token"
            agave.created_at = str(int(time.time()))
            agave.expires_in = str(14400)

            agave.files_download("tacc-globalfs-user/" + tmp_file, local_file)
        finally:
            assert filecmp.cmp(tmp_file, local_file)

            # rm local file.
            if os.path.exists(local_file):
                os.remove(local_file)
            # rm dummy file in current working directory.
            if os.path.exists(tmp_file):
                os.remove(tmp_file)
コード例 #2
0
ファイル: files_test.py プロジェクト: TACC/agavepy
    def test_files_download(self):
        """ Test file copying from a remote to the local system
        """
        # Create a "remote" dummy file.
        tmp_file = self.create_remote_dummy_file()

        # Destination of downloaded file.
        local_file = "testfile.txt"

        try:
            local_uri = "http://localhost:{port}/".format(port=self.mock_server_port)
            agave = Agave(api_server=local_uri)
            agave.token = "mock-access-token"
            agave.created_at = str(int(time.time()))
            agave.expires_in = str(14400)

            agave.files_download("tacc-globalfs-user/"+tmp_file, local_file)
        finally:
            assert filecmp.cmp(tmp_file, local_file)

            # rm local file.
            if os.path.exists(local_file):
                os.remove(local_file)
            # rm dummy file in current working directory.
            if os.path.exists(tmp_file):
                os.remove(tmp_file)
コード例 #3
0
ファイル: files-pems_test.py プロジェクト: TACC/agavepy
    def test_files_pems_delete(self, capfd):
        """ Test permissions deletion
        """
        local_uri = "http://localhost:{port}/".format(port=self.mock_server_port)
        agave = Agave(api_server=local_uri)
        agave.token = "mock-access-token"
        agave.created_at = str(int(time.time()))
        agave.expires_in = str(14400)

        # Delete permissions.
        agave.files_pems_delete("tacc-globalfs-username/")
        out, err = capfd.readouterr()
        assert "200" in err
コード例 #4
0
ファイル: files_test.py プロジェクト: TACC/agavepy
    def test_files_import(self, capfd):
        """ Test files import
        """
        local_uri = "http://localhost:{port}/".format(port=self.mock_server_port)
        agave = Agave(api_server=local_uri)
        agave.token = "mock-access-token"
        agave.created_at = str(int(time.time()))
        agave.expires_in = str(14400)

        # Import file.
        agave.files_import("agave://data-sd2e-community/test.txt", "tacc-globalfs-username/")
        out, err = capfd.readouterr()
        assert "200" in err
コード例 #5
0
ファイル: files_test.py プロジェクト: TACC/agavepy
    def test_files_mkdir(self):
        """ test files mkdir method

        The call to files_mkdir has no side effects on the host so the function
        call should simply be able to return successfully.
        """
        local_uri = "http://localhost:{port}/".format(port=self.mock_server_port)
        agave = Agave(api_server=local_uri)
        agave.token = "mock-access-token"
        agave.created_at = str(int(time.time()))
        agave.expires_in = str(14400)

        agave.files_mkdir("tacc-globalfs/new/path")
コード例 #6
0
ファイル: files_test.py プロジェクト: TACC/agavepy
    def test_files_copy(self):
        """ test files copying from remote to remote

        The call to files_copy has no side effects on the host so the function
        call should simply be able to return successfully.
        """
        local_uri = "http://localhost:{port}/".format(port=self.mock_server_port)
        agave = Agave(api_server=local_uri)
        agave.token = "mock-access-token"
        agave.created_at = str(int(time.time()))
        agave.expires_in = str(14400)
        
        agave.files_copy("tacc-globalfs/file", "tacc-globalfs/file-copy")
コード例 #7
0
    def test_files_mkdir(self):
        """ test files mkdir method

        The call to files_mkdir has no side effects on the host so the function
        call should simply be able to return successfully.
        """
        local_uri = "http://localhost:{port}/".format(
            port=self.mock_server_port)
        agave = Agave(api_server=local_uri)
        agave.token = "mock-access-token"
        agave.created_at = str(int(time.time()))
        agave.expires_in = str(14400)

        agave.files_mkdir("tacc-globalfs/new/path")
コード例 #8
0
    def test_files_copy(self):
        """ test files copying from remote to remote

        The call to files_copy has no side effects on the host so the function
        call should simply be able to return successfully.
        """
        local_uri = "http://localhost:{port}/".format(
            port=self.mock_server_port)
        agave = Agave(api_server=local_uri)
        agave.token = "mock-access-token"
        agave.created_at = str(int(time.time()))
        agave.expires_in = str(14400)

        agave.files_copy("tacc-globalfs/file", "tacc-globalfs/file-copy")
コード例 #9
0
    def test_files_pems_delete(self, capfd):
        """ Test permissions deletion
        """
        local_uri = "http://localhost:{port}/".format(
            port=self.mock_server_port)
        agave = Agave(api_server=local_uri)
        agave.token = "mock-access-token"
        agave.created_at = str(int(time.time()))
        agave.expires_in = str(14400)

        # Delete permissions.
        agave.files_pems_delete("tacc-globalfs-username/")
        out, err = capfd.readouterr()
        assert "200" in err
コード例 #10
0
    def test_files_import(self, capfd):
        """ Test files import
        """
        local_uri = "http://localhost:{port}/".format(
            port=self.mock_server_port)
        agave = Agave(api_server=local_uri)
        agave.token = "mock-access-token"
        agave.created_at = str(int(time.time()))
        agave.expires_in = str(14400)

        # Import file.
        agave.files_import("agave://data-sd2e-community/test.txt",
                           "tacc-globalfs-username/")
        out, err = capfd.readouterr()
        assert "200" in err
コード例 #11
0
    def test_files_list(self, capfd):
        """ Test files listings
        """
        local_uri = "http://localhost:{port}/".format(port=self.mock_server_port)
        agave = Agave(api_server=local_uri)
        agave.token = "mock-access-token"

        # List files.
        agave.files_list("tacc-globalfs-username/tests", long_format=False)

        # Stdout should contain the putput from the command.
        # Stderr will contain logs from the mock http server.
        out, err = capfd.readouterr()
        assert "copy.txt" in out
        assert "sp1-copy.fq" in out
        assert "upload.txt" in out
        assert "\"GET //files/v2/listings/system/tacc-globalfs-username/tests?pretty=true HTTP/1.1\" 200" in err 
コード例 #12
0
ファイル: files-pems_test.py プロジェクト: TACC/agavepy
    def test_files_pems_list(self, capfd):
        """ Test permissions listings
        """
        local_uri = "http://localhost:{port}/".format(port=self.mock_server_port)
        agave = Agave(api_server=local_uri)
        agave.token = "mock-access-token"
        agave.created_at = str(int(time.time()))
        agave.expires_in = str(14400)

        # List permissions.
        agave.files_pems_list("tacc-globalfs-username/")

        # Stdout should contain the putput from the command.
        # Stderr will contain logs from the mock http server.
        out, err = capfd.readouterr()
        assert "username" in out
        assert "yes" in out
        assert "200" in err 
コード例 #13
0
    def test_files_history(self, capfd):
        """ Test history
        """
        local_uri = "http://localhost:{port}/".format(port=self.mock_server_port)
        agave = Agave(api_server=local_uri)
        agave.token = "mock-access-token"
        agave.created_at = str(int(time.time()))
        agave.expires_in = str(14400)

        # List permissions.
        agave.files_history("tacc-globalfs-username/")

        # Stdout should contain the putput from the command.
        # Stderr will contain logs from the mock http server.
        out, err = capfd.readouterr()
        assert "username" in out
        assert "CREATED" in out
        assert "PERMISSION_REVOKE" in out
        assert "200" in err 
コード例 #14
0
ファイル: files_test.py プロジェクト: TACC/agavepy
    def test_files_upload(self):
        """ Test file uload to remote systems
        """
        # Create a local dummy file.
        tmp_file = self.create_local_dummy_file()

        try:
            local_uri = "http://localhost:{port}/".format(port=self.mock_server_port)
            agave = Agave(api_server=local_uri)
            agave.token = "mock-access-token"
            agave.created_at = str(int(time.time()))
            agave.expires_in = str(14400)

            agave.files_upload(tmp_file, "tacc-globalfs-user/")
        finally:
            _, tmp_filename = os.path.split(tmp_file)
            assert filecmp.cmp(tmp_file, tmp_filename)

            # rm dummy file.
            os.remove(tmp_file)
            # rm dummy file in current working directory.
            if os.path.exists(tmp_filename):
                os.remove(tmp_filename)
コード例 #15
0
    def test_files_upload(self):
        """ Test file uload to remote systems
        """
        # Create a local dummy file.
        tmp_file = self.create_local_dummy_file()

        try:
            local_uri = "http://localhost:{port}/".format(
                port=self.mock_server_port)
            agave = Agave(api_server=local_uri)
            agave.token = "mock-access-token"
            agave.created_at = str(int(time.time()))
            agave.expires_in = str(14400)

            agave.files_upload(tmp_file, "tacc-globalfs-user/")
        finally:
            _, tmp_filename = os.path.split(tmp_file)
            assert filecmp.cmp(tmp_file, tmp_filename)

            # rm dummy file.
            os.remove(tmp_file)
            # rm dummy file in current working directory.
            if os.path.exists(tmp_filename):
                os.remove(tmp_filename)