Skip to content

Commit

Permalink
Reducing line width to 79, #105
Browse files Browse the repository at this point in the history
  • Loading branch information
pylover committed Aug 2, 2018
1 parent f691b21 commit 6d17eed
Showing 1 changed file with 30 additions and 9 deletions.
39 changes: 30 additions & 9 deletions sqlalchemy_media/tests/test_delete_orphan.py
Expand Up @@ -29,7 +29,11 @@ class Person(self.Base):

with StoreManager(session, delete_orphan=True):
# First file before commit
person1.cv = File.create_from(BytesIO(b'Simple text.'), content_type='text/plain', extension='.txt')
person1.cv = File.create_from(
BytesIO(b'Simple text.'),
content_type='text/plain',
extension='.txt'
)
self.assertIsInstance(person1.cv, File)
first_filename = join(self.temp_path, person1.cv.path)
self.assertTrue(exists(first_filename))
Expand All @@ -55,7 +59,11 @@ class Person(self.Base):
with StoreManager(session):

# First file before commit
person1.cv = File.create_from(BytesIO(b'Simple text.'), content_type='text/plain', extension='.txt')
person1.cv = File.create_from(
BytesIO(b'Simple text.'),
content_type='text/plain',
extension='.txt'
)
first_filename = join(self.temp_path, person1.cv.path)
person1.cv = File.create_from(BytesIO(b'Second simple text.'))
second_filename = join(self.temp_path, person1.cv.path)
Expand All @@ -75,15 +83,19 @@ class Person(self.Base):
with StoreManager(session, delete_orphan=True):
person1 = Person()
person1.files = FileList([
File.create_from(BytesIO(b'simple text %d' % i)) for i in range(2)
File.create_from(
BytesIO(b'simple text %d' % i)
) for i in range(2)
])

# Removing the first file
first_filename = join(self.temp_path, person1.files[0].path)
second_filename = join(self.temp_path, person1.files[1].path)

person1.files = FileList([
File.create_from(BytesIO(b'New test file: %d' % i)) for i in range(2)
File.create_from(
BytesIO(b'New test file: %d' % i)
) for i in range(2)
])

session.add(person1)
Expand Down Expand Up @@ -136,8 +148,11 @@ class Person(self.Base):
self.assertFalse(exists(first_filename))
self.assertEqual(len(person1.files), 1)

old_attachment_filename = join(self.temp_path, person1.files[0].path)
attachment = person1.files[0].attach(BytesIO(b'Changed inside nested mutable!'))
old_attachment_filename = \
join(self.temp_path, person1.files[0].path)
attachment = person1.files[0].attach(
BytesIO(b'Changed inside nested mutable!')
)
attachment_filename = join(self.temp_path, attachment.path)
self.assertTrue(exists(old_attachment_filename))
self.assertTrue(exists(attachment_filename))
Expand All @@ -156,15 +171,19 @@ class Person(self.Base):
with StoreManager(session, delete_orphan=True):
person1 = Person()
person1.files = FileDict({
str(i): File.create_from(BytesIO(b'simple text %d' % i)) for i in range(2)
str(i): File.create_from(
BytesIO(b'simple text %d' % i)
) for i in range(2)
})

# Removing the first file
first_filename = join(self.temp_path, person1.files['0'].path)
second_filename = join(self.temp_path, person1.files['1'].path)

person1.files = FileDict({
str(i): File.create_from(BytesIO(b'New Text File %d' % i)) for i in range(2)
str(i): File.create_from(
BytesIO(b'New Text File %d' % i)
) for i in range(2)
})

session.add(person1)
Expand All @@ -188,7 +207,9 @@ class Person(self.Base):
with StoreManager(session, delete_orphan=True):
person1 = Person()
person1.files = FileDict({
str(i): File.create_from(BytesIO(b'simple text %d' % i)) for i in range(2)
str(i): File.create_from(
BytesIO(b'simple text %d' % i)
) for i in range(2)
})

# Removing the first file
Expand Down

0 comments on commit 6d17eed

Please sign in to comment.