Example #1
0
    def test_by_rolename_coordinator(self):
        callback = Mock()
        callback.side_effect = self.assert_is_coordinator(self.TEST_ROLEDEFS)
        env.roledefs = self.TEST_ROLEDEFS

        env.host = 'worker0'
        fabricapi.by_rolename(env.host, 'coordinator', callback)
        self.assertFalse(callback.called)

        env.host = 'coordinator'
        fabricapi.by_rolename(env.host, 'coordinator', callback)
        self.assertTrue(callback.called)
Example #2
0
    def test_by_rolename_all(self):
        callback = Mock()
        env.roledefs = self.TEST_ROLEDEFS

        env.host = 'worker0'
        fabricapi.by_rolename(env.host, None, callback)
        self.assertTrue(callback.called)

        callback.reset_mock()

        env.host = 'coordinator'
        fabricapi.by_rolename(env.host, None, callback)
        self.assertTrue(callback.called)