Completed
Pull Request — master (#539)
by
unknown
02:36
created

BuildJobActionTestCase   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 22
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A test_run_api_success() 0 10 1
A test_run_api_404() 0 7 1
1
from teamcity_base_test_case import TeamCityBaseActionTestCase
2
3
from build_job import BuildJobAction
4
5
class BuildJobActionTestCase(TeamCityBaseActionTestCase):
6
    __test__ = True
7
    action_cls = BuildJobAction
8
9
    def test_run_api_404(self):
10
        action, adapter = self._get_action_status_code(
11
            'POST',
12
            "mock://example.teamcityagent.com:8080/httpAuth/rest/buildQueue",
13
            status_code=404)
14
15
        self.assertRaises(ValueError, action.run, "test", "testbranch")
16
17
    def test_run_api_success(self):
18
        expected = self.load_json("build_job.json")
19
20
        action, adapter = self.__get_mocked_action()
21
        adapter.register_uri('POST',
22
                             "mock://example.teamcityagent.com:8080/httpAuth/rest/buildQueue",
23
                             text=self.get_fixture_content("build_job,json"))
24
25
        result = action.run("test", "testbranch")
26
        self.assertEqual(result, expected)
27