[CORD-1525] Populating relational fields and saving models
Change-Id: Ied02e7e48efed353ae4be8ebb277aef3b6af4cab
diff --git a/test/test_tosca_parser.py b/test/test_tosca_parser.py
index 9a369fe..6c0a14c 100644
--- a/test/test_tosca_parser.py
+++ b/test/test_tosca_parser.py
@@ -21,4 +21,32 @@
res = TOSCA_Parser.get_tosca_models_by_name(FakeTemplate)
self.assertIsInstance(res['model1'], FakeNode)
- self.assertIsInstance(res['model2'], FakeNode)
\ No newline at end of file
+ self.assertIsInstance(res['model2'], FakeNode)
+
+ def test_populate_dependencies(self):
+ """
+ [TOSCA_Parser] populate_dependencies: if a recipe has dependencies, it should find the ID of the requirements and add it to the model
+ """
+ class FakeRecipe:
+ requirements = [
+ {
+ 'site': {
+ 'node': 'site_onlab',
+ 'relationship': 'tosca.relationship.BelongsToOne'
+ }
+ }
+ ]
+
+ class FakeSite:
+ id = 1
+ name = 'onlab'
+
+ class FakeModel:
+ name = 'test@opencord.org'
+
+ saved_models = {
+ 'site_onlab': FakeSite
+ }
+
+ model = TOSCA_Parser.populate_dependencies(FakeModel, FakeRecipe.requirements, saved_models)
+ self.assertEqual(model.site_id, 1)
\ No newline at end of file