Code Duplication    Length = 33-41 lines in 2 locations

tests/test_webdav.py 2 locations

@@ 145-185 (lines=41) @@
142
        assert downloaded_file_content == file_content
143
        assert downloaded_file_content != new_file_content
144
145
    def test_move_path(self):
146
        # create a file to move
147
        file_name = "test_move_file"
148
        file_content = "test move file content"
149
        self.create_and_upload_file(file_name, file_content)
150
151
        # move file
152
        destination_path = "new_test_move_file_location"
153
        res = self.nxc_local.move_path(self.user_username, file_name, destination_path)
154
        assert res.raw.status_code == self.CREATED_CODE
155
        # check only new file exist
156
        original_file_props = self.nxc_local.list_folders(self.user_username, file_name)
157
        moved_file = self.nxc_local.list_folders(self.user_username, destination_path)
158
        assert len(original_file_props) == 0 and len(moved_file) == 1
159
160
        # copy file to already exist location
161
162
        # create a file to move
163
        file_name = "test_move_file"
164
        file_content = "test move file content"
165
        self.create_and_upload_file(file_name, file_content)
166
167
        # create new file for conflict
168
        new_file_name = 'test_move_file_'
169
        new_file_content = 'test_move_file_'
170
        self.create_and_upload_file(new_file_name, new_file_content)
171
172
        # move file to the new file location
173
        res = self.nxc_local.move_path(self.user_username, file_name, new_file_name)
174
        assert res.raw.status_code == self.PRECONDITION_FAILED_CODE
175
        # move with overriding
176
        res = self.nxc_local.move_path(self.user_username, file_name, new_file_name, overwrite=True)
177
        assert res.raw.status_code == self.NO_CONTENT_CODE
178
179
        # download just copied file and check content
180
        os.remove(os.path.join(os.getcwd(), new_file_name))  # remove file locally to download it
181
        self.nxc_local.download_file(self.user_username, new_file_name)
182
        with open(new_file_name, 'r') as f:
183
            downloaded_file_content = f.read()
184
        assert downloaded_file_content == file_content
185
        assert downloaded_file_content != new_file_content
186
187
    def test_set_list_favorites(self):
188
        # create new file to make favorite
@@ 111-143 (lines=33) @@
108
        res = self.nxc_local.delete_path(self.user_username, file_name)
109
        assert res.raw.status_code == 404
110
111
    def test_copy_path(self):
112
        # create a file to copy
113
        file_name = "test_file"
114
        file_content = "test file content"
115
        self.create_and_upload_file(file_name, file_content)
116
117
        # copy file
118
        destination_path = "new_test_file_location"
119
        res = self.nxc_local.copy_path(self.user_username, file_name, destination_path)
120
        assert res.raw.status_code == self.CREATED_CODE
121
        # check both file exist
122
        original_file_props = self.nxc_local.list_folders(self.user_username, file_name)
123
        copy_props = self.nxc_local.list_folders(self.user_username, destination_path)
124
        assert len(original_file_props) == 1 and len(copy_props) == 1
125
126
        # copy file to already exist location
127
        # create new file
128
        new_file_name = 'test_file_2'
129
        new_file_content = 'test_file_3'
130
        self.create_and_upload_file(new_file_name, new_file_content)
131
        res = self.nxc_local.copy_path(self.user_username, file_name, new_file_name)
132
        assert res.raw.status_code == self.PRECONDITION_FAILED_CODE
133
        # copy with overriding
134
        res = self.nxc_local.copy_path(self.user_username, file_name, new_file_name, overwrite=True)
135
        assert res.raw.status_code == self.NO_CONTENT_CODE
136
137
        # download just copied file and check content
138
        os.remove(os.path.join(os.getcwd(), new_file_name))  # remove file locally to download it
139
        self.nxc_local.download_file(self.user_username, new_file_name)
140
        with open(new_file_name, 'r') as f:
141
            downloaded_file_content = f.read()
142
        assert downloaded_file_content == file_content
143
        assert downloaded_file_content != new_file_content
144
145
    def test_move_path(self):
146
        # create a file to move