blob: 5016a4c2e1ddeaefb03350f408ce28e2c1d3b3de [file] [log] [blame]
# Copyright 2014 the Melange authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Seeder functions for sponsor model."""
from soc.models import sponsor as sponsor_model
from soc.modules.seeder.logic.providers import string as string_provider
TEST_SPONSOR_EMIAL = 'test.sponsor@example.com'
TEST_SPONSOR_HOME_PAGE = 'http://test.sponsor.home.page.com'
TEST_SPONSOR_NAME = 'Test Sponsor'
TEST_SPONSOR_DESCRIPTION = 'Test Sponsor Description'
TEST_SPONSOR_SHORT_NAME = 'Sponsor'
def seedSponsor(sponsor_id=None, **kwargs):
"""Seeds a new sponsor entity.
Args:
sponsor_id: Identifier of the new sponsor.
Returns:
Newly seeded sponsor_model.Sponsor entity.
"""
sponsor_id = sponsor_id or string_provider.UniqueIDProvider().getValue()
properties = {
'description': TEST_SPONSOR_DESCRIPTION,
'email': TEST_SPONSOR_EMIAL,
'home_page': TEST_SPONSOR_HOME_PAGE,
'key_name': sponsor_id,
'link_id': sponsor_id,
'org_id': sponsor_id,
'name': TEST_SPONSOR_NAME,
'short_name': TEST_SPONSOR_SHORT_NAME,
'sponsor_id': sponsor_id,
}
properties.update(kwargs)
sponsor = sponsor_model.Sponsor(**properties)
sponsor.put()
return sponsor