Code Duplication    Length = 27-29 lines in 2 locations

tests/testfunctions.py 2 locations

@@ 165-193 (lines=29) @@
162
    mock_getctime.assert_called_once_with(file_path)
163
164
165
@istest
166
@parameterized([
167
    param("Creation Time '1601-01-01 00:00:00'", "DVD_PATH/VIDEO_TS/VTS_02_0.IFO", -11644473600,
168
          bytearray([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00])),
169
    param("Creation Time '9999-12-31 23:59:59'", "DVD_PATH/VIDEO_TS/VTS_02_1.VOB", 253402300799,
170
          bytearray([0x80, 0xa9, 0x27, 0xd1, 0x5e, 0x5a, 0xc8, 0x24])),
171
    param("Creation Time '2015-07-01 21:51:43'", "DVD_PATH/VIDEO_TS/VTS_02_2.VOB", 1435787503,
172
          bytearray([0x80, 0x01, 0x23, 0x1e, 0x48, 0xb4, 0xd0, 0x01]))
173
])
174
@patch("pydvdid.functions.getctime") # pylint: disable=locally-disabled, invalid-name
175
def _get_file_creation_time_returns_correctly_when_file_creation_time_is_valid(description,
176
                                                                               file_path, ctime,
177
                                                                               expected,
178
                                                                               mock_getctime):
179
    """Tests that invocation of _get_file_creation_time() with a file path that has a creation time
180
       that is within the allowable range of values returns correctly.
181
    """
182
183
    mock_getctime.return_value = ctime
184
185
    file_creation_time_bytearray = _get_file_creation_time(file_path)
186
187
    template = "Test case {0}' failed: expected '{1}', actual '{2}'."
188
    assert_message = template.format(description, _format_as_bytestring(expected),
189
                                     _format_as_bytestring(file_creation_time_bytearray))
190
191
    eq_(expected, file_creation_time_bytearray, assert_message)
192
193
    mock_getctime.assert_called_once_with(file_path)
194
195
196
@istest
@@ 196-222 (lines=27) @@
193
    mock_getctime.assert_called_once_with(file_path)
194
195
196
@istest
197
@parameterized([
198
    param("Size less than 256b", "DVD_PATH/VIDEO_TS/VIDEO_TS.BUP", 202,
199
          bytearray([0xca, 0x00, 0x00, 0x00])),
200
    param("Size less than 64Kb", "DVD_PATH/VIDEO_TS/VIDEO_TS.IFO", 43051,
201
          bytearray([0x2b, 0xa8, 0x00, 0x00])),
202
    param("Size less than 16Mb", "DVD_PATH/VIDEO_TS/VTS_01_1.VOB", 14412088,
203
          bytearray([0x38, 0xe9, 0xdb, 0x00])),
204
    param("Size less than 4Gb", "DVD_PATH/VIDEO_TS/VTS_02_0.VOB", 3812800233,
205
          bytearray([0xe9, 0xb6, 0x42, 0xe3]))
206
])
207
@patch("pydvdid.functions.getsize") # pylint: disable=locally-disabled, invalid-name
208
def _get_file_size_returns_correctly(description, file_path, file_size, expected, mock_getsize):
209
    """Tests that invocation of _get_file_size() returns correctly.
210
    """
211
212
    mock_getsize.return_value = file_size
213
214
    file_size_bytearray = _get_file_size(file_path)
215
216
    template = "Test case '{0}' failed: expected '{1}', actual '{2}'."
217
    assert_message = template.format(description, _format_as_bytestring(expected),
218
                                     _format_as_bytestring(file_size_bytearray))
219
220
    eq_(expected, file_size_bytearray, assert_message)
221
222
    mock_getsize.assert_called_once_with(file_path)
223
224
225
@istest