grease
grease copied to clipboard
AutomationTest Support Multiple Mocked Sources
AutomationTest Support Multiple Mocked Sources
USE THIS TEMPLATE FOR YOUR ISSUE!
- Primary Contact: Ronald Queensen
- Team: Target/Core
Abstract
When wanting to mock multiple sources (EX: Multiple URL's in a URL prototype config) the tests fail
Supporting Elements
Given This Config
{
"name": "demo_1",
"source": "url_source",
"job": "demo",
"exe_env": "general",
"url": ["http://localhost:8000", "google.com"],
"logic": {
"Regex": [
{
"field": "url",
"pattern": ".*",
"variable": true,
"variable_name": "url"
}
],
"Range": [
{
"field": "status_code",
"min": 199,
"max": 201
}
]
}
}
And this Test
from tgt_grease.core.Types import AutomationTest
from tgt_grease.core import Configuration
from example_package.Commands import demo
class TestDemo1(AutomationTest):
def __init__(self, *args, **kwargs):
AutomationTest.__init__(self, *args, **kwargs)
self.configuration = "fs://{0}".format(Configuration.greaseDir + 'etc/basic.config.json')
self.mock_data = {
'url': 'localhost:8000',
'status_code': 200
}
self.expected_data = {
'url': ['localhost:8000', '']
}
self.enabled = True
def test_command(self):
d = demo()
self.assertTrue(d.execute({}))
The test fails
Issue Checklist
- [ ] Maintainer has viewed
- [ ] Loaded into Backlog
- [ ] PR Submitted [Link Here](Eventual Link)