storage.message: definitions, start with tests
This commit is contained in:
		
							parent
							
								
									ee5a76a808
								
							
						
					
					
						commit
						b55191dab3
					
				
					 4 changed files with 18 additions and 5 deletions
				
			
		|  | @ -52,8 +52,8 @@ class Storage(object): | |||
|         return metadata.tables.get((schema and schema + '.' or '') + tableName) | ||||
| 
 | ||||
|     def dropTable(self, tableName): | ||||
|         prefix = self.schema and self.schema + '.' or '' | ||||
|         with self.engine.begin() as conn: | ||||
|             prefix = self.schema and self.schema + '.' or '' | ||||
|             conn.execute(text('drop table if exists %s%s' % (prefix, tableName))) | ||||
| 
 | ||||
|     def resetSequence(self, tableName, colName, v): | ||||
|  | @ -63,7 +63,7 @@ class Storage(object): | |||
|             conn.execute(text(sq)) | ||||
| 
 | ||||
| 
 | ||||
| class StorageFactory(object): | ||||
| class StorageFactory: | ||||
| 
 | ||||
|     def sessionFactory(self): | ||||
|          return self.engine.connect | ||||
|  |  | |||
|  | @ -5,6 +5,7 @@ | |||
| from scopes.storage.common import registerContainerClass | ||||
| from scopes.storage.tracking import Container, Track | ||||
| 
 | ||||
| 
 | ||||
| class Message(Track): | ||||
| 
 | ||||
|     headFields = ['domain', 'action', 'class', 'item'] | ||||
|  |  | |||
|  | @ -32,6 +32,9 @@ class Test(unittest.TestCase): | |||
|     def test_004_topic(self): | ||||
|         tlib_storage.test_topic(self, config) | ||||
| 
 | ||||
|     def test_005_message(self): | ||||
|         tlib_storage.test_message(self, config) | ||||
| 
 | ||||
| def test_suite(): | ||||
|     return unittest.TestSuite(( | ||||
|         unittest.TestLoader().loadTestsFromTestCase(Test), | ||||
|  |  | |||
|  | @ -3,7 +3,7 @@ | |||
| """Test implementation for the `scopes.storage` package.""" | ||||
| 
 | ||||
| from datetime import datetime | ||||
| from scopes.storage import concept, folder, topic, tracking | ||||
| from scopes.storage import concept, folder, message, topic, tracking | ||||
| 
 | ||||
| 
 | ||||
| def test_tracking(self, config): | ||||
|  | @ -82,7 +82,7 @@ def test_type(self, config): | |||
|     concept.setupCoreTypes(storage) | ||||
|     types = storage.getContainer(concept.Type) | ||||
|     tps = list(types.query()) | ||||
|     self.assertEqual(len(tps), 6) | ||||
|     self.assertEqual(len(tps), 7) | ||||
| 
 | ||||
|     tfolder = types.queryLast(name='folder') | ||||
|     fldrs = list(tfolder.values()) | ||||
|  | @ -121,4 +121,13 @@ def test_topic(self, config): | |||
|     self.assertEqual(c[0].name, 'prog_lang') | ||||
| 
 | ||||
|     storage.commit() | ||||
|      | ||||
| 
 | ||||
| 
 | ||||
| def test_message(self, config): | ||||
|     storage = config.storageFactory(config.dbschema) | ||||
|     storage.dropTable('messages') | ||||
|     tracks = storage.create(message.Messages) | ||||
| 
 | ||||
|     storage.commit() | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue