def test_get_version(self): v1 = models.FileVersion(identifier='1') v2 = models.FileVersion(identifier='2') v1.save() v2.save() file = TestFile( _path='afile', name='name', target=self.node, provider='test', materialized_path='/long/path/to/name', ) file.save() file.versions.add(*[v1, v2]) assert_equals(file.get_version('1'), v1) assert_equals(file.get_version('2', required=True), v2) assert_is(file.get_version('3'), None) with assert_raises(exceptions.VersionNotFoundError): file.get_version('3', required=True)
def test_update_version_metadata(self): v1 = models.FileVersion(identifier='1') v1.save() file = TestFile( _path='afile', name='name', target=self.node, provider='test', materialized_path='/long/path/to/name', ) file.save() file.versions.add(v1) file.update_version_metadata(None, {'size': 1337}) with assert_raises(exceptions.VersionNotFoundError): file.update_version_metadata('3', {}) v1.refresh_from_db() assert_equal(v1.size, 1337)