def test_ephemeral_change(self): previous = [ ChangeItem( index='test_index', account='test_account', name='item1_name', new_config={ 'normal': True } ), ChangeItem( index='test_index', account='test_account', name='item2_name', new_config={ 'normal': False, 'test_ephemeral': 'previous ephemeral' } ) ] current = [ ChangeItem( index='test_index', account='test_account', name='item1_name', new_config={ 'normal': True } ), ChangeItem( index='test_index', account='test_account', name='item2_name', new_config={ 'normal': False, 'test_ephemeral': 'current ephemeral' } ) ] self._setup_account() watcher = Watcher(accounts=['test_account']) watcher.honor_ephemerals = True watcher.ephemeral_paths = ['test_ephemeral'] watcher.find_modified(previous, current) assert len(watcher.changed_items) == 0
def test_save_ephemeral_changed_item(self): self._setup_account() datastore = Datastore() old_item = ChangeItem( index='test_index', account='test_account', name='item_name', active=True, new_config={ 'config': 'test1' } ) old_item.save(datastore) query = Item.query.filter(Technology.name == 'test_index').filter(Account.name == 'test_account') items = query.all() self.assertEquals(len(items), 1) revisions = items[0].revisions.all() self.assertEquals(len(revisions), 1) new_item = ChangeItem( index='test_index', account='test_account', name='item_name', active=True, new_config={ 'config': 'test2' } ) watcher = Watcher(accounts=['test_account']) watcher.index = 'test_index' watcher.honor_ephemerals = True watcher.ephemeral_paths = ["config"] watcher.find_changes(current=[new_item]) watcher.save() query = Item.query.filter(Technology.name == 'test_index').filter(Account.name == 'test_account') items = query.all() self.assertEquals(len(items), 1) revisions = items[0].revisions.all() self.assertEquals(len(revisions), 1)
def test_save_ephemeral_changed_item(self): self._setup_account() datastore = Datastore() old_item = ChangeItem(index='test_index', account='test_account', name='item_name', active=True, new_config={'config': 'test1'}) old_item.save(datastore) query = Item.query.filter(Technology.name == 'test_index').filter( Account.name == 'test_account') items = query.all() self.assertEqual(len(items), 1) revisions = items[0].revisions.all() self.assertEqual(len(revisions), 1) new_item = ChangeItem(index='test_index', account='test_account', name='item_name', active=True, new_config={'config': 'test2'}) watcher = Watcher(accounts=['test_account']) watcher.index = 'test_index' watcher.honor_ephemerals = True watcher.ephemeral_paths = ["config"] watcher.find_changes(current=[new_item]) watcher.save() query = Item.query.filter(Technology.name == 'test_index').filter( Account.name == 'test_account') items = query.all() self.assertEqual(len(items), 1) revisions = items[0].revisions.all() self.assertEqual(len(revisions), 1)
def test_ephemeral_change(self): previous = [ ChangeItem(index='test_index', account='test_account', name='item1_name', new_config={'normal': True}), ChangeItem(index='test_index', account='test_account', name='item2_name', new_config={ 'normal': False, 'test_ephemeral': 'previous ephemeral' }) ] current = [ ChangeItem(index='test_index', account='test_account', name='item1_name', new_config={'normal': True}), ChangeItem(index='test_index', account='test_account', name='item2_name', new_config={ 'normal': False, 'test_ephemeral': 'current ephemeral' }) ] self._setup_account() watcher = Watcher(accounts=['test_account']) watcher.honor_ephemerals = True watcher.ephemeral_paths = ['test_ephemeral'] watcher.find_modified(previous, current) assert len(watcher.changed_items) == 0