'Asserts the user\'s account settings page context is in the expected state.
If duplicate is True, we expect context[\'duplicate_provider\'] to contain
the duplicate provider backend name. If linked is passed, we conditionally
check that the provider is included in context[\'auth\'][\'providers\'] and
its connected state is correct.'

def assert_account_settings_context_looks_correct(self, context, duplicate=False, linked=None):

    if duplicate:
        self.assertEqual(context['duplicate_provider'], self.provider.backend_name)
    else:
        self.assertIsNone(context['duplicate_provider'])
    if (linked is not None):
        expected_provider = [provider for provider in context['auth']['providers'] if (provider['name'] == self.provider.name)][0]
        self.assertIsNotNone(expected_provider)
        self.assertEqual(expected_provider['connected'], linked)
