summaryrefslogtreecommitdiffstats
path: root/utils/test/testapi/opnfv_testapi
diff options
context:
space:
mode:
Diffstat (limited to 'utils/test/testapi/opnfv_testapi')
-rw-r--r--utils/test/testapi/opnfv_testapi/resources/scenario_models.py30
-rw-r--r--utils/test/testapi/opnfv_testapi/tests/unit/resources/scenario-c2.json4
-rw-r--r--utils/test/testapi/opnfv_testapi/tests/unit/resources/test_scenario.py5
3 files changed, 26 insertions, 13 deletions
diff --git a/utils/test/testapi/opnfv_testapi/resources/scenario_models.py b/utils/test/testapi/opnfv_testapi/resources/scenario_models.py
index 7d0770759..ec262aa2f 100644
--- a/utils/test/testapi/opnfv_testapi/resources/scenario_models.py
+++ b/utils/test/testapi/opnfv_testapi/resources/scenario_models.py
@@ -16,6 +16,13 @@ class ScenarioTI(models.ModelBase):
self.date = date
self.status = status
+ def __eq__(self, other):
+ return (self.date == other.date and
+ self.status == other.status)
+
+ def __ne__(self, other):
+ return not self.__eq__(other)
+
@swagger.model()
class ScenarioScore(models.ModelBase):
@@ -23,6 +30,13 @@ class ScenarioScore(models.ModelBase):
self.date = date
self.score = score
+ def __eq__(self, other):
+ return (self.date == other.date and
+ self.score == other.score)
+
+ def __ne__(self, other):
+ return not self.__eq__(other)
+
@swagger.model()
class ScenarioProject(models.ModelBase):
@@ -50,10 +64,10 @@ class ScenarioProject(models.ModelBase):
'trust_indicators': ScenarioTI}
def __eq__(self, other):
- return [self.project == other.project and
+ return (self.project == other.project and
self._customs_eq(other) and
self._scores_eq(other) and
- self._ti_eq(other)]
+ self._ti_eq(other))
def __ne__(self, other):
return not self.__eq__(other)
@@ -62,10 +76,10 @@ class ScenarioProject(models.ModelBase):
return set(self.customs) == set(other.customs)
def _scores_eq(self, other):
- return set(self.scores) == set(other.scores)
+ return self.scores == other.scores
def _ti_eq(self, other):
- return set(self.trust_indicators) == set(other.trust_indicators)
+ return self.trust_indicators == other.trust_indicators
@swagger.model()
@@ -84,9 +98,9 @@ class ScenarioVersion(models.ModelBase):
return {'projects': ScenarioProject}
def __eq__(self, other):
- return [self.version == other.version and
+ return (self.version == other.version and
self.owner == other.owner and
- self._projects_eq(other)]
+ self._projects_eq(other))
def __ne__(self, other):
return not self.__eq__(other)
@@ -116,7 +130,7 @@ class ScenarioInstaller(models.ModelBase):
return {'versions': ScenarioVersion}
def __eq__(self, other):
- return [self.installer == other.installer and self._versions_eq(other)]
+ return (self.installer == other.installer and self._versions_eq(other))
def __ne__(self, other):
return not self.__eq__(other)
@@ -166,7 +180,7 @@ class Scenario(models.ModelBase):
return not self.__eq__(other)
def __eq__(self, other):
- return [self.name == other.name and self._installers_eq(other)]
+ return (self.name == other.name and self._installers_eq(other))
def _installers_eq(self, other):
for s_install in self.installers:
diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/resources/scenario-c2.json b/utils/test/testapi/opnfv_testapi/tests/unit/resources/scenario-c2.json
index b6a3b83ab..980051c4f 100644
--- a/utils/test/testapi/opnfv_testapi/tests/unit/resources/scenario-c2.json
+++ b/utils/test/testapi/opnfv_testapi/tests/unit/resources/scenario-c2.json
@@ -8,7 +8,7 @@
[
{
"owner": "Lucky",
- "version": "colorado",
+ "version": "danube",
"projects":
[
{
@@ -29,7 +29,7 @@
"scores": [
{
"date": "2017-01-08 22:46:44",
- "score": "0"
+ "score": "0/1"
}
],
"trust_indicators": [
diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_scenario.py b/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_scenario.py
index 466caaf13..f9bb58c6b 100644
--- a/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_scenario.py
+++ b/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_scenario.py
@@ -47,8 +47,7 @@ class TestScenarioBase(base.TestBase):
req = self.req_d
self.assertIsNotNone(scenario._id)
self.assertIsNotNone(scenario.creation_date)
-
- scenario == models.Scenario.from_dict(req)
+ self.assertEqual(scenario, models.Scenario.from_dict(req))
@staticmethod
def _set_query(*args):
@@ -298,7 +297,7 @@ class TestScenarioUpdate(TestScenarioBase):
@update_partial('_update', '_success')
def test_changeOwner(self, scenario):
new_owner = 'new_owner'
- scenario['installers'][0]['versions'][0]['owner'] = 'www'
+ scenario['installers'][0]['versions'][0]['owner'] = new_owner
return new_owner, scenario
def _add(self, update_req, new_scenario):