本文整理汇总了Python中subscriber.Subscriber.save方法的典型用法代码示例。如果您正苦于以下问题:Python Subscriber.save方法的具体用法?Python Subscriber.save怎么用?Python Subscriber.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类subscriber.Subscriber
的用法示例。
在下文中一共展示了Subscriber.save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_non_ascii_char
# 需要导入模块: from subscriber import Subscriber [as 别名]
# 或者: from subscriber.Subscriber import save [as 别名]
def test_non_ascii_char(self):
subscriber = Subscriber()
subscriber.lastname = u'Toto°°'
subscriber.issues_to_receive = 1
subscriber.save()
line = get_first_line()
self.assertTrue(line is not None)
示例2: test_subscription_info_by_lastname
# 需要导入模块: from subscriber import Subscriber [as 别名]
# 或者: from subscriber.Subscriber import save [as 别名]
def test_subscription_info_by_lastname(self):
"""Test subscription info fields retrieved by the adapter"""
sub = Subscriber()
sub.lastname = 'toto'
sub.subscription_date = date(2011, 10, 10)
sub.issues_to_receive = 5
sub.subs_beginning_issue = 32
sub.subscription_price = 31.50
sub.membership_price = 50.25
sub.hors_serie1 = 1
sub.ordering_type = 'pp'
sub.comment = 'blahblah'
sub.save()
dict_list = SubscriberAdapter.get_subscribers_from_lastname('toto')
new_sub = dict_list[0]
self.assertEquals('10/10/2011', new_sub['subscription_date'])
self.assertEquals('5', new_sub['issues_to_receive'])
self.assertEquals('32', new_sub['subs_beginning_issue'])
self.assertEquals('31,50', new_sub['subscription_price'])
self.assertEquals('50,25', new_sub['membership_price'])
self.assertEquals('1', new_sub['hors_serie1'])
self.assertEquals('pp', new_sub['ordering_type'])
self.assertEquals('blahblah', new_sub['comment'])
self.assertEquals(sub.identifier, new_sub['subscriber_id'])
示例3: test_first_line
# 需要导入模块: from subscriber import Subscriber [as 别名]
# 或者: from subscriber.Subscriber import save [as 别名]
def test_first_line(self):
"""Test if the first line of generated file is well written"""
subs = Subscriber()
subs.lastname = 'Debelle'
subs.firstname = 'Anne'
a = Address()
a.address1 = 'rue dupre 63'
a.address2 = 'Bruxelles 1090'
a.city = 'belgique'
subs.address = a
subs.issues_to_receive = 1
subs.save()
line = self.export_and_get_first_line()
self.assertTrue(line is not None)
splitted_line = line.split('\t')
self.assertEquals(splitted_line[2], u'DEBELLE')
self.assertEquals(splitted_line[3], u'ANNE')
self.assertEquals(splitted_line[4], u'')
self.assertEquals(splitted_line[5], u'')
self.assertEquals(splitted_line[6], u'RUE DUPRE 63')
self.assertEquals(splitted_line[7], u'BRUXELLES 1090')
self.assertEquals(splitted_line[8], u'')
self.assertEquals(splitted_line[9], u'BELGIQUE')
self.assertEquals(splitted_line[10], u'')
self.assertEquals(splitted_line[11], u'')
self.assertEquals(splitted_line[12], u'')
self.assertEquals(splitted_line[13], u'')
self.assertEquals(splitted_line[14], u'')
self.assertEquals(splitted_line[15], u'\n')
示例4: test_field_length
# 需要导入模块: from subscriber import Subscriber [as 别名]
# 或者: from subscriber.Subscriber import save [as 别名]
def test_field_length(self):
"""test if the fields in the output file does not exceed character limits"""
big_string = ''.join(['b' for i in xrange(1, 40)])
subscriber = Subscriber()
subscriber.lastname = big_string
subscriber.firstname = big_string
subscriber.company = big_string
a = Address()
a.address1 = big_string
a.address2 = big_string
a.post_code = 123456
a.city = big_string
subscriber.address = a
subscriber.issues_to_receive = 10
subscriber.save()
line = self.export_and_get_first_line()
splitted_line = line.split('\t')
self.assertTrue(len(splitted_line[0]) <= 20)
self.assertTrue(len(splitted_line[1]) <= 12)
self.assertTrue(len(splitted_line[2]) <= 32)
self.assertTrue(len(splitted_line[3]) <= 20)
self.assertTrue(len(splitted_line[4]) <= 32)
self.assertTrue(len(splitted_line[5]) <= 32)
self.assertTrue(len(splitted_line[6]) <= 32)
self.assertTrue(len(splitted_line[7]) <= 32)
self.assertTrue(len(splitted_line[8]) <= 5)
self.assertTrue(len(splitted_line[9]) <= 26)
self.assertTrue(len(splitted_line[10]) <= 8)
self.assertTrue(len(splitted_line[11]) <= 3)
self.assertTrue(len(splitted_line[12]) <= 32)
self.assertTrue(len(splitted_line[13]) <= 32)
self.assertTrue(len(splitted_line[14]) <= 32)
self.assertTrue(len(splitted_line[15]) <= 32)
示例5: test_one_email
# 需要导入模块: from subscriber import Subscriber [as 别名]
# 或者: from subscriber.Subscriber import save [as 别名]
def test_one_email(self):
"""Test retrieval of one subscriber's email"""
subscriber = Subscriber()
subscriber.issues_to_receive = 0
subscriber.email_address = '[email protected]'
subscriber.save()
lines = self.export_and_get_lines()
self.assertEqual('[email protected]', lines.strip())
示例6: test_remaining_issues_subscriber
# 需要导入模块: from subscriber import Subscriber [as 别名]
# 或者: from subscriber.Subscriber import save [as 别名]
def test_remaining_issues_subscriber(self):
"""Tests when the subscriber has remaining issues"""
subs = Subscriber()
subs.issues_to_receive = 1
subs.email_address = '[email protected]'
subs.save()
lines = self.export_and_get_lines()
self.assertEqual('', lines)
示例7: test_email_in_lowercase
# 需要导入模块: from subscriber import Subscriber [as 别名]
# 或者: from subscriber.Subscriber import save [as 别名]
def test_email_in_lowercase(self):
"""Tests that in generated file, the emails are in lower case"""
subscriber = Subscriber()
subscriber.issues_to_receive = 0
subscriber.email_address = '[email protected]'
subscriber.save()
lines = self.export_and_get_lines()
self.assertEqual('[email protected]', lines.strip())
示例8: test_subscriber_with_regular_and_special
# 需要导入模块: from subscriber import Subscriber [as 别名]
# 或者: from subscriber.Subscriber import save [as 别名]
def test_subscriber_with_regular_and_special(self):
"""Test when subscriber has both remaining regular and special issues"""
subs = Subscriber()
subs.issues_to_receive = 1
subs.hors_serie1 = 1
subs.email_address = '[email protected]'
subs.save()
lines = self.export_and_get_lines()
self.assertEqual('', lines)
示例9: init_company_subscriber_without_name
# 需要导入模块: from subscriber import Subscriber [as 别名]
# 或者: from subscriber.Subscriber import save [as 别名]
def init_company_subscriber_without_name(self):
"""Initialize a subscriber without name info but with company info."""
sub = Subscriber()
sub.company = 'Google'
a = Address()
a.address1 = 'Address'
a.city = 'USA'
sub.address = a
sub.issues_to_receive = 0
sub.save()
示例10: test_noexception_with_emtpy_string_postcode
# 需要导入模块: from subscriber import Subscriber [as 别名]
# 或者: from subscriber.Subscriber import save [as 别名]
def test_noexception_with_emtpy_string_postcode(self):
"""Test that former empty postcode leads to no export error exception"""
subscriber = Subscriber()
subscriber.lastname = 'toto'
subscriber.issues_to_receive = 1
a = Address()
a.post_code = 0
subscriber.address = a
subscriber.save()
line = self.export_and_get_first_line()
self.assertEqual(line.split('\t')[8], '')
示例11: test_5_digit_post_code
# 需要导入模块: from subscriber import Subscriber [as 别名]
# 或者: from subscriber.Subscriber import save [as 别名]
def test_5_digit_post_code(self):
"""Checks that the exported post_code is always written with 5 digits,
even if the first one is 0."""
sub = Subscriber()
sub.issues_to_receive = 1
a = Address()
a.post_code = 1300
sub.address = a
sub.save()
line = self.export_and_get_first_line()
splitted_line = line.split('\t')
self.assertEqual(splitted_line[8], '01300')
示例12: test_null_post_code_format
# 需要导入模块: from subscriber import Subscriber [as 别名]
# 或者: from subscriber.Subscriber import save [as 别名]
def test_null_post_code_format(self):
"""Test the postcode format when a null postcode is in db: 00000 is
ugly"""
sub = Subscriber()
sub.lastname = 'toto'
address = Address()
address.post_code = 0
sub.address = address
sub.save()
dict_list = SubscriberAdapter.get_subscribers_from_lastname('toto')
new_sub = dict_list[0]
self.assertEquals('', new_sub['post_code'])
示例13: test_subscriber_with_wrong_pricing_info
# 需要导入模块: from subscriber import Subscriber [as 别名]
# 或者: from subscriber.Subscriber import save [as 别名]
def test_subscriber_with_wrong_pricing_info(self):
"""Tests what happens when Subscriber has wrong or empty pricing
info"""
sub = Subscriber()
sub.lastname = 'toto'
sub.subscription_price = 'foo'
sub.membership_price = 'bar'
sub.save()
dict_list = SubscriberAdapter.get_subscribers_from_lastname('toto')
new_sub = dict_list[0]
self.assertEquals('0,00', new_sub['subscription_price'])
self.assertEquals('0,00', new_sub['membership_price'])
示例14: test_empty_email
# 需要导入模块: from subscriber import Subscriber [as 别名]
# 或者: from subscriber.Subscriber import save [as 别名]
def test_empty_email(self):
"""Tests what appens when a subscriber has no email"""
subscriber = Subscriber()
subscriber.email_address = '[email protected]'
subscriber.issues_to_receive = 0
subscriber.save()
subscriber = Subscriber()
subscriber.email_address = ''
subscriber.issues_to_receive = 0
subscriber.save()
lines = self.export_and_get_lines()
self.assertEqual('[email protected]\n', lines)
示例15: test_mail_sent_updated_special_issue
# 需要导入模块: from subscriber import Subscriber [as 别名]
# 或者: from subscriber.Subscriber import save [as 别名]
def test_mail_sent_updated_special_issue(self):
sub = Subscriber()
sub.lastname = 'toto'
sub.issues_to_receive = 0
sub.hors_serie1 = 0
sub.mail_sent = 1
sub.save()
self.assertEqual(1, sub.mail_sent)
sub.hors_serie1 = 1
sub.save()
self.assertEqual(0, sub.mail_sent)