66from django .test import RequestFactory , SimpleTestCase , override_settings
77
88from dojo import context_processors
9- from dojo .announcements import os_message
9+ from dojo .announcement import os_message
1010
1111
1212class _Resp :
@@ -105,44 +105,44 @@ def setUp(self):
105105
106106 def test_200_with_body_caches_body (self ):
107107 body = "# headline\n "
108- with patch ("dojo.announcements .os_message.requests.get" , return_value = _Resp (200 , body )) as mock_get :
108+ with patch ("dojo.announcement .os_message.requests.get" , return_value = _Resp (200 , body )) as mock_get :
109109 result = os_message .fetch_os_message ()
110110 self .assertEqual (result , body )
111111 self .assertEqual (cache .get (os_message .CACHE_KEY ), body )
112112 mock_get .assert_called_once ()
113113
114114 def test_404_caches_none (self ):
115- with patch ("dojo.announcements .os_message.requests.get" , return_value = _Resp (404 , "not found" )):
115+ with patch ("dojo.announcement .os_message.requests.get" , return_value = _Resp (404 , "not found" )):
116116 result = os_message .fetch_os_message ()
117117 self .assertIsNone (result )
118118 self .assertIsNone (cache .get (os_message .CACHE_KEY , default = "sentinel" ))
119119
120120 def test_timeout_caches_none (self ):
121- with patch ("dojo.announcements .os_message.requests.get" , side_effect = requests .exceptions .Timeout ):
121+ with patch ("dojo.announcement .os_message.requests.get" , side_effect = requests .exceptions .Timeout ):
122122 result = os_message .fetch_os_message ()
123123 self .assertIsNone (result )
124124 self .assertIsNone (cache .get (os_message .CACHE_KEY , default = "sentinel" ))
125125
126126 def test_connection_error_caches_none (self ):
127- with patch ("dojo.announcements .os_message.requests.get" , side_effect = requests .exceptions .ConnectionError ):
127+ with patch ("dojo.announcement .os_message.requests.get" , side_effect = requests .exceptions .ConnectionError ):
128128 result = os_message .fetch_os_message ()
129129 self .assertIsNone (result )
130130 self .assertIsNone (cache .get (os_message .CACHE_KEY , default = "sentinel" ))
131131
132132 def test_empty_body_caches_none (self ):
133- with patch ("dojo.announcements .os_message.requests.get" , return_value = _Resp (200 , " \n \n " )):
133+ with patch ("dojo.announcement .os_message.requests.get" , return_value = _Resp (200 , " \n \n " )):
134134 result = os_message .fetch_os_message ()
135135 self .assertIsNone (result )
136136 self .assertIsNone (cache .get (os_message .CACHE_KEY , default = "sentinel" ))
137137
138138 def test_second_call_hits_cache (self ):
139- with patch ("dojo.announcements .os_message.requests.get" , return_value = _Resp (200 , "# h\n " )) as mock_get :
139+ with patch ("dojo.announcement .os_message.requests.get" , return_value = _Resp (200 , "# h\n " )) as mock_get :
140140 os_message .fetch_os_message ()
141141 os_message .fetch_os_message ()
142142 self .assertEqual (mock_get .call_count , 1 )
143143
144144 def test_second_call_after_failure_also_hits_cache (self ):
145- with patch ("dojo.announcements .os_message.requests.get" , side_effect = requests .exceptions .Timeout ) as mock_get :
145+ with patch ("dojo.announcement .os_message.requests.get" , side_effect = requests .exceptions .Timeout ) as mock_get :
146146 os_message .fetch_os_message ()
147147 os_message .fetch_os_message ()
148148 self .assertEqual (mock_get .call_count , 1 )
@@ -155,12 +155,12 @@ def setUp(self):
155155 cache .clear ()
156156
157157 def test_returns_none_when_fetch_returns_none (self ):
158- with patch ("dojo.announcements .os_message.fetch_os_message" , return_value = None ):
158+ with patch ("dojo.announcement .os_message.fetch_os_message" , return_value = None ):
159159 self .assertIsNone (os_message .get_os_banner ())
160160
161161 def test_swallows_parse_exception (self ):
162- with patch ("dojo.announcements .os_message.fetch_os_message" , return_value = "# ok\n " ), \
163- patch ("dojo.announcements .os_message.parse_os_message" , side_effect = RuntimeError ("boom" )):
162+ with patch ("dojo.announcement .os_message.fetch_os_message" , return_value = "# ok\n " ), \
163+ patch ("dojo.announcement .os_message.parse_os_message" , side_effect = RuntimeError ("boom" )):
164164 self .assertIsNone (os_message .get_os_banner ())
165165
166166
0 commit comments