Beispiel #1
0
  def test_complex_json(self):
    """Test the complex JSON project creation with only the required fields"""
    
    p.token = 'unittest2'
    # dataset format = (dataset_name, [ximagesz, yimagesz, zimagesz], [[xvoxel, yvoxel, zvoxel], [xoffset, yoffset, zoffset], timerange, scalinglevels, scaling)
    dataset = (p.dataset, [2000,2000,30], [1.0,1.0,5.0], [0,0,0], None, None, None)
    # project format = (project_name, token_name, public)
    project = (p.token, None, None)
    # channel format = { chan1 : (channel_name, datatype, channel_type, data_url, file_name, exceptions, resolution, windowrange, readonly), chan2: ...... }
    channels = { p.channels[1] : (p.channels[1], p.datatype, p.channel_type, 'sample_data_url', 'sample_filename', 'tif', None, None, None, None) }
    
    json_file = tempfile.NamedTemporaryFile(mode='w+b')
    json_file.write(createJson(dataset, project, channels))
    json_file.seek(0)

    # posting the JSON url and checking if it is successful
    response = json.loads(postURL("http://{}/ca/autoIngest/".format(SITE_HOST), json_file).read())
    assert('SUCCESS. The ingest process has now started.' == response)

    # fetching the JSON info
    f = getURL("http://{}/ca/{}/info/".format(SITE_HOST, p.token))

    # read the JSON file
    proj_info = json.loads(f.read())
    assert( proj_info['project']['name'] == p.token )
    assert( proj_info['dataset']['imagesize']['0'] == [2000,2000,30])
    assert( proj_info['dataset']['cube_dimension']['0'] == [128,128,16])
    assert( proj_info['dataset']['scalinglevels'] == 1)
    assert( proj_info['channels'][p.channels[1]]['resolution'] == 0)
    assert( proj_info['channels'][p.channels[1]]['datatype'] == p.datatype)
Beispiel #2
0
    def test_error_json(self):
        """Test the wrong JSON channel creation with only the required fields"""

        # Here we send incorrect dataset information

        # dataset format = (dataset_name, [ximagesz, yimagesz, zimagesz], [[xvoxel, yvoxel, zvoxel], [xoffset, yoffset, zoffset], timerange, scalinglevels, scaling)
        dataset = (p.dataset, [1000, 2000, 1000], [1.0, 1.0,
                                                   5.0], [0, 0,
                                                          0], None, None, None)
        # project format = (project_name, token_name, public)
        project = (p.token, None, None)
        # channel format = { chan1 : (channel_name, datatype, channel_type, data_url, file_name, exceptions, resolution, windowrange, readonly), chan2: ...... }
        channels = {
            p.channels[1]:
            (p.channels[1], p.datatype, p.channel_type, 'sample_data_url',
             'sample_filename', 'tif', None, None, None, None)
        }

        json_file = tempfile.NamedTemporaryFile(mode='w+b')
        json_file.write(
            createJson(dataset, project, channels, channel_only=True))
        json_file.seek(0)

        # posting the JSON url and checking if it is successful
        response = json.loads(
            postURL(
                "http://{}/ca/{}/createChannel/".format(SITE_HOST, p.token),
                json_file).read())
        assert ('FAILED' == response)
Beispiel #3
0
    def test_create_json(self):
        """Test the basic JSON project creation with only the required fields"""

        p.channels = ['CHAN1', 'CHAN2']
        # dataset format = (dataset_name, [ximagesz, yimagesz, zimagesz], [[xvoxel, yvoxel, zvoxel], [xoffset, yoffset, zoffset], timerange, scalinglevels, scaling)
        dataset = (p.dataset, [2000, 2000,
                               1000], [1.0, 1.0, 5.0], None, None, None, None)
        # project format = (project_name, token_name, public)
        project = (p.token, None, None)
        # channel format = { chan1 : (channel_name, datatype, channel_type, data_url, file_name, exceptions, resolution, windowrange, readonly), chan2: ...... }
        channels = {
            p.channels[0]:
            (p.channels[0], p.datatype, p.channel_type, 'sample_data_url',
             'sample_filename', 'tif', None, None, None, 0),
            p.channels[1]:
            (p.channels[1], p.datatype, p.channel_type, 'sample_data_url',
             'sample_filename', 'tif', None, None, None, 0),
        }

        json_file = tempfile.NamedTemporaryFile(mode='w+b')
        json_file.write(
            createJson(dataset, project, channels, channel_only=True))
        json_file.seek(0)

        # posting the JSON url and checking if it is successful
        response = json.loads(
            postURL(
                "http://{}/ca/{}/createChannel/".format(SITE_HOST, p.token),
                json_file).read())
        assert (
            'SUCCESS. The information in the channel was correct.' == response)

        # fetching the JSON info
        f = getURL("http://{}/ca/{}/info/".format(SITE_HOST, p.token))

        # read the JSON file
        proj_info = json.loads(f.read())
        assert (proj_info['project']['name'] == p.token)
        assert (proj_info['dataset']['imagesize']['0'] == [2000, 2000, 1000])
        assert (proj_info['dataset']['cube_dimension']['0'] == [128, 128, 16])
        assert (proj_info['dataset']['scalinglevels'] == 5)
        assert (proj_info['channels'][p.channels[0]]['resolution'] == 0)
        assert (proj_info['channels'][p.channels[0]]['channel_type'] ==
                p.channel_type)
        assert (proj_info['channels'][p.channels[1]]['datatype'] == p.datatype)

        # Testing if the it allows data to be posted to the created channels
        p.args = (1000, 1100, 500, 600, 200, 201)
        image_data = np.ones([2, 1, 100, 100],
                             dtype=np.uint8) * random.randint(0, 255)
        response = postNPZ(p, image_data)
        voxarray = getNPZ(p)
        assert (np.array_equal(image_data, voxarray))
Beispiel #4
0
    def test_basic_json(self):
        """Test the basic JSON project creation with only the required fields"""

        # dataset format = (dataset_name, [ximagesz, yimagesz, zimagesz], [[xvoxel, yvoxel, zvoxel], [xoffset, yoffset, zoffset], timerange, scalinglevels, scaling)
        dataset = (p.dataset, [2000, 2000, 30], [1.0, 1.0,
                                                 5.0], None, None, None, None)
        # project format = (project_name, token_name, public)
        project = (p.token, None, None)
        # channel format = { chan1 : (channel_name, datatype, channel_type, data_url, file_name, exceptions, resolution, windowrange, readonly), chan2: ...... }
        channels = {
            p.channels[0]: (p.channels[0], p.datatype, p.channel_type,
                            'http://127.0.0.1/data/sample_dir/', 'SLICE',
                            'tif', None, None, None, None)
        }
        metadata = {
            'Author': 'Will',
            'Animal': 'Mouse',
            'Date_Collected': '10/2/2015'
        }

        json_file = tempfile.NamedTemporaryFile(mode='w+b')
        json_file.write(
            createJson(dataset, project, channels, metadata=metadata))
        json_file.seek(0)

        # posting the JSON url and checking if it is successful
        response = json.loads(
            postURL("http://{}/ca/createProject/".format(SITE_HOST),
                    json_file).read())
        assert ('SUCCESS' == response)

        # fetching the JSON info
        f = getURL("http://{}/ca/{}/info/".format(SITE_HOST, p.token))

        # read the JSON file
        proj_info = json.loads(f.read())
        assert (proj_info['project']['name'] == p.token)
        assert (proj_info['dataset']['imagesize']['0'] == [2000, 2000, 30])
        assert (proj_info['dataset']['cube_dimension']['0'] == [128, 128, 16])
        assert (proj_info['dataset']['scalinglevels'] == 1)
        assert (proj_info['channels'][p.channels[0]]['resolution'] == 0)
        assert (proj_info['channels'][p.channels[0]]['datatype'] == p.datatype)
        try:
            assert (proj_info['metadata'][0]['Author'] == 'Will')
        except KeyError:
            print "LIMS System not working"
        except AssertionError:
            print "LIMS System not working"
Beispiel #5
0
  def test_error_json(self):
    """Test the wrong JSON channel creation with only the required fields"""

    # Here we send incorrect dataset information

    # dataset format = (dataset_name, [ximagesz, yimagesz, zimagesz], [[xvoxel, yvoxel, zvoxel], [xoffset, yoffset, zoffset], timerange, scalinglevels, scaling)
    dataset = (p.dataset, [1000,2000,1000], [1.0,1.0,5.0], [0,0,0], None, None, None)
    # project format = (project_name, token_name, public)
    project = (p.token, None, None)
    # channel format = { chan1 : (channel_name, datatype, channel_type, data_url, file_name, exceptions, resolution, windowrange, readonly), chan2: ...... }
    channels = { p.channels[1] : (p.channels[1], p.datatype, p.channel_type, 'sample_data_url', 'sample_filename', 'tif', None, None, None, None) }
    
    json_file = tempfile.NamedTemporaryFile(mode='w+b')
    json_file.write(createJson(dataset, project, channels, channel_only=True))
    json_file.seek(0)

    # posting the JSON url and checking if it is successful
    response = json.loads(postURL("http://{}/ca/{}/createChannel/".format(SITE_HOST, p.token), json_file).read())
    assert('Channel CHAN2 already exists for this project. Specify a different channel name' == response)
Beispiel #6
0
  def test_single_channel_json(self):
    """Test the basic JSON project creation with only the required fields"""
    
    ocp_dict = { 'channels' : (p.channels[1],) }

    json_file = tempfile.NamedTemporaryFile(mode='w+b')
    json_file.write(json.dumps(ocp_dict, sort_keys=True, indent=4))
    json_file.seek(0)

    # posting the JSON url and checking if it is successful
    response = json.loads(postURL("http://{}/ca/{}/deleteChannel/".format(SITE_HOST, p.token), json_file).read())
    assert('SUCCESS' == response)

    # fetching the JSON info
    f = getURL("http://{}/ca/{}/info/".format(SITE_HOST, p.token))

    # read the JSON file
    proj_info = json.loads(f.read())
    assert( proj_info['project']['name'] == p.token )
    assert( proj_info['channels'][p.channels[0]]['resolution'] == 0)
Beispiel #7
0
  def test_create_json(self):
    """Test the basic JSON project creation with only the required fields"""
    
    p.channels = ['CHAN1', 'CHAN2'] 
    # dataset format = (dataset_name, [ximagesz, yimagesz, zimagesz], [[xvoxel, yvoxel, zvoxel], [xoffset, yoffset, zoffset], timerange, scalinglevels, scaling)
    dataset = (p.dataset, [2000,2000,1000], [1.0,1.0,5.0], None, None, None, None)
    # project format = (project_name, token_name, public)
    project = (p.token, None, None)
    # channel format = { chan1 : (channel_name, datatype, channel_type, data_url, file_name, exceptions, resolution, windowrange, readonly), chan2: ...... }
    channels = { p.channels[0] : (p.channels[0], p.datatype, p.channel_type, 'sample_data_url', 'sample_filename', 'tif', None, None, None, 0), p.channels[1] : (p.channels[1], p.datatype, p.channel_type, 'sample_data_url', 'sample_filename', 'tif', None, None, None, 0),  }

    json_file = tempfile.NamedTemporaryFile(mode='w+b')
    json_file.write(createJson(dataset, project, channels, channel_only=True))
    json_file.seek(0)

    # posting the JSON url and checking if it is successful
    response = json.loads(postURL("http://{}/ca/{}/createChannel/".format(SITE_HOST, p.token), json_file).read())
    assert('SUCCESS. The information in the channel was correct.' == response)

    # fetching the JSON info
    f = getURL("http://{}/ca/{}/info/".format(SITE_HOST, p.token))

    # read the JSON file
    proj_info = json.loads(f.read())
    assert( proj_info['project']['name'] == p.token )
    assert( proj_info['dataset']['imagesize']['0'] == [2000,2000,1000])
    assert( proj_info['dataset']['cube_dimension']['0'] == [128,128,16])
    assert( proj_info['dataset']['scalinglevels'] == 5)
    assert( proj_info['channels'][p.channels[0]]['resolution'] == 0)
    assert( proj_info['channels'][p.channels[0]]['channel_type'] == p.channel_type)
    assert( proj_info['channels'][p.channels[1]]['datatype'] == p.datatype)
    
    # Testing if the it allows data to be posted to the created channels
    p.args = (1000,1100,500,600,200,201)
    image_data = np.ones( [2,1,100,100], dtype=np.uint8 ) * random.randint(0,255)
    response = postNPZ(p, image_data)
    voxarray = getNPZ(p)
    assert( np.array_equal(image_data, voxarray) )
Beispiel #8
0
    def test_complex_json(self):
        """Test the complex JSON project creation with only the required fields"""

        p.token = 'unittest2'
        # dataset format = (dataset_name, [ximagesz, yimagesz, zimagesz], [[xvoxel, yvoxel, zvoxel], [xoffset, yoffset, zoffset], timerange, scalinglevels, scaling)
        dataset = (p.dataset, [2000, 2000, 30], [1.0, 1.0,
                                                 5.0], [0, 0,
                                                        0], None, None, None)
        # project format = (project_name, token_name, public)
        project = (p.token, None, None)
        # channel format = { chan1 : (channel_name, datatype, channel_type, data_url, file_name, exceptions, resolution, windowrange, readonly), chan2: ...... }
        channels = {
            p.channels[1]:
            (p.channels[1], p.datatype, p.channel_type, 'sample_data_url',
             'sample_filename', 'tif', None, None, None, None)
        }

        json_file = tempfile.NamedTemporaryFile(mode='w+b')
        json_file.write(createJson(dataset, project, channels))
        json_file.seek(0)

        # posting the JSON url and checking if it is successful
        response = json.loads(
            postURL("http://{}/ca/createProject/".format(SITE_HOST),
                    json_file).read())
        assert ('SUCCESS' == response)

        # fetching the JSON info
        f = getURL("http://{}/ca/{}/info/".format(SITE_HOST, p.token))

        # read the JSON file
        proj_info = json.loads(f.read())
        assert (proj_info['project']['name'] == p.token)
        assert (proj_info['dataset']['imagesize']['0'] == [2000, 2000, 30])
        assert (proj_info['dataset']['cube_dimension']['0'] == [128, 128, 16])
        assert (proj_info['dataset']['scalinglevels'] == 1)
        assert (proj_info['channels'][p.channels[1]]['resolution'] == 0)
        assert (proj_info['channels'][p.channels[1]]['datatype'] == p.datatype)
Beispiel #9
0
    def test_single_channel_json(self):
        """Test the basic JSON project creation with only the required fields"""

        ocp_dict = {'channels': (p.channels[1], )}

        json_file = tempfile.NamedTemporaryFile(mode='w+b')
        json_file.write(json.dumps(ocp_dict, sort_keys=True, indent=4))
        json_file.seek(0)

        # posting the JSON url and checking if it is successful
        response = json.loads(
            postURL(
                "http://{}/ca/{}/deleteChannel/".format(SITE_HOST, p.token),
                json_file).read())
        assert ('SUCCESS' == response)

        # fetching the JSON info
        f = getURL("http://{}/ca/{}/info/".format(SITE_HOST, p.token))

        # read the JSON file
        proj_info = json.loads(f.read())
        assert (proj_info['project']['name'] == p.token)
        assert (proj_info['channels'][p.channels[0]]['resolution'] == 0)
Beispiel #10
0
  def test_basic_json(self):
    """Test the basic JSON project creation with only the required fields"""
    
    # dataset format = (dataset_name, [ximagesz, yimagesz, zimagesz], [[xvoxel, yvoxel, zvoxel], [xoffset, yoffset, zoffset], timerange, scalinglevels, scaling)
    dataset = (p.dataset, [2000,2000,30], [1.0,1.0,5.0], None, None, None, None)
    # project format = (project_name, token_name, public)
    project = (p.token, None, None)
    # channel format = { chan1 : (channel_name, datatype, channel_type, data_url, file_name, exceptions, resolution, windowrange, readonly), chan2: ...... }
    channels = { p.channels[0] : (p.channels[0], p.datatype, p.channel_type, 'http://127.0.0.1/data/sample_dir/', 'SLICE', 'tif', None, None, None, None) }
    metadata = { 'Author': 'Will', 'Animal':'Mouse', 'Date_Collected':'10/2/2015' }

    json_file = tempfile.NamedTemporaryFile(mode='w+b')
    json_file.write(createJson(dataset, project, channels, metadata=metadata))
    json_file.seek(0)

    # posting the JSON url and checking if it is successful
    response = json.loads(postURL("http://{}/ca/autoIngest/".format(SITE_HOST), json_file).read())
    assert('SUCCESS. The ingest process has now started.' == response)

    # fetching the JSON info
    f = getURL("http://{}/ca/{}/info/".format(SITE_HOST, p.token))

    # read the JSON file
    proj_info = json.loads(f.read())
    assert( proj_info['project']['name'] == p.token )
    assert( proj_info['dataset']['imagesize']['0'] == [2000,2000,30])
    assert( proj_info['dataset']['cube_dimension']['0'] == [128,128,16])
    assert( proj_info['dataset']['scalinglevels'] == 1)
    assert( proj_info['channels'][p.channels[0]]['resolution'] == 0)
    assert( proj_info['channels'][p.channels[0]]['datatype'] == p.datatype)
    try:
      assert( proj_info['metadata'][0]['Author'] == 'Will')
    except KeyError:
      print "LIMS System not working"
    except AssertionError:
      print "LIMS System not working"