Back to index

python-biopython  1.60
Public Member Functions | Public Attributes
test_BioSQL.DupLoadTest Class Reference

List of all members.

Public Member Functions

def setUp
def tearDown
def test_duplicate_load
def test_duplicate_load2
def test_duplicate_id_load

Public Attributes

 server
 db

Detailed Description

Check a few duplicate conditions fail.

Definition at line 392 of file test_BioSQL.py.


Member Function Documentation

Definition at line 394 of file test_BioSQL.py.

00394 
00395     def setUp(self):
00396         #drop any old database and create a new one:
00397         create_database()
00398         #connect to new database:
00399         self.server = BioSeqDatabase.open_database(driver = DBDRIVER,
00400                                               user = DBUSER, passwd = DBPASSWD,
00401                                               host = DBHOST, db = TESTDB)
00402         #Create new namespace within new empty database:
00403         self.db = self.server.new_database("biosql-test")

Here is the call graph for this function:

Definition at line 404 of file test_BioSQL.py.

00404 
00405     def tearDown(self):
00406         self.server.rollback()
00407         self.server.close()
00408         del self.db
00409         del self.server

Make sure can't import records with same ID (in one go).

Definition at line 438 of file test_BioSQL.py.

00438 
00439     def test_duplicate_id_load(self):
00440         """Make sure can't import records with same ID (in one go)."""
00441         record1 = SeqRecord(Seq("ATGCTATGACTAT", Alphabet.generic_dna),id="TestA")
00442         record2 = SeqRecord(Seq("GGGATGCGACTAT", Alphabet.generic_dna),id="TestA")
00443         try:
00444             count = self.db.load([record1,record2])
00445         except Exception, err:
00446             #Good!
00447             self.assertEqual("IntegrityError", err.__class__.__name__)
00448             return
00449         raise Exception("Should have failed! Loaded %i records" % count)

Make sure can't import a single record twice (in one go).

Definition at line 410 of file test_BioSQL.py.

00410 
00411     def test_duplicate_load(self):
00412         """Make sure can't import a single record twice (in one go)."""
00413         record = SeqRecord(Seq("ATGCTATGACTAT", Alphabet.generic_dna),id="Test1")
00414         try:
00415             count = self.db.load([record,record])
00416         except Exception, err:
00417             #Good!
00418             #Note we don't do a specific exception handler because the
00419             #exception class will depend on which DB back end is in use.            
00420             self.assertTrue(err.__class__.__name__ in ["IntegrityError",
00421                                                        "OperationalError"],
00422                             err.__class__.__name__)
00423             return
00424         raise Exception("Should have failed! Loaded %i records" % count)

Make sure can't import a single record twice (in steps).

Definition at line 425 of file test_BioSQL.py.

00425 
00426     def test_duplicate_load2(self):
00427         """Make sure can't import a single record twice (in steps)."""
00428         record = SeqRecord(Seq("ATGCTATGACTAT", Alphabet.generic_dna),id="Test2")
00429         count = self.db.load([record])
00430         self.assertEqual(count,1)
00431         try:
00432             count = self.db.load([record])
00433         except Exception, err:
00434             #Good!
00435             self.assertEqual("IntegrityError", err.__class__.__name__)
00436             return
00437         raise Exception("Should have failed! Loaded %i records" % count)


Member Data Documentation

Definition at line 402 of file test_BioSQL.py.

Definition at line 398 of file test_BioSQL.py.


The documentation for this class was generated from the following file: