Skip to content

Commit

Permalink
Tests for chained upgrades
Browse files Browse the repository at this point in the history
Tests that upgrade is created from the latest node.
Tests that a failed upgrade falls back to the previous upgrade.
  • Loading branch information
rexissimus committed Apr 7, 2016
1 parent fe7073c commit 21708fa
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 0 deletions.
43 changes: 43 additions & 0 deletions vistrails/gui/vistrail_controller.py
Expand Up @@ -1465,3 +1465,46 @@ def test_abstraction_execute(self):
self.assertEqual(c.execute_current_workflow()[0][0].errors, {})
api.close_current_vistrail(True)
c.unload_abstractions()

def test_chained_upgrade(self):
# We should try to upgrade from the latest upgrade in
# the upgrade chain first
from vistrails import api
view = api.open_vistrail_from_file(
vistrails.core.system.vistrails_root_directory() +
'/tests/resources/chained_upgrade.xml')
# Trigger upgrade
api.select_version('myTuple')
view.execute()
# Assert new upgrade was created from the latest action
# 1 = original
# 2 = old upgrade
# 3 = new upgrade (should be the upgrade of 2)
vistrail = api.get_current_vistrail()
for a in vistrail.action_annotations:
if a.key == Vistrail.UPGRADE_ANNOTATION:
self.assertIn(a.action_id, [1,2])
if a.action_id == 1:
self.assertEqual(int(a.value), 2)
if a.action_id == 2:
self.assertEqual(int(a.value), 3)

def test_broken_upgrade(self):
# When upgrade is broken the controller should try to upgrade
# the previous action in the upgrade chain
from vistrails import api
view = api.open_vistrail_from_file(
vistrails.core.system.vistrails_root_directory() +
'/tests/resources/broken_upgrade.xml')
# Trigger upgrade
api.select_version('myTuple')
view.execute()
# Assert new upgrade was created from the first action
# 1 = original
# 2 = broken
# 3 = new (should be the upgrade of 1)
vistrail = api.get_current_vistrail()
for a in vistrail.action_annotations:
if a.key == Vistrail.UPGRADE_ANNOTATION:
self.assertEqual(a.action_id, 1)
self.assertEqual(int(a.value), 3)
23 changes: 23 additions & 0 deletions vistrails/tests/resources/broken_upgrade.xml
@@ -0,0 +1,23 @@
<vistrail id="" name="" version="1.0.4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vistrails.org/vistrail.xsd">
<action date="2001-11-22 17:08:50" id="1" prevId="0" session="0" user="god">
<add id="0" objectId="0" parentObjId="" parentObjType="" what="module">
<module cache="1" id="0" name="Tuple" namespace="" package="edu.utah.sci.vistrails.basic" version="1.6" />
</add>
<add id="1" objectId="0" parentObjId="0" parentObjType="module" what="location">
<location id="0" x="0.0" y="0.0" />
</add>
</action>
<action date="2002-11-23 15:11:51" id="2" prevId="1" session="2" user="god">
<annotation id="0" key="__description__" value="Upgrade" />
<delete id="2" objectId="0" parentObjId="0" parentObjType="module" what="location" />
<delete id="3" objectId="0" parentObjId="" parentObjType="" what="module" />
<add id="4" objectId="1" parentObjId="" parentObjType="" what="module">
<module cache="1" id="1" name="BrokenUpgrade" namespace="" package="edu.utah.sci.vistrails.basic" version="10.0" />
</add>
<add id="5" objectId="1" parentObjId="1" parentObjType="module" what="location">
<location id="1" x="0.0" y="0.0" />
</add>
</action>
<actionAnnotation actionId="1" date="2002-09-12 14:41:53" id="0" key="__upgrade__" user="tommy" value="2" />
<actionAnnotation actionId="1" date="2002-09-12 14:42:20" id="1" key="__tag__" user="tommy" value="myTuple" />
</vistrail>
23 changes: 23 additions & 0 deletions vistrails/tests/resources/chained_upgrade.xml
@@ -0,0 +1,23 @@
<vistrail id="" name="" version="1.0.4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vistrails.org/vistrail.xsd">
<action date="2001-11-22 17:08:50" id="1" prevId="0" session="0" user="god">
<add id="0" objectId="0" parentObjId="" parentObjType="" what="module">
<module cache="1" id="0" name="Tuple" namespace="" package="edu.utah.sci.vistrails.basic" version="1.0" />
</add>
<add id="1" objectId="0" parentObjId="0" parentObjType="module" what="location">
<location id="0" x="0.0" y="0.0" />
</add>
</action>
<action date="2002-11-23 15:11:51" id="2" prevId="1" session="2" user="god">
<annotation id="0" key="__description__" value="Upgrade" />
<delete id="2" objectId="0" parentObjId="0" parentObjType="module" what="location" />
<delete id="3" objectId="0" parentObjId="" parentObjType="" what="module" />
<add id="4" objectId="1" parentObjId="" parentObjType="" what="module">
<module cache="1" id="1" name="Tuple" namespace="" package="edu.utah.sci.vistrails.basic" version="1.6" />
</add>
<add id="5" objectId="1" parentObjId="1" parentObjType="module" what="location">
<location id="1" x="0.0" y="0.0" />
</add>
</action>
<actionAnnotation actionId="1" date="2002-09-12 14:41:53" id="0" key="__upgrade__" user="tommy" value="2" />
<actionAnnotation actionId="1" date="2002-09-12 14:42:20" id="1" key="__tag__" user="tommy" value="myTuple" />
</vistrail>

0 comments on commit 21708fa

Please sign in to comment.