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 ( 120697...0b4edb )
by Maksim
01:20
created

TestOptimizationApi.test_create()   C

Complexity

Conditions 7

Size

Total Lines 45

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 7
c 1
b 0
f 0
dl 0
loc 45
rs 5.5
1
# -*- coding: utf-8 -*-
2
3
import os
4
import json
5
6
# import pytest
7
# import mock
8
9
from route4me.sdk.self_test import MockerResourceWithNetworkClient
10
from .optimizations import Optimizations
11
import route4me.sdk.resources.optimizations as M
12
13
from ..models import Optimization
14
from ..models import AlgorithmTypeEnum
15
from ..models import OptimizationStateEnum
16
17
18
class TestOptimizations:
19
	def test_ctor(self):
20
21
		api_key = '11111111111111111111111111111111'
22
23
		ns = Optimizations(api_key=api_key)
24
25
		assert ns is not None
26
27
28
class TestOptimizationApi(MockerResourceWithNetworkClient):
29
30
	resource_module = M
31
32
	def test_create(self):
33
34
		with open(os.path.join(
35
			# '..', '..', '..',
36
			'submodules', 'route4me-api-data-examples', 'Optimizations',
37
			'create_response.json'
38
		)) as f:
39
			sample_response_data = json.load(f)
40
41
		self.set_response(data=sample_response_data)
42
43
		o = Optimization()
44
		o.algorithm_type = AlgorithmTypeEnum.TSP
45
46
		r = Optimizations(api_key='test')
47
		res = r.create(o)
48
49
		print(self.mock_fluent_request_class.mock_calls)
50
		# call(),
51
		# call().method('POST'),
52
		# call().url('https://www.route4me.com//api.v4/optimization_problem.php'),
53
		# call().qs(None),
54
		# call().json({'links': {}, 'parameters': {'algorithm_type': 1}}),
55
		# call().user_agent('requests/2.18.3 (Linux 4.8.0-53-generic) Route4Me-Python-SDK/0.1.0 CPython/3.5.2'),
56
		# call().header('Route4Me-User-Agent', 'requests/2.18.3 (Linux 4.8.0-53-generic) ..'),
57
		# call().accept('application/json'),
58
		# call().header('Route4Me-Api-Key', 'test'),
59
		# call().qs({'format': 'json', 'api_key': 'test'}),
60
		# call().send(),
61
		# call().send().json()
62
63
		# assertions
64
		mock_freq = self.last_request()
65
		mock_freq.method.assert_called_with('POST')
66
		mock_freq.url.assert_called_with(
67
			'https://www.route4me.com/api.v4/optimization_problem.php'
68
		)
69
		mock_freq.json.assert_called_with(dict(o))
70
71
		# assertions on response
72
		assert isinstance(res, Optimization)
73
		assert res.ID == '1EDB78F63556D99336E06A13A34CF139'
74
		assert res.name == 'Fri, 17 Jun 2016 08:21:59 +0000 UTC'
75
		assert res.algorithm_type == AlgorithmTypeEnum.TSP
76
		assert res.state == OptimizationStateEnum.MATRIX_PROCESSING
77