@@ -72,6 +72,19 @@ def test_sub_id(self):
7272 'url' : 'http://example.com/t' ,
7373 })
7474
75+ def test_election_id_for_non_poltical_contribution (self ):
76+ it = ItemDefinition (
77+ 1 , 'EUR20' , 'http://example.com/t' , 'title' , item_type = constants .ITEM_TYPE_CONTRIBUTION ,
78+ election_id = '123-election' ,
79+ )
80+ self .assertEqual (it .data , {
81+ 'campaign_id' : 1 ,
82+ 'expiry' : None ,
83+ 'pricing' : 'EUR20' ,
84+ 'title' : 'title' ,
85+ 'url' : 'http://example.com/t' ,
86+ })
87+
7588 def test_item_type_contribution (self ):
7689 it = ItemDefinition (1 , 'EUR20' , 'http://example.com/t' , 'title' , item_type = constants .ITEM_TYPE_CONTRIBUTION )
7790 self .assertEqual (it .data , {
@@ -94,6 +107,21 @@ def test_item_type_donation(self):
94107 })
95108 self .assertEqual (it .item_type , 'donation' )
96109
110+ def test_item_type_political_contribution (self ):
111+ it = ItemDefinition (
112+ 1 , 'EUR20' , 'http://example.com/t' , 'title' , item_type = constants .ITEM_TYPE_POLITICAL_CONTRIBUTION ,
113+ election_id = '123-election' ,
114+ )
115+ self .assertEqual (it .data , {
116+ 'campaign_id' : 1 ,
117+ 'expiry' : None ,
118+ 'pricing' : 'EUR20' ,
119+ 'title' : 'title' ,
120+ 'url' : 'http://example.com/t' ,
121+ 'election_id' : '123-election' ,
122+ })
123+ self .assertEqual (it .item_type , 'political' )
124+
97125 def test_item_type_unknown (self ):
98126 it = ItemDefinition (1 , 'EUR20' , 'http://example.com/t' , 'title' , item_type = 'whatever' )
99127 self .assertEqual (it .data , {
@@ -285,6 +313,19 @@ def test_get_add_url_donation(self):
285313 self .assertQueryString (url , 'url' , 'http://example.net/t' )
286314 self .assertQueryString (url , 'title' , 'Save the World!' )
287315
316+ def test_get_add_url_political_contribution (self ):
317+ item = ItemDefinition (
318+ '2' , 'EUR20' , 'http://example.net/t' , 'Vote for Sue!' ,
319+ item_type = constants .ITEM_TYPE_POLITICAL_CONTRIBUTION , election_id = '123-election' ,
320+ )
321+ url = self .lp .get_add_url (item , item_type = 'political' )
322+ self .assertTrue (url .startswith ('https://web.laterpay.net/dialog/political_contribution/pay_later?' ))
323+ self .assertQueryString (url , 'campaign_id' , '2' )
324+ self .assertQueryString (url , 'pricing' , 'EUR20' )
325+ self .assertQueryString (url , 'url' , 'http://example.net/t' )
326+ self .assertQueryString (url , 'title' , 'Vote for Sue!' )
327+ self .assertQueryString (url , 'election_id' , '123-election' )
328+
288329 def test_get_buy_url (self ):
289330 item = ItemDefinition (1 , 'EUR20' , 'http://example.net/t' , 'title' )
290331 url = self .lp .get_buy_url (
@@ -336,6 +377,19 @@ def test_get_buy_url_donation(self):
336377 self .assertQueryString (url , 'url' , 'http://example.net/t' )
337378 self .assertQueryString (url , 'title' , 'Save the World!' )
338379
380+ def test_get_buy_url_political_contribution (self ):
381+ item = ItemDefinition (
382+ 'vote-for-sue' , 'EUR20' , 'http://example.net/t' , 'Vote for Sue!' ,
383+ item_type = constants .ITEM_TYPE_POLITICAL_CONTRIBUTION , election_id = '123-election' ,
384+ )
385+ url = self .lp .get_buy_url (item )
386+ self .assertTrue (url .startswith ('https://web.laterpay.net/dialog/political_contribution/pay_now?' ))
387+ self .assertQueryString (url , 'campaign_id' , 'vote-for-sue' )
388+ self .assertQueryString (url , 'pricing' , 'EUR20' )
389+ self .assertQueryString (url , 'url' , 'http://example.net/t' )
390+ self .assertQueryString (url , 'title' , 'Vote for Sue!' )
391+ self .assertQueryString (url , 'election_id' , '123-election' )
392+
339393 def test_get_subscribe_url (self ):
340394 item = ItemDefinition (1 , 'EUR20' , 'http://example.net/t' , 'title' , sub_id = 'a0_-9Z' , period = 12345 )
341395 url = self .lp .get_subscribe_url (
0 commit comments