def test_generate_passphrase_with_specific_language(self): # Given a generator that supports two languages generator = PassphraseGenerator(language_to_words={ "en": ["boat"], "fr": ["bateau"] }) assert generator.available_languages == {"en", "fr"} # When using it to create a passphrase for one of the two languages # It succeeds passphrase = generator.generate_passphrase(preferred_language="fr") # And the passphrase is in the chosen language assert "bateau" in passphrase assert "boat" not in passphrase
def test_generate_passphrase_with_specific_language_that_is_not_available( self): # Given a generator that supports two languages generator = PassphraseGenerator( language_to_words={ "en": ["boat"], "fr": ["bateau"] }, # With english as the fallback language fallback_language="en", ) assert generator.available_languages == {"en", "fr"} # When using it to create a passphrase for another, non-supported language # It succeeds passphrase = generator.generate_passphrase(preferred_language="es") # And the passphrase is in the default/fallback language, english assert "boat" in passphrase assert "bateau" not in passphrase