~aaron-whitehouse/duplicity/08-unadorned-strings

« back to all changes in this revision

Viewing changes to testing/functional/test_verify.py

  • Committer: kenneth at loafman
  • Date: 2017-12-03 16:14:27 UTC
  • mfrom: (1189.1.37 08-unicode-select)
  • Revision ID: kenneth@loafman.com-20171203161427-cpsccbctsti9gy6l
* Merged in lp:~aaron-whitehouse/duplicity/08-unicode
  - Many strings have been changed to unicode for better handling of international
    characters and to make the transition to Python 3 significantly easier, primarily
    on the 'local' side of duplicity (selection, commandline arguments etc) rather
    than any backends etc.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
    """
33
33
    def test_verify(self):
34
34
        """Test that verify (without --compare-data) works in the basic case"""
35
 
        self.backup("full", "testfiles/various_file_types", options=[])
36
 
        self.verify('testfiles/various_file_types/executable', file_to_verify='executable', options=[])
 
35
        self.backup(u"full", u"testfiles/various_file_types", options=[])
 
36
        self.verify(u'testfiles/various_file_types/executable', file_to_verify=u'executable', options=[])
37
37
 
38
38
    def test_verify_changed_source_file(self):
39
39
        """Test verify (without --compare-data) gives no error if a source file is changed"""
40
40
        # This test was made to pass in fixing Bug #1354880
41
 
        self.backup("full", "testfiles/various_file_types", options=[])
 
41
        self.backup(u"full", u"testfiles/various_file_types", options=[])
42
42
 
43
43
        # Edit source file
44
44
        with open('testfiles/various_file_types/executable', 'r+') as f:
45
45
            f.write('This changes a source file.')
46
46
 
47
47
        # Test verify for the file
48
 
        self.verify('testfiles/various_file_types/executable', file_to_verify='executable', options=[])
 
48
        self.verify(u'testfiles/various_file_types/executable', file_to_verify=u'executable', options=[])
49
49
 
50
50
    def test_verify_changed_source_file_adjust_mtime(self):
51
51
        """Test verify (without --compare-data) gives no error if a source file is changed and the mtime is changed
58
58
        # the times from a stat call don't match what a utime will set.
59
59
        os.utime('testfiles/various_file_types/executable', (file_info.st_atime, file_info.st_mtime))
60
60
 
61
 
        self.backup("full", "testfiles/various_file_types", options=[])
 
61
        self.backup(u"full", u"testfiles/various_file_types", options=[])
62
62
 
63
63
        # Edit source file
64
64
        with open('testfiles/various_file_types/executable', 'r+') as f:
68
68
        os.utime('testfiles/various_file_types/executable', (file_info.st_atime, file_info.st_mtime))
69
69
 
70
70
        # Test verify for the file
71
 
        self.verify('testfiles/various_file_types/executable', file_to_verify='executable', options=[])
 
71
        self.verify(u'testfiles/various_file_types/executable', file_to_verify=u'executable', options=[])
72
72
 
73
73
    def test_verify_compare_data(self):
74
74
        """Test that verify works in the basic case when the --compare-data option is used"""
75
 
        self.backup("full", "testfiles/various_file_types", options=[])
 
75
        self.backup(u"full", u"testfiles/various_file_types", options=[])
76
76
 
77
77
        # Test verify for the file with --compare-data
78
 
        self.verify('testfiles/various_file_types/executable', file_to_verify='executable',
79
 
                    options=["--compare-data"])
 
78
        self.verify(u'testfiles/various_file_types/executable', file_to_verify=u'executable',
 
79
                    options=[u"--compare-data"])
80
80
 
81
81
    def test_verify_compare_data_changed_source_file(self):
82
82
        """Test verify with --compare-data gives an error if a source file is changed"""
83
 
        self.backup("full", "testfiles/various_file_types", options=[])
 
83
        self.backup(u"full", u"testfiles/various_file_types", options=[])
84
84
 
85
85
        # Edit source file
86
86
        with open('testfiles/various_file_types/executable', 'r+') as f:
88
88
 
89
89
        # Test verify for edited file fails with --compare-data
90
90
        try:
91
 
            self.verify('testfiles/various_file_types/executable', file_to_verify='executable',
92
 
                        options=["--compare-data"])
 
91
            self.verify(u'testfiles/various_file_types/executable', file_to_verify=u'executable',
 
92
                        options=[u"--compare-data"])
93
93
        except CmdError as e:
94
94
            self.assertEqual(e.exit_status, 1, str(e))
95
95
        else:
105
105
        # the times from a stat call don't match what a utime will set
106
106
        os.utime('testfiles/various_file_types/executable', (file_info.st_atime, file_info.st_mtime))
107
107
 
108
 
        self.backup("full", "testfiles/various_file_types", options=[])
 
108
        self.backup(u"full", u"testfiles/various_file_types", options=[])
109
109
        # Edit source file
110
110
        with open('testfiles/various_file_types/executable', 'r+') as f:
111
111
            f.write('This changes a source file.')
115
115
 
116
116
        # Test verify for edited file fails with --compare-data
117
117
        try:
118
 
            self.verify('testfiles/various_file_types/executable', file_to_verify='executable',
119
 
                        options=["--compare-data"])
 
118
            self.verify(u'testfiles/various_file_types/executable', file_to_verify=u'executable',
 
119
                        options=[u"--compare-data"])
120
120
        except CmdError as e:
121
121
            self.assertEqual(e.exit_status, 1, str(e))
122
122
        else:
124
124
 
125
125
    def test_verify_corrupt_archive(self):
126
126
        """Test verify (without --compare-data) gives an error if the archive is corrupted"""
127
 
        self.backup("full", "testfiles/various_file_types", options=[])
 
127
        self.backup(u"full", u"testfiles/various_file_types", options=[])
128
128
        output_files = os.listdir("testfiles/output")
129
129
        archives = [elem for elem in output_files if "vol" in elem]
130
130
        for archive in archives:
133
133
                f.write('This writes text into each archive file to corrupt it.')
134
134
        # Test verify for the file
135
135
        try:
136
 
            self.verify('testfiles/various_file_types/executable', file_to_verify='executable', options=[])
 
136
            self.verify(u'testfiles/various_file_types/executable', file_to_verify=u'executable', options=[])
137
137
        except CmdError as e:
138
138
            # Should return a 21 error code for "hash mismatch"
139
139
            self.assertEqual(e.exit_status, 21, str(e))
142
142
 
143
143
    def test_verify_corrupt_archive_compare_data(self):
144
144
        """Test verify with --compare-data gives an error if the archive is corrupted"""
145
 
        self.backup("full", "testfiles/various_file_types", options=[])
 
145
        self.backup(u"full", u"testfiles/various_file_types", options=[])
146
146
        output_files = os.listdir("testfiles/output")
147
147
        archives = [elem for elem in output_files if "vol" in elem]
148
148
        for archive in archives:
151
151
                f.write('This writes text into each archive file to corrupt it.')
152
152
        # Test verify for the file
153
153
        try:
154
 
            self.verify('testfiles/various_file_types/executable', file_to_verify='executable',
155
 
                        options=["--compare-data"])
 
154
            self.verify(u'testfiles/various_file_types/executable', file_to_verify=u'executable',
 
155
                        options=[u"--compare-data"])
156
156
        except CmdError as e:
157
157
            # Should return a 21 error code for "hash mismatch"
158
158
            self.assertEqual(e.exit_status, 21, str(e))