Skip to content

Commit

Permalink
Merge pull request #35 from ambitioninc/develop
Browse files Browse the repository at this point in the history
Release 0.5.3
  • Loading branch information
jaredlewis committed Jan 19, 2016
2 parents 4a52eff + 0ab2551 commit d5b14c3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 44 deletions.
5 changes: 3 additions & 2 deletions dynamic_initial_data/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,9 @@ def update_app(self, app, handle_deletions=True):
self.updated_apps.add(app)

# Handle deletions if necessary, this could be a single call that was nat batched with multiple updates
if handle_deletions:
self.handle_deletions()
# We cannot handle this case yet since we do not know what app registered what deletions
# if handle_deletions:
# self.handle_deletions()

def handle_deletions(self):
"""
Expand Down
41 changes: 0 additions & 41 deletions dynamic_initial_data/tests/integration_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,44 +211,3 @@ def update_initial_data(self):
self.assertEquals(Account.objects.count(), 1)
self.assertEquals(RegisteredForDeletionReceipt.objects.count(), 1)
self.assertEquals(RegisteredForDeletionReceipt.objects.get().model_obj.name, 'hi')

def test_handle_deletions_when_update_app_is_called(self):
"""
Tests handling of deletions and updates when they are registered from the update_initial_data function. And we
only update a single application and not all
"""
class AccountInitialData1(BaseInitialData):
"""
The initial data code the first time it is called. It registers two accounts for deletion
by returning it from the update_initial_data function.
"""
def update_initial_data(self):
# Register two account objects for deletion
self.register_for_deletion(
Account.objects.get_or_create(name='hi')[0], Account.objects.get_or_create(name='hi2')[0])

class AccountInitialData2(BaseInitialData):
"""
The initial data code the second time it is called. It only manages one of the previous accounts
"""
def update_initial_data(self):
self.register_for_deletion(Account.objects.get_or_create(name='hi')[0])

# Verify no account objects exist
self.assertEquals(Account.objects.count(), 0)

with patch.object(InitialDataUpdater, 'load_app', return_value=AccountInitialData1):
InitialDataUpdater().update_app('test')

# Verify two account objects were created and are managed by deletion receipts
self.assertEquals(Account.objects.count(), 2)
self.assertEquals(RegisteredForDeletionReceipt.objects.count(), 2)

# Run the initial data process again, this time deleting the account named 'hi2'
with patch.object(InitialDataUpdater, 'load_app', return_value=AccountInitialData2):
InitialDataUpdater().update_app('test')

# Verify only the 'hi' account exists
self.assertEquals(Account.objects.count(), 1)
self.assertEquals(RegisteredForDeletionReceipt.objects.count(), 1)
self.assertEquals(RegisteredForDeletionReceipt.objects.get().model_obj.name, 'hi')
2 changes: 1 addition & 1 deletion dynamic_initial_data/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.5.2'
__version__ = '0.5.3'

0 comments on commit d5b14c3

Please sign in to comment.