-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_pumpkins.py
57 lines (42 loc) · 1.27 KB
/
test_pumpkins.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import datetime
import pytest
import pumpkins
hostname = 'http://localhost:8080'
username = 'admin'
password = 'admin'
@pytest.fixture
def host():
return pumpkins.Host(hostname, username=username, password=password)
def test_connection(host):
assert host
def test_user(host):
assert host.me.name == username
def test_job_lifecycle(host):
assert host
name = 'asdasdasd'
if host.job(name):
host.job(name).delete()
assert name not in host.jobs()
job = host.createJob(name)
assert name in host.jobs()
assert host.job(name) is not None
job._configuration.buildSteps.add('true')
assert len(job.builds) == 0
a = datetime.datetime.now()
queue = job.schedule()
b = datetime.datetime.now()
queue.wait() # wait for the job to start
c = datetime.datetime.now()
queue.build.wait() # wait for the job to finish
d = datetime.datetime.now()
print('schedule: %s' % (b - a))
print('queue.wait: %s' % (c - b))
print('build.wait: %s' % (d - c))
assert len(job.builds) == 1
assert job.lastBuild.succeeded
print(job.lastBuild.duration)
job._configuration.buildSteps[0] = 'false'
assert job.start().failed
assert len(job.builds) == 2
job.delete()
assert name not in host.jobs()