예제 #1
0
 def test_load_protocols_fails_on_repeated_protocol(self):
     register_protocols('mock')(MockCabinet)
     protocols = {}
     cabinets.plugins.load_to_cache(MockCabinet, protocols,
                                    cabinets.Cabinet)
     with self.assertRaises(cabinets.plugins.CabinetsPluginError):
         cabinets.plugins.load_to_cache(MockCabinet, protocols,
                                        cabinets.Cabinet)
예제 #2
0
 def test_load_protocols(self):
     register_protocols('mock')(MockCabinet)
     protocols = {}
     cabinets.plugins.load_to_cache(MockCabinet, protocols,
                                    cabinets.Cabinet)
     self.assertDictEqual(protocols, {'mock': MockCabinet})
예제 #3
0
 def test_register_protocols_fails_on_attempt_to_register_instance(self):
     with self.assertRaises(CabinetError) as err:
         register_protocols('mock')(42)
     self.assertIn('must be a class', str(err.exception))
예제 #4
0
 def test_register_protocols_fails_on_parser_subclass_check(self):
     with self.assertRaises(CabinetError) as err:
         register_protocols('mock')(MockParser)
     self.assertIn('not a subclass', str(err.exception))
예제 #5
0
 def test_register_protocols_fails_on_double_register(self):
     with self.assertRaises(CabinetError):
         _ = register_protocols('mock')(MockCabinet)
         _ = register_protocols('mock')(MockCabinet)
예제 #6
0
 def test_register_protocols_succeeds(self):
     cls = register_protocols('mock')(MockCabinet)
     self.assertIs(cls, MockCabinet)
     self.assertIn('mock', MockCabinet._protocols)