Пример #1
0
  def test_wrong_field ( self ):
   
    # Make an annotation 
    makeAnno (p, 2)

    # Test the synapse type
    synapse_type = random.randint (0,100)
    f = setField(p, 'synapse_type', synapse_type)
    f = getField(p, 'synapse_type')
    assert synapse_type == int(f.read()) 

    # Test the weight
    weight = random.random ()
    f = setField(p, 'weight', weight)
    f = getField(p, 'weight')
    assert weight - float(f.read()) < 0.001

    # Test inheritance
    status = random.randint (0,100)
    f = setField(p, 'status', status)
    f = getField(p, 'status')
    assert status == int(f.read())
    
    #  bad format to a number
    url =  "http://{}/ca/{}/{}/{}/setField/status/aa/".format(SITE_HOST, 'unittest', 'unit_anno', p.annoid)
    with pytest.raises(urllib2.HTTPError): 
      req = urllib2.Request ( url )
      f = urllib2.urlopen ( url )
    
    #  request a missing field
    url =  "http://{}/ca/{}/{}/{}/getField/othernonesuch/".format(SITE_HOST, 'unittest', 'unit_anno', p.annoid)
    with pytest.raises(urllib2.HTTPError): 
      req = urllib2.Request ( url )
      f = urllib2.urlopen ( url )
Пример #2
0
  def test_seed_field (self):
    """Upload a seed and test it's fields"""

    # Make a seed
    makeAnno (p, 3)

    # Test the parent
    parent = random.randint (0,100)
    f = setField(p, 'parent', parent)
    f = getField(p, 'parent')
    assert parent == int(f.read()) 

    # Test the source
    source = random.randint (0,100)
    f = setField(p, 'source', source)
    f = getField(p, 'source')
    assert source == int(f.read()) 

    # Test the cubelocation
    cubelocation = random.randint (0,100)
    f = setField(p, 'cubelocation', cubelocation)
    f = getField(p, 'cubelocation')
    assert cubelocation == int(f.read()) 
    
    # Test the position
    position = [random.randint (0,100), random.randint(0,100), random.randint(0,100)]
    f = setField(p, 'position', ','.join([str(i) for i in position]))
    f = getField(p, 'position')
    assert ','.join([str(i) for i in position]) == f.read()
Пример #3
0
  def test_organelle_field (self):
    """Upload an organelle and test it's fields"""

    # Make an organelle 
    makeAnno ( p, 6 )

    # Test the parentseed
    parentseed = random.randint (0,100)
    f = setField(p, 'parentseed', parentseed)
    f = getField(p, 'parentseed')
    assert parentseed == int(f.read()) 

    # Test the organelleclass
    organelleclass = random.randint (0,100)
    f = setField(p, 'organelleclass', organelleclass)
    f = getField(p, 'organelleclass')
    assert organelleclass == int(f.read()) 

    # Test inheritance
    status = random.randint (0,100)
    f = setField(p, 'status', status)
    f = getField(p, 'status')
    assert status == int(f.read()) 

    # Test the seeds
    seeds = [random.randint(0,100), random.randint(0,100), random.randint(0,100)]
    f = setField(p, 'seeds', ','.join([str(i) for i in seeds]))
    f = getField(p, 'seeds')
    assert ','.join([str(i) for i in seeds]) == f.read()
Пример #4
0
  def test_segment_field (self):
    """Upload a segment and test it's fields"""

    # Make a segment
    makeAnno (p, 4)

    # Test the parentseed
    parentseed = random.randint (0,100)
    f = setField(p, 'parentseed', parentseed)
    f = getField(p, 'parentseed')
    assert parentseed == int(f.read()) 

    # Test the segmentclass
    segmentclass = random.randint (0,100)
    f = setField(p, 'segmentclass', segmentclass)
    f = getField(p, 'segmentclass')
    assert segmentclass == int(f.read()) 

    # Test the neuron
    neuron = random.randint (0,100)
    f = setField(p, 'neuron', neuron)
    f = getField(p, 'neuron')
    assert neuron == int(f.read()) 

    # Test inheritance
    status = random.randint (0,100)
    f = setField(p, 'status', status)
    f = getField(p, 'status')
    assert status == int(f.read()) 
    
    # Test the synapses
    synapses = [random.randint(0,100), random.randint(0,100), random.randint(0,100)]
    f = setField(p, 'synapses', ','.join([str(i) for i in synapses]))
    f = getField(p, 'synapses')
    assert ','.join([str(i) for i in synapses]) == f.read()
Пример #5
0
    def test_organelle_field(self):
        """Upload an organelle and test it's fields"""

        # Make an organelle
        makeAnno(p, 6)

        # Test the parentseed
        parentseed = random.randint(0, 100)
        f = setField(p, 'parentseed', parentseed)
        f = getField(p, 'parentseed')
        assert parentseed == int(f.read())

        # Test the organelleclass
        organelleclass = random.randint(0, 100)
        f = setField(p, 'organelleclass', organelleclass)
        f = getField(p, 'organelleclass')
        assert organelleclass == int(f.read())

        # Test inheritance
        status = random.randint(0, 100)
        f = setField(p, 'status', status)
        f = getField(p, 'status')
        assert status == int(f.read())

        # Test the seeds
        seeds = [
            random.randint(0, 100),
            random.randint(0, 100),
            random.randint(0, 100)
        ]
        f = setField(p, 'seeds', ','.join([str(i) for i in seeds]))
        f = getField(p, 'seeds')
        assert ','.join([str(i) for i in seeds]) == f.read()
Пример #6
0
  def test_synapse_field (self):
    """Upload a synapse and test it's fields"""

    # Make a synapse
    makeAnno (p, 2)

    # Test synapse type
    synapse_type = random.randint (0,100)
    f = setField(p, 'synapse_type', synapse_type)
    f = getField(p, 'synapse_type')
    assert synapse_type == int(f.read()) 

    # Test the weight
    weight = random.random ()
    f = setField(p, 'weight', weight)
    f = getField(p, 'weight')
    assert weight - float(f.read()) < 0.001

    # Test the inheritance
    status = random.randint (0,100)
    f = setField(p, 'status', status)
    f = getField(p, 'status')
    assert status == int(f.read()) 

    # Test the seeds
    seeds = [random.randint(0,100), random.randint(0,100), random.randint(0,100)]
    f = setField(p, 'seeds', ','.join([str(i) for i in seeds]))
    f = getField(p, 'seeds')
    assert ','.join([str(i) for i in seeds]) == f.read()
Пример #7
0
    def test_seed_field(self):
        """Upload a seed and test it's fields"""

        # Make a seed
        makeAnno(p, 3)

        # Test the parent
        parent = random.randint(0, 100)
        f = setField(p, 'parent', parent)
        f = getField(p, 'parent')
        assert parent == int(f.read())

        # Test the source
        source = random.randint(0, 100)
        f = setField(p, 'source', source)
        f = getField(p, 'source')
        assert source == int(f.read())

        # Test the cubelocation
        cubelocation = random.randint(0, 100)
        f = setField(p, 'cubelocation', cubelocation)
        f = getField(p, 'cubelocation')
        assert cubelocation == int(f.read())

        # Test the position
        position = [
            random.randint(0, 100),
            random.randint(0, 100),
            random.randint(0, 100)
        ]
        f = setField(p, 'position', ','.join([str(i) for i in position]))
        f = getField(p, 'position')
        assert ','.join([str(i) for i in position]) == f.read()
Пример #8
0
    def test_synapse_field(self):
        """Upload a synapse and test it's fields"""

        # Make a synapse
        makeAnno(p, 2)

        # Test synapse type
        synapse_type = random.randint(0, 100)
        f = setField(p, 'synapse_type', synapse_type)
        f = getField(p, 'synapse_type')
        assert synapse_type == int(f.read())

        # Test the weight
        weight = random.random()
        f = setField(p, 'weight', weight)
        f = getField(p, 'weight')
        assert weight - float(f.read()) < 0.001

        # Test the inheritance
        status = random.randint(0, 100)
        f = setField(p, 'status', status)
        f = getField(p, 'status')
        assert status == int(f.read())

        # Test the seeds
        seeds = [
            random.randint(0, 100),
            random.randint(0, 100),
            random.randint(0, 100)
        ]
        f = setField(p, 'seeds', ','.join([str(i) for i in seeds]))
        f = getField(p, 'seeds')
        assert ','.join([str(i) for i in seeds]) == f.read()
Пример #9
0
  def test_neuron_field (self):
    """Upload a neuron and test it's fields"""

    # Make a neuron
    makeAnno (p, 5)

    # Test inheritance
    status = random.randint (0,100)
    f = setField(p, 'status', status)
    f = getField(p, 'status')
    assert status == int(f.read()) 

    # Test segments
    status = [random.randint (0,100), random.randint(0,100), random.randint(0,100)]
    f = setField(p, 'segments', ",".join([str(i) for i in status]))
    f = getField(p, 'segments')
    assert ",".join([str(i) for i in status]) == f.read()
Пример #10
0
  def test_annotation_field (self):
    """Upload an annotation and test it's fields"""

    # Make an annotation 
    makeAnno (p, 1)
    
    # Test Status
    status = random.randint (0,100)
    f = setField(p, 'status', status)
    f = getField(p, 'status')
    assert status == int(f.read()) 

    # Test confidence
    confidence = random.random ()
    f = setField(p, 'confidence', confidence)
    f = getField(p, 'confidence')
    assert confidence - float(f.read()) < 0.001
Пример #11
0
    def test_annotation_field(self):
        """Upload an annotation and test it's fields"""

        # Make an annotation
        makeAnno(p, 1)

        # Test Status
        status = random.randint(0, 100)
        f = setField(p, 'status', status)
        f = getField(p, 'status')
        assert status == int(f.read())

        # Test confidence
        confidence = random.random()
        f = setField(p, 'confidence', confidence)
        f = getField(p, 'confidence')
        assert confidence - float(f.read()) < 0.001
Пример #12
0
    def test_neuron_field(self):
        """Upload a neuron and test it's fields"""

        # Make a neuron
        makeAnno(p, 5)

        # Test inheritance
        status = random.randint(0, 100)
        f = setField(p, 'status', status)
        f = getField(p, 'status')
        assert status == int(f.read())

        # Test segments
        status = [
            random.randint(0, 100),
            random.randint(0, 100),
            random.randint(0, 100)
        ]
        f = setField(p, 'segments', ",".join([str(i) for i in status]))
        f = getField(p, 'segments')
        assert ",".join([str(i) for i in status]) == f.read()
Пример #13
0
    def test_segment_field(self):
        """Upload a segment and test it's fields"""

        # Make a segment
        makeAnno(p, 4)

        # Test the parentseed
        parentseed = random.randint(0, 100)
        f = setField(p, 'parentseed', parentseed)
        f = getField(p, 'parentseed')
        assert parentseed == int(f.read())

        # Test the segmentclass
        segmentclass = random.randint(0, 100)
        f = setField(p, 'segmentclass', segmentclass)
        f = getField(p, 'segmentclass')
        assert segmentclass == int(f.read())

        # Test the neuron
        neuron = random.randint(0, 100)
        f = setField(p, 'neuron', neuron)
        f = getField(p, 'neuron')
        assert neuron == int(f.read())

        # Test inheritance
        status = random.randint(0, 100)
        f = setField(p, 'status', status)
        f = getField(p, 'status')
        assert status == int(f.read())

        # Test the synapses
        synapses = [
            random.randint(0, 100),
            random.randint(0, 100),
            random.randint(0, 100)
        ]
        f = setField(p, 'synapses', ','.join([str(i) for i in synapses]))
        f = getField(p, 'synapses')
        assert ','.join([str(i) for i in synapses]) == f.read()
Пример #14
0
    def test_wrong_field(self):

        # Make an annotation
        makeAnno(p, 2)

        # Test the synapse type
        synapse_type = random.randint(0, 100)
        f = setField(p, 'synapse_type', synapse_type)
        f = getField(p, 'synapse_type')
        assert synapse_type == int(f.read())

        # Test the weight
        weight = random.random()
        f = setField(p, 'weight', weight)
        f = getField(p, 'weight')
        assert weight - float(f.read()) < 0.001

        # Test inheritance
        status = random.randint(0, 100)
        f = setField(p, 'status', status)
        f = getField(p, 'status')
        assert status == int(f.read())

        #  bad format to a number
        url = "http://{}/ca/{}/{}/{}/setField/status/aa/".format(
            SITE_HOST, 'unittest', 'unit_anno', p.annoid)
        with pytest.raises(urllib2.HTTPError):
            req = urllib2.Request(url)
            f = urllib2.urlopen(url)

        #  request a missing field
        url = "http://{}/ca/{}/{}/{}/getField/othernonesuch/".format(
            SITE_HOST, 'unittest', 'unit_anno', p.annoid)
        with pytest.raises(urllib2.HTTPError):
            req = urllib2.Request(url)
            f = urllib2.urlopen(url)