GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — v1 ( b4dcfa...110339 )
by Maksim
01:36
created

MockerResourceWithNetworkClient.setup_method()   A

Complexity

Conditions 1

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
c 0
b 0
f 0
dl 0
loc 15
rs 9.4285
1
# -*- coding: utf-8 -*-
2
3
import mock
4
5
6
class MockerResourceWithNetworkClient(object):
7
8
	resource_module = None
9
10
	mock_fluent_request_class = None
11
12
	@classmethod
13
	def setup_method(cls):
14
15
		# there are several similar modules-resources.
16
		# all we need to test them -- mock NetworkClient, to prevent
17
		# network access.
18
		# Let's do it with mock.patch.object
19
		#
20
		# Mocked client will be accessible in tests as `cls.client`
21
22
		# mock FluentRequest
23
		cls._patcher_fluent_request_class = mock.patch(
24
			'route4me.sdk._net.FluentRequest'
25
		)
26
		cls.mock_fluent_request_class = cls._patcher_fluent_request_class.start()
27
28
	@classmethod
29
	def teardown_method(cls):
30
		"""Teardown test environment for the entire class
31
		"""
32
		cls._patcher_fluent_request_class.stop()
33
34
	def set_response(self, status_code=200, data=None, **qw):
35
36
		x = mock.MagicMock()
37
		x.status_code = status_code
38
		x.json.return_value = data
39
40
		for k in qw:
41
			x.k = qw[k]
42
43
		self.mock_fluent_request_class.return_value.send.return_value = x
44
45
	def last_request(self):
46
		return self.mock_fluent_request_class.return_value
47