diff options
author | Stuart Mackie <wsmackie@juniper.net> | 2016-01-29 16:00:57 -0800 |
---|---|---|
committer | Stuart Mackie <wsmackie@juniper.net> | 2016-01-29 16:00:57 -0800 |
commit | 82f1a7eb5535b30a95b1e71ff18c315d40d1e6f0 (patch) | |
tree | f930c90f75846ec8d8e33cf27325ff8fafc85d5c /Testcases/vnc_api/gen/cfixture.py | |
parent | 5c04f2e22eb6b5e7a671bc02ba53a438eb66e90d (diff) |
OpenContrail test suitestable/colorado
Change-Id: I61168093a2a05d47377ef47c8638ae1554b1a999
Signed-off-by: Stuart Mackie <wsmackie@juniper.net>
Diffstat (limited to 'Testcases/vnc_api/gen/cfixture.py')
-rw-r--r-- | Testcases/vnc_api/gen/cfixture.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/Testcases/vnc_api/gen/cfixture.py b/Testcases/vnc_api/gen/cfixture.py new file mode 100644 index 0000000..6e31f2a --- /dev/null +++ b/Testcases/vnc_api/gen/cfixture.py @@ -0,0 +1,46 @@ +# +# Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. +# +import fixtures + + +class ConrtailLink (object): + + def __init__(self, name, _from, _to, _type, fixtr): + self._type = _type + self._fixture = fixtr + self._from = _from + self._to = _to + self._name = name + + def fixture(self): + return self._fixture + + +class ContrailFixture (fixtures.Fixture): + + def __init__(self): + self._pdetails = {} + + def _get_link_dict(self): + if '__links__' not in self._pdetails: + self._pdetails['__links__'] = {} + return self._pdetails['__links__'] + + def _update_link_dict(self, lname): + self._pdetails['__links__'][lname] = [] + + def links(self): + return self._get_link_dict().keys() + + def get_links(self, lname): + return self._get_link_dict().get(lname, []) + + def add_link(self, lname, link): + if not self.get_links(lname): + self._update_link_dict(lname) + + return self.get_links(lname).append(link) + + def get_link_fixtures(self, lname): + return map(lambda l: l.fixture(), self.get_links(lname)) |