Example #1
0
    def test_priority(self, available_mocks):
        new_order = [NetplanActivator, NetworkManagerActivator]
        resp = search_activator(priority=new_order)
        assert resp == new_order

        activator = select_activator(priority=new_order)
        assert activator == new_order[0]
Example #2
0
    def test_none_available(self, unavailable_mocks):
        resp = search_activator()
        assert resp == []

        with pytest.raises(RuntimeError):
            select_activator()
Example #3
0
 def test_priority_not_exist(self, available_mocks):
     with pytest.raises(ValueError):
         search_activator(priority=['spam', 'eggs'])
     with pytest.raises(ValueError):
         select_activator(priority=['spam', 'eggs'])
Example #4
0
    def test_first_not_available(self, m_available, available_mocks):
        resp = search_activator()
        assert resp == DEFAULT_PRIORITY[1:]

        resp = select_activator()
        assert resp == DEFAULT_PRIORITY[1]
Example #5
0
    def test_target(self, available_mocks):
        search_activator(target='/tmp')
        assert '/tmp' == available_mocks.m_which.call_args[1]['target']

        select_activator(target='/tmp')
        assert '/tmp' == available_mocks.m_which.call_args[1]['target']
Example #6
0
    def test_defaults(self, available_mocks):
        resp = search_activator()
        assert resp == DEFAULT_PRIORITY

        activator = select_activator()
        assert activator == DEFAULT_PRIORITY[0]
Example #7
0
    def test_none_available(self, unavailable_mocks):
        resp = search_activator()
        assert resp == []

        with pytest.raises(NoActivatorException):
            select_activator()
Example #8
0
    def test_target(self, available_mocks):
        search_activator(target="/tmp")
        assert "/tmp" == available_mocks.m_which.call_args[1]["target"]

        select_activator(target="/tmp")
        assert "/tmp" == available_mocks.m_which.call_args[1]["target"]