def test_default_with_explicit_default(self): locale_configuration_a = LocaleConfiguration('nl-NL') locale_configuration_b = LocaleConfiguration('en-US') sut = LocalesConfiguration([ locale_configuration_a, ]) sut.default = locale_configuration_b self.assertEquals(locale_configuration_b, sut.default)
def test_eq(self) -> None: locale_configuration_a = LocaleConfiguration('nl-NL') locale_configuration_b = LocaleConfiguration('en-US') sut = LocalesConfiguration([ locale_configuration_a, locale_configuration_b, ]) other = LocalesConfiguration([ locale_configuration_a, locale_configuration_b, ]) with assert_in_scope(sut): self.assertEquals(other, sut)
def test_delitem_with_one_remaining_locale_configuration(self) -> None: locale_configuration_a = LocaleConfiguration('nl-NL') sut = LocalesConfiguration([ locale_configuration_a, ]) with self.assertRaises(ConfigurationError): del sut['nl-NL']
def test_getitem(self) -> None: locale_configuration_a = LocaleConfiguration('nl-NL') sut = LocalesConfiguration([ locale_configuration_a, ]) with assert_in_scope(sut): self.assertEquals(locale_configuration_a, sut['nl-NL'])
def test_repr(self) -> None: locale_configuration_a = LocaleConfiguration('nl-NL') sut = LocalesConfiguration([ locale_configuration_a, ]) with assert_in_scope(sut): self.assertIsInstance(repr(sut), str)
def test_contains(self) -> None: locale_configuration_a = LocaleConfiguration('nl-NL') sut = LocalesConfiguration([ locale_configuration_a, ]) with assert_in_scope(sut): self.assertIn('nl-NL', sut) self.assertNotIn('en-US', sut)
def test_iter(self) -> None: locale_configuration_a = LocaleConfiguration('nl-NL') locale_configuration_b = LocaleConfiguration('en-US') sut = LocalesConfiguration([ locale_configuration_a, locale_configuration_b, ]) with assert_in_scope(sut): self.assertCountEqual( [locale_configuration_a, locale_configuration_b], iter(sut))
def test_delitem(self) -> None: locale_configuration_a = LocaleConfiguration('nl-NL') locale_configuration_b = LocaleConfiguration('en-US') sut = LocalesConfiguration([ locale_configuration_a, locale_configuration_b, ]) with assert_scope_empty(): with assert_reactor_called(sut): del sut['nl-NL'] self.assertCountEqual([locale_configuration_b], sut)
def test_should_load_locale_locale(self) -> None: locale = 'nl-NL' locale_config = { 'locale': locale, } with _build_minimal_configuration_dict() as configuration_dict: configuration_dict['locales'] = [locale_config] configuration = _from_dict(configuration_dict) self.assertEquals( LocalesConfiguration([LocaleConfiguration(locale)]), configuration.locales)
def test_default_without_explicit_locale_configurations(self): sut = LocalesConfiguration() self.assertEquals(LocaleConfiguration('en-US'), sut.default)
def test_add(self) -> None: sut = LocalesConfiguration() with assert_scope_empty(): with assert_reactor_called(sut): sut.add(LocaleConfiguration('nl-NL'))