def test___getitem___initialized(self): """Test __getitem__() when the origins are initialized.""" co = security.CorsOrigins('cors_origins_ro') co.initialize() with mock.patch('bodhi.server.security.get_current_registry', side_effect=Exception()): # This should not raise the Exception because initialize() won't get called again. self.assertEqual(co[1], 'origin_2')
def test_initialize_with_origins(self): """initialize() with origins already set should do nothing.""" co = security.CorsOrigins('cors_origins_ro') co.initialize() with mock.patch('bodhi.server.security.get_current_registry', side_effect=Exception()): # This should not raise the Exception because initialize() won't get called again. co.initialize()
def test___init__(self): """Test correct behavior from __init__().""" co = security.CorsOrigins('cors_origins_ro') assert co.name == 'cors_origins_ro' assert co.origins is None
def test___getitem___uninitialized(self): """Test __getitem__() when the origins are uninitialized.""" co = security.CorsOrigins('cors_origins_ro') assert co[0] == 'origin_1'
def test___contains___uninitialized(self): """Test __contains__() when the origins are uninitialized.""" co = security.CorsOrigins('cors_origins_ro') assert 'origin_1' in co
def test_initialize_without_origins(self): """initialize() without origins set should set the origins.""" co = security.CorsOrigins('cors_origins_ro') co.initialize() assert co.origins == ['origin_1', 'origin_2']
def test_initialize_setting_not_found(self): """initialize() should set origins to ['localhost'] if the setting doesn't exist.""" co = security.CorsOrigins('not_found') assert list(co) == ['localhost']
def test___len___uninitialized(self): """Test __len__() when the origins are uninitialized.""" co = security.CorsOrigins('cors_origins_ro') assert len(co) == 2
def test___iter___uninitialized(self): """Test __iter__() when the origins are uninitialized.""" co = security.CorsOrigins('cors_origins_ro') assert list(co) == ['origin_1', 'origin_2']
def test___init__(self): """Test correct behavior from __init__().""" co = security.CorsOrigins('cors_origins_ro') self.assertEqual(co.name, 'cors_origins_ro') self.assertIs(co.origins, None)