work in progress: topics (as example for concepts)
This commit is contained in:
		
							parent
							
								
									20520a70c5
								
							
						
					
					
						commit
						606284791d
					
				
					 4 changed files with 107 additions and 66 deletions
				
			
		|  | @ -52,6 +52,13 @@ class Predicates(Concepts): | ||||||
|     tableName = 'preds' |     tableName = 'preds' | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | defaultPredicate = 'standard' | ||||||
|  | 
 | ||||||
|  | def storePredicate(storage, name): | ||||||
|  |     preds = storage.getContainer('pred') | ||||||
|  |     preds.save(Predicate(name)) | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| class Triple(Track): | class Triple(Track): | ||||||
| 
 | 
 | ||||||
|     headFields = ['first', 'second', 'predicate'] |     headFields = ['first', 'second', 'predicate'] | ||||||
|  | @ -76,8 +83,6 @@ class Rels(Container): | ||||||
|     tableName = 'rels' |     tableName = 'rels' | ||||||
|     insertOnChange = False |     insertOnChange = False | ||||||
| 
 | 
 | ||||||
|     defaultPredicate = 'standard' |  | ||||||
| 
 |  | ||||||
| 
 | 
 | ||||||
| # types stuff | # types stuff | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
							
								
								
									
										18
									
								
								scopes/storage/topic.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								scopes/storage/topic.py
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,18 @@ | ||||||
|  | # scopes.storage.topic | ||||||
|  | 
 | ||||||
|  | from scopes.storage.common import registerContainerClass | ||||||
|  | from scopes.storage import concept | ||||||
|  | 
 | ||||||
|  | class Topic(concept.Concept): | ||||||
|  | 
 | ||||||
|  |     prefix = 'tpc' | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | @registerContainerClass | ||||||
|  | class Topics(concept.Concepts): | ||||||
|  | 
 | ||||||
|  |     itemFactory = Topic | ||||||
|  |     tableName = 'topics' | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | @ -24,6 +24,9 @@ class Test(unittest.TestCase): | ||||||
|     def test_003_type(self): |     def test_003_type(self): | ||||||
|         tlib_storage.test_type(self, config) |         tlib_storage.test_type(self, config) | ||||||
| 
 | 
 | ||||||
|  |     def test_004_topic(self): | ||||||
|  |         tlib_storage.test_topic(self, config) | ||||||
|  | 
 | ||||||
|     def test_013_server(self): |     def test_013_server(self): | ||||||
|         tlib_server.test_app(self, config) |         tlib_server.test_app(self, config) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -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, tracking | from scopes.storage import concept, folder, topic, tracking | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def test_tracking(self, config): | def test_tracking(self, config): | ||||||
|  | @ -81,7 +81,7 @@ def test_type(self, config): | ||||||
| 
 | 
 | ||||||
|     types = storage.getContainer(concept.Type.prefix) |     types = storage.getContainer(concept.Type.prefix) | ||||||
|     tps = list(types.query()) |     tps = list(types.query()) | ||||||
|         self.assertEqual(len(tps), 5) |     self.assertEqual(len(tps), 6) | ||||||
|     self.assertEqual(tps[0].name, 'track') |     self.assertEqual(tps[0].name, 'track') | ||||||
| 
 | 
 | ||||||
|     tfolder = types.queryLast(name='folder') |     tfolder = types.queryLast(name='folder') | ||||||
|  | @ -90,3 +90,18 @@ def test_type(self, config): | ||||||
|     self.assertEqual(fldrs[0].name, 'top') |     self.assertEqual(fldrs[0].name, 'top') | ||||||
| 
 | 
 | ||||||
|     storage.commit() |     storage.commit() | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | def test_topic(self, config): | ||||||
|  |     storage = config.storageFactory(config.dbschema) | ||||||
|  |     storage.dropTable('topics') | ||||||
|  |     topics = storage.getContainer(topic.Topic.prefix) | ||||||
|  |     concept.storePredicate(storage, concept.defaultPredicate) | ||||||
|  |     root = folder.Root(storage) | ||||||
|  |     root['top']['topics'] = folder.Folder() | ||||||
|  | 
 | ||||||
|  |     tp_itc = topic.Topic('itc') | ||||||
|  |     topics.save(tp_itc) | ||||||
|  | 
 | ||||||
|  |     storage.commit() | ||||||
|  |      | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue