def test_make_request(self, mock_connect): sc = StatsManager(None, 'Mock', 1) sc._sock = StringIOConnection() sc.log_request(7, 0.01) server = self._mock_server_call(sc._sock.value()) self.assertEqual( server.sys_cache, {'requests': 1, 'request_seconds': 0.01, 'max_request_seconds': 0.01} ) self.assertEqual( server.img_cache.get(7), {'requests': 1, 'request_seconds': 0.01, 'max_request_seconds': 0.01} )
def test_make_download_nostats(self, mock_connect): sc = StatsManager(None, 'Mock', 1) sc._sock = StringIOConnection() sc.log_download(7, 1024, 1, False) server = self._mock_server_call(sc._sock.value()) self.assertEqual( server.sys_cache, {'requests': 1, 'downloads': 1, 'bytes': 1024, 'request_seconds': 1, 'max_request_seconds': 1} ) self.assertEqual( server.img_cache.get(7), {'requests': 1} )
def test_make_cached_view(self, mock_connect): sc = StatsManager(None, 'Mock', 1) sc._sock = StringIOConnection() sc.log_view(7, 1024, True, 0.02) server = self._mock_server_call(sc._sock.value()) self.assertEqual( server.sys_cache, {'requests': 1, 'views': 1, 'cached_views': 1, 'bytes': 1024, 'request_seconds': 0.02, 'max_request_seconds': 0.02} ) self.assertEqual( server.img_cache.get(7), {'requests': 1, 'views': 1, 'cached_views': 1, 'bytes': 1024, 'request_seconds': 0.02, 'max_request_seconds': 0.02} )