~dpb/pyjuju/dont-proxy-https

« back to all changes in this revision

Viewing changes to juju/state/tests/test_errors.py

Subordinate support in unit agent lifecycle [r=kapil] [f=805585,963355]

This branch lands the support in the unit agent which allows it to deploy 
subordinate services in its own container.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
    ServiceUnitResolvedAlreadyEnabled, ServiceUnitUpgradeAlreadyEnabled,
18
18
    ServiceUnitRelationResolvedAlreadyEnabled, PrincipalNotFound,
19
19
    RelationBrokenContextError, PrincipalServiceUnitRequired,
20
 
    UnitMissingContainer, SubordinateUsedAsContainer, InvalidRelationIdentity)
 
20
    NotSubordinateCharm, UnitMissingContainer, SubordinateUsedAsContainer,
 
21
    InvalidRelationIdentity, UnsupportedSubordinateServiceRemoval,
 
22
    IllegalSubordinateMachineAssignment)
21
23
 
22
24
 
23
25
class StateErrorsTest(TestCase):
241
243
        error = PrincipalServiceUnitRequired("lard", 1)
242
244
        self.assertIsStateError(error)
243
245
        self.assertEquals(str(error),
244
 
                          "Expected principal service unit as container for lard instance, got 1")
 
246
                          "Expected principal service unit as container for "
 
247
                          "lard instance, got 1")
245
248
 
246
249
    def test_subordinate_used_as_container(self):
247
250
        error = SubordinateUsedAsContainer("lard", "blubber/0")
248
251
        self.assertIsStateError(error)
249
252
        self.assertEquals(str(error),
250
 
                          "Attempted to assign unit of lard to subordinate blubber/0")
 
253
                          "Attempted to assign unit of lard "
 
254
                          "to subordinate blubber/0")
 
255
 
 
256
    def test_not_subordinate_charm(self):
 
257
        error = NotSubordinateCharm("lard", "blubber/0")
 
258
        self.assertIsStateError(error)
 
259
        self.assertEquals(str(error),
 
260
                          "lard cannot be used as subordinate to blubber/0")
 
261
 
 
262
    def test_unsupported_subordinate_service_removal(self):
 
263
        error = UnsupportedSubordinateServiceRemoval("lard", "blubber")
 
264
        self.assertIsStateError(error)
 
265
        self.assertEquals(str(error),
 
266
                          "Unsupported attempt to destroy subordinate "
 
267
                          "service 'lard' while principal service "
 
268
                          "'blubber' is related.")
251
269
 
252
270
    def test_invalid_relation_ident(self):
253
271
        error = InvalidRelationIdentity("invalid-id$forty-two")
254
272
        self.assertTrue(isinstance(error, JujuError))
255
273
        self.assertTrue(isinstance(error, ValueError))
256
274
        self.assertEquals(
257
 
            str(error), 
 
275
            str(error),
258
276
            "Not a valid relation id: 'invalid-id$forty-two'")
 
277
 
 
278
    def test_illegal_subordinate_machine_assignment(self):
 
279
        error = IllegalSubordinateMachineAssignment("blubber/1")
 
280
        self.assertTrue(isinstance(error, JujuError))
 
281
        self.assertEquals(
 
282
            str(error),
 
283
            "Unable to assign subordinate blubber/1 to machine.")