def test_delete(self): user_settings = GoogleDriveUserSettingsFactory() assert_true(user_settings.has_auth) user_settings.delete() user_settings.save() assert_false(user_settings.access_token) assert_true(user_settings.deleted)
def test_clear(self): node_settings = GoogleDriveNodeSettingsFactory.build() user_settings = GoogleDriveUserSettingsFactory(access_token='abcde') node_settings.user_settings = user_settings node_settings.save() assert_true(user_settings.access_token) user_settings.clear() user_settings.save() assert_false(user_settings.access_token)
def test_clear_clears_associated_node_settings(self): node_settings = GoogleDriveNodeSettingsFactory.build() user_settings = GoogleDriveUserSettingsFactory() node_settings.user_settings = user_settings node_settings.save() user_settings.clear() user_settings.save() # Node settings no longer associated with user settings assert_is(node_settings.folder_id, None) assert_is(node_settings.user_settings, None)
def test_clear_wo_oauth_settings(self, mock_revoke_access_token): user_settings = GoogleDriveUserSettingsFactory(access_token='abcde') user_settings.oauth_settings = None user_settings.save() node_settings = GoogleDriveNodeSettingsFactory.build() node_settings.user_settings = user_settings node_settings.save() assert_false(user_settings.oauth_settings) user_settings.clear() user_settings.save() assert_false(mock_revoke_access_token.called)
def test_access_token_doesnt_refresh(self, mock_refresh): user_settings = GoogleDriveUserSettingsFactory() user_settings.save() user_settings.access_token assert_false(mock_refresh.called)
def test_has_auth(self): user_settings = GoogleDriveUserSettingsFactory(access_token=None) assert_false(user_settings.has_auth) user_settings.access_token = '12345' user_settings.save() assert_true(user_settings.has_auth)