~verterok/ubuntuone-client/volumemanager_udfs-2

« back to all changes in this revision

Viewing changes to tests/syncdaemon/test_vm.py

  • Committer: guillermo.gonzalez at canonical
  • Date: 2010-01-11 18:19:51 UTC
  • Revision ID: guillermo.gonzalez@canonical.com-20100111181951-fwlsp53dij29d4ol
added test for VolumeManager.handle_AQ_LIST_VOLUMES_ERROR 

Show diffs side-by-side

added added

removed removed

Lines of Context:
710
710
        new_udf = self.vm.udfs[str(udf_id)]
711
711
        self.assertEquals(udf.__dict__, new_udf.__dict__)
712
712
 
 
713
    def test_handle_AQ_LIST_VOLUMES_ERROR(self):
 
714
        """Test the handling of the AQ_LIST_VOLUMES_ERROR event."""
 
715
        # patch AQ.list_volumes
 
716
        class Helper(object):
 
717
            """Helper class to keep count of the retries"""
 
718
            retries = 0
 
719
 
 
720
            def list_volumes(self):
 
721
                """Fake list_volumes"""
 
722
                self.retries += 1
 
723
 
 
724
        helper = Helper()
 
725
        self.main.action_q = helper
 
726
        self.vm.handle_AQ_LIST_VOLUMES_ERROR("ERROR!")
 
727
        self.assertEquals(self.vm.list_volumes_retries, helper.retries)
 
728
        self.vm.handle_AQ_LIST_VOLUMES_ERROR("ERROR!")
 
729
        self.assertEquals(self.vm.list_volumes_retries, helper.retries)
 
730
        # reset the retry counter
 
731
        helper.retries = 0
 
732
        response = ListVolumes(None)
 
733
        response.volumes = []
 
734
        self.vm.handle_AQ_LIST_VOLUMES(response)
 
735
        self.assertEquals(self.vm.list_volumes_retries, helper.retries)
 
736
        self.assertEquals(0, self.vm.list_volumes_retries)
 
737
 
713
738
    def test_handle_AQ_LIST_VOLUMES_unicode(self):
714
739
        """Test the handling of the AQ_LIST_VOLUMES event."""
715
740
        share_id = uuid.uuid4()
1056
1081
        share = Share.from_share_volume(share_volume, share_path)
1057
1082
        # create a UDF
1058
1083
        udf_id = uuid.uuid4()
1059
 
        udf, udf_volume = self._create_udf(udf_id, 'udf_uuid', u'~/ñoño'.encode("utf8"))
 
1084
        udf, udf_volume = self._create_udf(udf_id, 'udf_uuid',
 
1085
                                           u'~/ñoño'.encode("utf8"))
1060
1086
        self.vm.add_udf(udf)
1061
1087
        self.vm.add_share(share)
1062
1088
        # initialize the the root
1103
1129
                                                   'Shared with Me'))
1104
1130
 
1105
1131
    def tearDown(self):
1106
 
        """ cleanup main and remove the temp dir """
 
1132
        """Cleanup main and remove the temp dir."""
1107
1133
        main = getattr(self, 'main', None)
1108
1134
        if main:
1109
1135
            main.shutdown()
1112
1138
        if os.path.exists(self.data_dir):
1113
1139
            self.rmtree(self.data_dir)
1114
1140
        if os.path.exists(self.shares_dir):
1115
 
                self.rmtree(self.shares_dir)
 
1141
            self.rmtree(self.shares_dir)
1116
1142
        VolumeManager.METADATA_VERSION = CURRENT_METADATA_VERSION
1117
1143
        return BaseTwistedTestCase.tearDown(self)
1118
1144