def test_exists_unknown_all(self): """If the repository sync-state is unknown, then it is considered to exist regardless of clean state. """ stat = ExternalStatus() stat.sync_state = ExternalStatus.UNKNOWN stat.clean_state = ExternalStatus.DEFAULT exists = stat.exists() self.assertTrue(exists) stat.clean_state = ExternalStatus.EMPTY exists = stat.exists() self.assertTrue(exists) stat.clean_state = ExternalStatus.UNKNOWN exists = stat.exists() self.assertTrue(exists) stat.clean_state = ExternalStatus.STATUS_OK exists = stat.exists() self.assertTrue(exists) stat.clean_state = ExternalStatus.DIRTY exists = stat.exists() self.assertTrue(exists)
def test_exists_empty_all(self): """If the repository sync-state is empty (doesn't exist), and there is no clean state, then it is considered not to exist. """ stat = ExternalStatus() stat.sync_state = ExternalStatus.EMPTY stat.clean_state = ExternalStatus.DEFAULT exists = stat.exists() self.assertFalse(exists) stat.clean_state = ExternalStatus.EMPTY exists = stat.exists() self.assertFalse(exists) stat.clean_state = ExternalStatus.UNKNOWN exists = stat.exists() self.assertFalse(exists) # this state represtens an internal logic error in how the # repo status was determined. stat.clean_state = ExternalStatus.STATUS_OK exists = stat.exists() self.assertTrue(exists) # this state represtens an internal logic error in how the # repo status was determined. stat.clean_state = ExternalStatus.DIRTY exists = stat.exists() self.assertTrue(exists)
def test_update_empty_all(self): """If the repository in-sync is empty, then it is not safe to update, regardless of the clean state. """ stat = ExternalStatus() stat.sync_state = ExternalStatus.UNKNOWN stat.clean_state = ExternalStatus.DEFAULT safe_to_update = stat.safe_to_update() self.assertFalse(safe_to_update) stat.clean_state = ExternalStatus.EMPTY safe_to_update = stat.safe_to_update() self.assertFalse(safe_to_update) stat.clean_state = ExternalStatus.UNKNOWN safe_to_update = stat.safe_to_update() self.assertFalse(safe_to_update) stat.clean_state = ExternalStatus.STATUS_OK safe_to_update = stat.safe_to_update() self.assertFalse(safe_to_update) stat.clean_state = ExternalStatus.DIRTY safe_to_update = stat.safe_to_update() self.assertFalse(safe_to_update)
def test_update_modified_all(self): """If the repository in-sync is modified, then it is safe to update only if clean state is ok """ stat = ExternalStatus() stat.sync_state = ExternalStatus.MODEL_MODIFIED stat.clean_state = ExternalStatus.DEFAULT safe_to_update = stat.safe_to_update() self.assertFalse(safe_to_update) stat.clean_state = ExternalStatus.EMPTY safe_to_update = stat.safe_to_update() self.assertFalse(safe_to_update) stat.clean_state = ExternalStatus.UNKNOWN safe_to_update = stat.safe_to_update() self.assertFalse(safe_to_update) stat.clean_state = ExternalStatus.STATUS_OK safe_to_update = stat.safe_to_update() self.assertTrue(safe_to_update) stat.clean_state = ExternalStatus.DIRTY safe_to_update = stat.safe_to_update() self.assertFalse(safe_to_update)