def test_ref_with_id_only(self):
     object_id = helpers.ObjectID()
     parameters = {'#foo_template': {'?': {'id': object_id}}}
     mock_service = mock.Mock(parameters=parameters)
     context = {'?service': mock_service}
     result = yaql_functions._ref(context, 'foo_template')
     self.assertIsInstance(result, helpers.ObjectID)
     self.assertEqual(object_id, result)
Example #2
0
 def test_ref_with_evaluate_template(self):
     templates = {
         'foo_template': {
             '?': {
                 'id': helpers.ObjectID()
             }
         }
     }
     mock_service = mock.Mock(parameters={}, templates=templates)
     context = {'?service': mock_service}
     result = yaql_functions._ref(context, 'foo_template')
     self.assertIsInstance(result, helpers.ObjectID)
Example #3
0
 def test_ref(self):
     parameters = {
         '#foo_template': {
             '?': {
                 'id': None
             }
         }
     }
     mock_service = mock.Mock(parameters=parameters)
     context = {'?service': mock_service}
     result = yaql_functions._ref(context, 'foo_template')
     self.assertIsInstance(result['?']['id'], helpers.ObjectID)
Example #4
0
 def test_ref_return_none(self):
     mock_service = mock.Mock(parameters={'#foo_template': 'foo_data'})
     context = {'?service': mock_service}
     result = yaql_functions._ref(context, 'foo_template')
     self.assertIsNone(result)