@@ -73,18 +73,22 @@ class TestMessageStr:
7373 messaging .Message (topic = 'topic' , condition = 'condition' ),
7474 messaging .Message (condition = 'condition' , token = 'token' ),
7575 messaging .Message (topic = 'topic' , token = 'token' , condition = 'condition' ),
76+ messaging .Message (fid = 'fid' , token = 'token' ),
77+ messaging .Message (fid = 'fid' , topic = 'topic' ),
78+ messaging .Message (fid = 'fid' , condition = 'condition' ),
79+ messaging .Message (fid = 'fid' , token = 'token' , topic = 'topic' ),
7680 ])
7781 def test_invalid_target_message (self , msg ):
7882 with pytest .raises (ValueError ) as excinfo :
7983 str (msg )
8084 assert str (
81- excinfo .value ) == 'Exactly one of token, topic or condition must be specified.'
85+ excinfo .value ) == 'Exactly one of fid, token, topic or condition must be specified.'
8286
8387 def test_empty_message (self ):
8488 assert str (messaging .Message (token = 'value' )) == '{"token": "value"}'
8589 assert str (messaging .Message (topic = 'value' )) == '{"topic": "value"}'
86- assert str (messaging .Message (condition = 'value' )
87- ) == '{"condition ": "value"}'
90+ assert str (messaging .Message (condition = 'value' )) == '{"condition": "value"}'
91+ assert str ( messaging . Message ( fid = 'value' )) == '{"fid ": "value"}'
8892
8993 def test_data_message (self ):
9094 assert str (messaging .Message (topic = 'topic' , data = {})
@@ -128,18 +132,28 @@ class TestMessageEncoder:
128132 messaging .Message (topic = 'topic' , condition = 'condition' ),
129133 messaging .Message (condition = 'condition' , token = 'token' ),
130134 messaging .Message (topic = 'topic' , token = 'token' , condition = 'condition' ),
135+ messaging .Message (fid = 'fid' , token = 'token' ),
136+ messaging .Message (fid = 'fid' , topic = 'topic' ),
137+ messaging .Message (fid = 'fid' , condition = 'condition' ),
138+ messaging .Message (fid = 'fid' , token = 'token' , topic = 'topic' ),
131139 ])
132140 def test_invalid_target_message (self , msg ):
133141 with pytest .raises (ValueError ) as excinfo :
134142 check_encoding (msg )
135- assert str (excinfo .value ) == 'Exactly one of token, topic or condition must be specified.'
143+ assert str (excinfo .value ) == 'Exactly one of fid, token, topic or condition must be specified.'
136144
137145 @pytest .mark .parametrize ('target' , NON_STRING_ARGS + ['' ])
138146 def test_invalid_token (self , target ):
139147 with pytest .raises (ValueError ) as excinfo :
140148 check_encoding (messaging .Message (token = target ))
141149 assert str (excinfo .value ) == 'Message.token must be a non-empty string.'
142150
151+ @pytest .mark .parametrize ('target' , NON_STRING_ARGS + ['' ])
152+ def test_invalid_fid (self , target ):
153+ with pytest .raises (ValueError ) as excinfo :
154+ check_encoding (messaging .Message (fid = target ))
155+ assert str (excinfo .value ) == 'Message.fid must be a non-empty string.'
156+
143157 @pytest .mark .parametrize ('target' , NON_STRING_ARGS + ['' ])
144158 def test_invalid_topic (self , target ):
145159 with pytest .raises (ValueError ) as excinfo :
@@ -159,9 +173,14 @@ def test_malformed_topic_name(self, topic):
159173
160174 def test_empty_message (self ):
161175 check_encoding (messaging .Message (token = 'value' ), {'token' : 'value' })
176+ check_encoding (messaging .Message (fid = 'value' ), {'fid' : 'value' })
162177 check_encoding (messaging .Message (topic = 'value' ), {'topic' : 'value' })
163178 check_encoding (messaging .Message (condition = 'value' ), {'condition' : 'value' })
164179
180+ def test_token_deprecation_warning (self ):
181+ with pytest .deprecated_call ():
182+ messaging .Message (token = 'value' )
183+
165184 @pytest .mark .parametrize ('data' , NON_DICT_ARGS )
166185 def test_invalid_data_message (self , data ):
167186 with pytest .raises (ValueError ):
0 commit comments