def test_network_state_change(self):
        """Test the changes in the network connection."""
        nms = NetworkManagerState(self._listen_network_changes)
        nms._state_changed(2)
        nms._state_changed(0)  # 0 or anything other than 2
        nms._state_changed(2)

        self.assertEqual(self.network_changes, [ONLINE, OFFLINE, ONLINE])
 def test_cant_schedule_with_runloop(self):
     """SCNRScheduleWithRunLoop returning false -> callback gets UNKNOWN."""
     self.patch(darwin, "SCNRScheduleWithRunLoop", lambda _1, _2, _3: False)
     nms = NetworkManagerState(self.expect_unknown)
     nms._listen_on_separate_thread()
 def test_cant_set_callback(self):
     """SCNRSetCallback returning false -> callback gets UNKNOWN."""
     self.patch(darwin, "SCNRSetCallback", lambda _1, _2, _3: False)
     nms = NetworkManagerState(self.expect_unknown)
     nms._listen_on_separate_thread()
 def test_cant_create_target(self):
     """SCNRCreateWithName returning None -> callback gets UNKNOWN."""
     self.patch(darwin, "SCNRCreateWithName", lambda _1, _2: None)
     nms = NetworkManagerState(self.expect_unknown)
     nms._listen_on_separate_thread()