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) |         return metadata.tables.get((schema and schema + '.' or '') + tableName) | ||||||
| 
 | 
 | ||||||
|     def dropTable(self, tableName): |     def dropTable(self, tableName): | ||||||
|  |         prefix = self.schema and self.schema + '.' or '' | ||||||
|         with self.engine.begin() as conn: |         with self.engine.begin() as conn: | ||||||
|             prefix = self.schema and self.schema + '.' or '' |  | ||||||
|             conn.execute(text('drop table if exists %s%s' % (prefix, tableName))) |             conn.execute(text('drop table if exists %s%s' % (prefix, tableName))) | ||||||
| 
 | 
 | ||||||
|     def resetSequence(self, tableName, colName, v): |     def resetSequence(self, tableName, colName, v): | ||||||
|  | @ -63,7 +63,7 @@ class Storage(object): | ||||||
|             conn.execute(text(sq)) |             conn.execute(text(sq)) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class StorageFactory(object): | class StorageFactory: | ||||||
| 
 | 
 | ||||||
|     def sessionFactory(self): |     def sessionFactory(self): | ||||||
|          return self.engine.connect |          return self.engine.connect | ||||||
|  |  | ||||||
|  | @ -5,6 +5,7 @@ | ||||||
| from scopes.storage.common import registerContainerClass | from scopes.storage.common import registerContainerClass | ||||||
| from scopes.storage.tracking import Container, Track | from scopes.storage.tracking import Container, Track | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| class Message(Track): | class Message(Track): | ||||||
| 
 | 
 | ||||||
|     headFields = ['domain', 'action', 'class', 'item'] |     headFields = ['domain', 'action', 'class', 'item'] | ||||||
|  |  | ||||||
|  | @ -32,6 +32,9 @@ class Test(unittest.TestCase): | ||||||
|     def test_004_topic(self): |     def test_004_topic(self): | ||||||
|         tlib_storage.test_topic(self, config) |         tlib_storage.test_topic(self, config) | ||||||
| 
 | 
 | ||||||
|  |     def test_005_message(self): | ||||||
|  |         tlib_storage.test_message(self, config) | ||||||
|  | 
 | ||||||
| def test_suite(): | def test_suite(): | ||||||
|     return unittest.TestSuite(( |     return unittest.TestSuite(( | ||||||
|         unittest.TestLoader().loadTestsFromTestCase(Test), |         unittest.TestLoader().loadTestsFromTestCase(Test), | ||||||
|  |  | ||||||
|  | @ -3,7 +3,7 @@ | ||||||
| """Test implementation for the `scopes.storage` package.""" | """Test implementation for the `scopes.storage` package.""" | ||||||
| 
 | 
 | ||||||
| from datetime import datetime | 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): | def test_tracking(self, config): | ||||||
|  | @ -82,7 +82,7 @@ def test_type(self, config): | ||||||
|     concept.setupCoreTypes(storage) |     concept.setupCoreTypes(storage) | ||||||
|     types = storage.getContainer(concept.Type) |     types = storage.getContainer(concept.Type) | ||||||
|     tps = list(types.query()) |     tps = list(types.query()) | ||||||
|     self.assertEqual(len(tps), 6) |     self.assertEqual(len(tps), 7) | ||||||
| 
 | 
 | ||||||
|     tfolder = types.queryLast(name='folder') |     tfolder = types.queryLast(name='folder') | ||||||
|     fldrs = list(tfolder.values()) |     fldrs = list(tfolder.values()) | ||||||
|  | @ -122,3 +122,12 @@ def test_topic(self, config): | ||||||
| 
 | 
 | ||||||
|     storage.commit() |     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