def setup_terms(self): scope = Scope.for_brand(self.brand_id) snippet, _ = snippet_service.create_fragment( scope, 'terms_of_service', self.admin.id, 'Don\'t do anything stupid!', ) consent_subject = consent_subject_service.create_subject( f'{self.brand_id}_terms-of-service_v1', f'Terms of service for {self.brand.title} / v1', 'terms_of_service', ) terms_document_id = self.brand_id terms_document = terms_document_service.create_document( terms_document_id, terms_document_id) terms_version = terms_version_service.create_version( terms_document.id, '01-Jan-2016', snippet.id, consent_subject.id) terms_document_service.set_current_version(terms_document_id, terms_version.id) brand_settings_service.create_setting(self.brand.id, 'terms_document_id', str(terms_document.id)) self.terms_version_id = terms_version.id self.terms_consent_subject_id = terms_version.consent_subject_id
def setup_newsletter_list(self): list_ = newsletter_command_service.create_list(self.brand.id, self.brand.title) brand_settings_service.create_setting(self.brand.id, 'newsletter_list_id', str(list_.id))
def setup_privacy_policy(self): consent_subject = consent_subject_service.create_subject( '{}_privacy_policy_v1'.format(self.brand_id), 'Privacy policy for {} / v1'.format(self.brand.title), 'privacy_policy') brand_settings_service.create_setting( self.brand.id, 'privacy_policy_consent_subject_id', str(consent_subject.id)) self.privacy_policy_consent_subject_id = consent_subject.id
def test_find_value(app): brand_id = app.brand_id name = 'name4' value = 'value4' value_before_create = settings_service.find_setting_value(brand_id, name) assert value_before_create is None settings_service.create_setting(brand_id, name, value) value_after_create = settings_service.find_setting_value(brand_id, name) assert value_after_create == value
def setup_privacy_policy(self): consent_subject = consent_subject_service.create_subject( f'{self.brand_id}_privacy_policy_v1', f'Privacy policy for {self.brand.title} / v1', 'privacy_policy', ) brand_settings_service.create_setting( self.brand.id, 'privacy_policy_consent_subject_id', str(consent_subject.id), ) self.privacy_policy_consent_subject_id = consent_subject.id
def test_find(app): brand_id = app.brand_id name = 'name3' value = 'value3' setting_before_create = settings_service.find_setting(brand_id, name) assert setting_before_create is None settings_service.create_setting(brand_id, name, value) setting_after_create = settings_service.find_setting(brand_id, name) assert setting_after_create is not None assert setting_after_create.brand_id == brand_id assert setting_after_create.name == name assert setting_after_create.value == value
def test_create(app): brand_id = app.brand_id name = 'name1' value = 'value1' assert settings_service.find_setting(brand_id, name) is None setting = settings_service.create_setting(brand_id, name, value) assert setting is not None assert setting.brand_id == brand_id assert setting.name == name assert setting.value == value
def test_get_settings(app): brand_id = app.brand_id # Clean up. DbSetting.query.delete() all_settings_before_create = settings_service.get_settings(brand_id) assert all_settings_before_create == set() for name, value in { ('name5a', 'value5a'), ('name5b', 'value5b'), ('name5c', 'value5c'), }: settings_service.create_setting(brand_id, name, value) all_settings_after_create = settings_service.get_settings(brand_id) assert all_settings_after_create == { BrandSetting(brand_id, 'name5a', 'value5a'), BrandSetting(brand_id, 'name5b', 'value5b'), BrandSetting(brand_id, 'name5c', 'value5c'), }