Пример #1
0
    def test_register_does_not_call_setitem_when_no_second_argument(self):
        c = MedleyContainer()
        provider = Mock(register=Mock())

        with patch.object(c, '__setitem__') as setitem:
            c.register(provider)
            setitem.assert_not_called()
Пример #2
0
    def test_register_sets_ids_from_second_argument(self):
        c = MedleyContainer()
        provider = Mock(register=Mock())

        with patch.object(c, '__setitem__') as setitem:
            c.register(provider, {
                'foo': self.foo,
                'bar': self.bar,
                'baz': self.baz
            })

            self.assertEqual(setitem.call_count, 3)
Пример #3
0
    def test_register_returns_c(self):
        c = MedleyContainer()
        provider = Mock(register=Mock())

        self.assertEqual(c.register(provider), c)
Пример #4
0
    def test_register_calls_provider_register(self):
        c = MedleyContainer()
        provider = Mock(register=Mock())

        c.register(provider)
        provider.register.assert_called_with(c)