Exemplo n.º 1
0
    def test_raw_returns_function_when_exists(self):
        c = MedleyContainer()
        c._keys = Mock()
        c._keys.__contains__ = Mock(return_value=True)
        c._raw = {'foo': self.foo}

        self.assertEqual(c.raw('foo'), self.foo)
Exemplo n.º 2
0
    def test_raw_returns_raw_function_from_values_attr_when_it_does_not_exist_in_raw_attr(
            self):
        c = MedleyContainer()
        c._keys = Mock()
        c._keys.__contains__ = Mock(return_value=True)
        c._raw = Mock()
        c._raw.__contains__ = Mock(return_value=False)
        c._values = {'foo': self.foo}

        self.assertEqual(c.raw('foo'), self.foo)

        c._keys.__contains__.assert_called_with('foo')
        c._raw.__contains__.assert_called_with('foo')
Exemplo n.º 3
0
    def test_raw_throws_error_when_service_id_does_not_exist(self):
        c = MedleyContainer()
        c._keys = Mock(__contains__=Mock(return_value=False))

        with self.assertRaises(Exception):
            c.raw('foo')