Esempio n. 1
0
 def testAddOneReference(self):
     self.assertEqual(self._referenceSet.getNumReferences(), 0)
     referenceName = "ref"
     reference = references.AbstractReference(self._referenceSet,
                                              referenceName)
     self._referenceSet.addReference(reference)
     self.assertEqual(self._referenceSet.getNumReferences(), 1)
     self.assertEqual(self._referenceSet.getReferenceByIndex(0), reference)
     self.assertEqual(self._referenceSet.getReferenceByName(referenceName),
                      reference)
     self.assertEqual(self._referenceSet.getReference(reference.getId()),
                      reference)
     self.assertEqual(self._referenceSet.getReferences(), [reference])
Esempio n. 2
0
 def testListReferenceBasesErrors(self):
     referenceSet = self.backend.getReferenceSets()[0]
     for badId in self.getBadIds():
         path = '/references/{}/bases'.format(badId)
         response = self.app.get(path)
         self.assertEqual(response.status_code, 404)
         reference = references.AbstractReference(referenceSet, badId)
         path = '/references/{}/bases'.format(reference.getId())
         response = self.app.get(path)
         self.assertEqual(response.status_code, 404)
     reference = referenceSet.getReferences()[0]
     path = '/references/{}/bases'.format(reference.getId())
     length = reference.getLength()
     badRanges = [(-1, 0), (-1, -1), (length, 0), (0, length + 1)]
     for start, end in badRanges:
         args = protocol.ListReferenceBasesRequest()
         args.start, args.end = start, end
         response = self.app.get(path, query_string=args.toJsonDict())
         self.assertEqual(response.status_code, 416)
Esempio n. 3
0
    def testAddMultipleReference(self):
        referenceList = []
        referenceBaseName = "ref"
        referenceCount = 10

        self.assertEqual(self._referenceSet.getNumReferences(), 0)

        for i in range(referenceCount):
            referenceName = referenceBaseName + str(i)
            reference = references.AbstractReference(self._referenceSet,
                                                     referenceName)
            referenceList.append(reference)
            self._referenceSet.addReference(reference)
            self.assertEqual(self._referenceSet.getNumReferences(), i + 1)
            self.assertEqual(self._referenceSet.getReferenceByIndex(i),
                             reference)
            self.assertEqual(
                self._referenceSet.getReferenceByName(referenceName),
                reference)
            self.assertEqual(
                self._referenceSet.getReference(reference.getId()), reference)
            self.assertEqual(self._referenceSet.getReferences(), referenceList)
Esempio n. 4
0
 def setUp(self):
     self._backend = backend.Backend(datarepo.AbstractDataRepository())
     self._referenceSet = references.AbstractReferenceSet(self._backend)
     self._reference = references.AbstractReference(self._referenceSet,
                                                    "ref")
Esempio n. 5
0
 def _addReference(self, referenceName):
     reference = references.AbstractReference(self._referenceSet,
                                              referenceName)
     self._referenceSet.addReference(reference)
Esempio n. 6
0
 def setUp(self):
     self._backend = backend.AbstractBackend()
     self._referenceSet = references.AbstractReferenceSet(self._backend)
     self._reference = references.AbstractReference(self._referenceSet,
                                                    "ref")