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
Pull Request — v1 (#16)
by Maksim
03:39
created

TestTiedListWrapper_Existing_Address   A

Complexity

Total Complexity 18

Size/Duplication

Total Lines 87
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 87
rs 10
c 1
b 0
f 0
wmc 18

7 Methods

Rating   Name   Duplication   Size   Complexity  
A setup_method() 0 19 1
B test_iterator_on_existance_parent() 0 21 5
A test_unlink() 0 6 3
A test_unset() 0 5 2
A test_append_raw_dict() 0 10 3
A test_append_model() 0 10 3
A teardown_method() 0 4 1
1
# -*- coding: utf-8 -*-
2
3
# import pytest
4
import mock
5
6
from . import TiedListWrapper
7
8
from . import Address
9
from . import Optimization
10
11
12
class TestTiedListWrapper_Existing_Address(object):
13
14
	parent = None
15
	mylist = None
16
17
	@classmethod
18
	def setup_method(cls, *args, **qw):
19
		cls.parent = Optimization(raw={
20
			'addresses': [
21
				{
22
					'lat': 1,
23
					'route_destination_id': 100
24
				},
25
				{
26
					'lat': 2,
27
					'route_destination_id': 200
28
				},
29
			]
30
		})
31
32
		cls.mylist = TiedListWrapper(
33
			parent=cls.parent,
34
			key='addresses',
35
			anytype=Address
36
		)
37
38
	@classmethod
39
	def teardown_method(cls, *args, **qw):
40
		cls.parent = None
41
		cls.mylist = None
42
43
	def test_iterator_on_existance_parent(self):
44
45
		exp = []
46
		cnt = 0
47
		m = mock.MagicMock()
48
		m.ID = 100
49
		m.latitude = 1.
50
		exp.append(m)
51
52
		m = mock.MagicMock()
53
		m.ID = 200
54
		m.latitude = 2.
55
		exp.append(m)
56
57
		for i in self.mylist:
58
			ee = exp[cnt]
59
			assert isinstance(i, Address)
60
			assert i.ID == ee.ID
61
			assert i.latitude == ee.latitude
62
63
			cnt += 1
64
65
	def test_append_model(self):
66
67
		addr = Address(raw={'route_destination_id': 123})
68
69
		self.mylist.append(addr)
70
71
		li = self.mylist
72
73
		assert len(li) == 3
74
		assert li[2] == addr
75
76
	def test_append_raw_dict(self):
77
78
		addr = {'route_destination_id': 123}
79
80
		self.mylist.append(addr)
81
82
		li = self.mylist
83
84
		assert len(li) == 3
85
		assert li[2] == addr
86
87
	def test_unlink(self):
88
89
		self.mylist.unlink()
90
91
		assert 'addresses' in self.parent.raw
92
		assert self.parent.raw['addresses'] is None
93
94
	def test_unset(self):
95
96
		self.mylist.unset()
97
98
		assert 'addresses' not in self.parent.raw
99
100
101
class TestOptimization(object):
102
	def test_links(self):
103
		opt = Optimization(raw={
104
105
			'optimization_problem_id': '1EDB78F63556D99336E06A13A34CF139',
106
			'user_errors': [],
107
			'optimization_errors': [],
108
			'state': 2,
109
			'created_timestamp': 1466151720,
110
			'scheduled_for': 1466121600,
111
			'optimization_completed_timestamp': None,
112
			'parameters': {
113
				'is_upload': False,
114
				'rt': False
115
			},
116
			'links': {
117
				'view': (
118
					'http:\/\/www.route4me.com\/api.v4\/'
119
					'optimization_problem.php?'
120
					'optimization_problem_id=1EDB78F63556D99336E06A13A34CF139'
121
					'&api_key=11111111111111111111111111111111&member_id=1'
122
				)
123
			}
124
		})
125
126
		assert opt.links['view'] == (
127
			'http:\/\/www.route4me.com\/api.v4\/'
128
			'optimization_problem.php?'
129
			'optimization_problem_id=1EDB78F63556D99336E06A13A34CF139'
130
			'&api_key=11111111111111111111111111111111&member_id=1'
131
		)
132