Coverage for tests/publisher/snaps/test_builds.py : 100%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1import unittest
4from webapp.publisher.snaps.builds import map_build_and_upload_states
7class TestBuildStateMapper(unittest.TestCase):
8 def test_build_state_mappings(self):
9 combinations = [
10 ("Needs building", "Unscheduled", "building_soon"),
11 ("Needs building", "Pending", "building_soon"),
12 ("Needs building", "Failed to upload", "building_soon"),
13 (
14 "Needs building",
15 "Failed to release to channels",
16 "building_soon",
17 ),
18 ("Needs building", "Uploaded", "building_soon"),
19 ("Successfully built", "Unscheduled", "wont_release"),
20 ("Successfully built", "Pending", "releasing_soon"),
21 ("Successfully built", "Failed to upload", "release_failed"),
22 (
23 "Successfully built",
24 "Failed to release to channels",
25 "release_failed",
26 ),
27 ("Successfully built", "Uploaded", "released"),
28 ("Currently building", "Unscheduled", "in_progress"),
29 ("Currently building", "Pending", "in_progress"),
30 ("Currently building", "Failed to upload", "in_progress"),
31 (
32 "Currently building",
33 "Failed to release to channels",
34 "in_progress",
35 ),
36 ("Currently building", "Uploaded", "in_progress"),
37 ("Failed to build", "Unscheduled", "failed_to_build"),
38 ("Failed to build", "Pending", "failed_to_build"),
39 ("Failed to build", "Failed to upload", "failed_to_build"),
40 (
41 "Failed to build",
42 "Failed to release to channels",
43 "failed_to_build",
44 ),
45 ("Failed to build", "Uploaded", "failed_to_build"),
46 ("Dependency wait", "Unscheduled", "failed_to_build"),
47 ("Dependency wait", "Pending", "failed_to_build"),
48 ("Dependency wait", "Failed to upload", "failed_to_build"),
49 (
50 "Dependency wait",
51 "Failed to release to channels",
52 "failed_to_build",
53 ),
54 ("Dependency wait", "Uploaded", "failed_to_build"),
55 ("Chroot problem", "Unscheduled", "failed_to_build"),
56 ("Chroot problem", "Pending", "failed_to_build"),
57 ("Chroot problem", "Failed to upload", "failed_to_build"),
58 (
59 "Chroot problem",
60 "Failed to release to channels",
61 "failed_to_build",
62 ),
63 ("Chroot problem", "Uploaded", "failed_to_build"),
64 ("Build for superseded Source", "Unscheduled", "failed_to_build"),
65 ("Build for superseded Source", "Pending", "failed_to_build"),
66 (
67 "Build for superseded Source",
68 "Failed to upload",
69 "failed_to_build",
70 ),
71 (
72 "Build for superseded Source",
73 "Failed to release to channels",
74 "failed_to_build",
75 ),
76 ("Build for superseded Source", "Uploaded", "failed_to_build"),
77 ("Failed to upload", "Unscheduled", "failed_to_build"),
78 ("Failed to upload", "Pending", "failed_to_build"),
79 ("Failed to upload", "Failed to upload", "failed_to_build"),
80 (
81 "Failed to upload",
82 "Failed to release to channels",
83 "failed_to_build",
84 ),
85 ("Failed to upload", "Uploaded", "failed_to_build"),
86 ("Cancelling build", "Unscheduled", "cancelled"),
87 ("Cancelling build", "Pending", "cancelled"),
88 ("Cancelling build", "Cancelling build", "cancelled"),
89 (
90 "Cancelling build",
91 "Failed to release to channels",
92 "cancelled",
93 ),
94 ("Cancelling build", "Uploaded", "cancelled"),
95 ("Cancelled build", "Unscheduled", "cancelled"),
96 ("Cancelled build", "Pending", "cancelled"),
97 ("Cancelled build", "Cancelled build", "cancelled"),
98 (
99 "Cancelled build",
100 "Failed to release to channels",
101 "cancelled",
102 ),
103 ("Cancelled build", "Uploaded", "cancelled"),
104 ("Failed to upload", "Unscheduled", "failed_to_build"),
105 ("Failed to upload", "Pending", "failed_to_build"),
106 ("Failed to upload", "Failed to upload", "failed_to_build"),
107 (
108 "Failed to upload",
109 "Failed to release to channels",
110 "failed_to_build",
111 ),
112 ("Failed to upload", "Uploaded", "failed_to_build"),
113 ]
115 for build_state, upload_state, expected in combinations:
116 result = map_build_and_upload_states(build_state, upload_state)
117 self.assertEqual(result, expected)