Exemplo n.º 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)
Exemplo n.º 2
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)
Exemplo n.º 3
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
Exemplo n.º 4
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
Exemplo n.º 5
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")
Exemplo n.º 6
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")
Exemplo n.º 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")
Exemplo n.º 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")
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 11
0
    def test_refresh_tokens(self):
        """ Test refresh token operation
        """
        local_uri = "http://localhost:{port}/".format(port=self.mock_server_port)
        ag = Agave(api_server=local_uri)
        ag.api_key = "xxx"
        ag.api_secret = "xxx"
        ag.refresh_token = "xxx"
        # See agavepy/agave.py:refresh_tokens() for more info.
        ag.created_at = str( int(time.time()) - 100 )
        ag.expires_in = str(0)

        # Refresh access token
        ag.refresh_tokens()

        assert ag.token == "access token"
        assert ag.refresh_token == "refresh token"
Exemplo n.º 12
0
    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 
Exemplo n.º 13
0
    def test_refresh_tokens(self):
        """ Test refresh token operation
        """
        local_uri = "http://localhost:{port}/".format(
            port=self.mock_server_port)
        ag = Agave(api_server=local_uri)
        ag.api_key = "xxx"
        ag.api_secret = "xxx"
        ag.refresh_token = "xxx"
        # See agavepy/agave.py:refresh_tokens() for more info.
        ag.created_at = str(int(time.time()) - 100)
        ag.expires_in = str(0)

        # Refresh access token
        ag.refresh_tokens()

        assert ag.token == "access token"
        assert ag.refresh_token == "refresh token"
Exemplo n.º 14
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 
Exemplo n.º 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)
Exemplo n.º 16
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)