Esempio n. 1
0
class ExportImageTest(unittest.TestCase):
    def setUp(self):
        self.comm = Comm()
        self.params = {'tree_id': '1234'}

    @patch('itolapi.comm.requests')
    def test_export_image(self, mock_requests):
        mock_requests.post().content = 'asdf'
        output = self.comm.export_image(self.params)
        self.assertEqual(output, 'asdf')
Esempio n. 2
0
class ItolExport:
    EXPORT_FORMATS = ['png', 'svg', 'eps', 'ps', 'pdf', 'nexus', 'newick']
    """
    Instantiate the itolexport class with empty params and empty server
    """

    def __init__(self):
        """
        Instantiate class
        """
        self.params = dict({})
        self.comm = Comm()

    # Setting Export Parameters
    def add_export_param_dict(self, param_dict):
        """
        Add a dictionary of parameters to the parameters to be used when
        exporting
        @param: dictionary of parameters to be used
        """
        self.params.update(param_dict)

    def set_export_param_value(self, key, value):
        """
        Add a value to the dictionary of parameters to be used when exporting
        @param: dictionary of parameters to be used
        """
        self.params[key] = value

    def get_export_params(self):
        """
        Get the dictionary of parameters to tbe used when exporting
        @return: export the Parameters
        """
        return self.params

    # Do Exporting
    def export(self, export_location):
        """
        Call the export process
        Calling this directly assumes that the export filetype is already set
        in the export params
        @param filelocation: the location to write the export to
        @return: whether the export works
        """
        output = self.comm.export_image(self.params)
        file_handle = open(export_location, 'wb')
        file_handle.write(output)
        file_handle.close()
Esempio n. 3
0
class ItolExport:
    EXPORT_FORMATS = ['png', 'svg', 'eps', 'ps', 'pdf', 'nexus', 'newick']
    """
    Instantiate the itolexport class with empty params and empty server
    """

    def __init__(self):
        """
        Instantiate class
        """
        self.params = dict({})
        self.comm = Comm()

    # Setting Export Parameters
    def add_export_param_dict(self, param_dict):
        """
        Add a dictionary of parameters to the parameters to be used when
        exporting
        @param: dictionary of parameters to be used
        """
        self.params.update(param_dict)

    def set_export_param_value(self, key, value):
        """
        Add a value to the dictionary of parameters to be used when exporting
        @param: dictionary of parameters to be used
        """
        self.params[key] = value

    def get_export_params(self):
        """
        Get the dictionary of parameters to tbe used when exporting
        @return: export the Parameters
        """
        return self.params

    # Do Exporting
    def export(self, export_location):
        """
        Call the export process
        Calling this directly assumes that the export filetype is already set
        in the export params
        @param filelocation: the location to write the export to
        @return: whether the export works
        """
        output = self.comm.export_image(self.params)
        file_handle = open(export_location, 'wb')
        file_handle.write(output)
        file_handle.close()