Exemplo n.º 1
0
    def test_restore(self):
        """Restore a project."""

        factory = stubs.Factory()
        fp = filepath.FilePath(self.mktemp())
        fp.setContent(CONFIG1)
        config = configfile.ConfigFile()
        config.restore(factory, fp)
        self.assertIsNotNone(factory.get_brick_by_name("sender"))
Exemplo n.º 2
0
    def test_save(self):
        """Save a project."""

        factory = stubs.Factory()
        factory.new_brick("switch", "sw")
        fp = filepath.FilePath(self.mktemp())
        config = configfile.ConfigFile()
        config.save(factory, fp)
        self.assertEqual(fp.getContent(), "[Switch:sw]\n\n")
 def test_restore(self):
     """Restore a project."""
     #NB -> Twisted FilePath returns files opened in binary mode
     factory = stubs.Factory()
     fp = filepath.FilePath(self.mktemp())
     fp.setContent(file_bytes_from_text(CONFIG1))
     config = configfile.ConfigFile()
     config.restore(factory, fp)
     self.assertIsNotNone(factory.get_brick_by_name("sender"))
Exemplo n.º 4
0
 def test_config_resume(self):
     self.factory.del_brick(self.vm)
     self.assertEqual(len(self.factory.bricks), 0)
     sio = StringIO.StringIO(HOSTONLY_CONFIG)
     configfile.ConfigFile().restore_from(self.factory, sio)
     self.assertEqual(len(self.factory.bricks), 1)
     vm1 = self.factory.get_brick_by_name("vm")
     self.assertEqual(len(vm1.plugs), 1)
     plug = vm1.plugs[0]
     self.assertEqual(plug.mac, "00:11:22:33:44:55")
     self.assertIs(plug.sock, vm.hostonly_sock)
Exemplo n.º 5
0
 def test_config_save(self):
     sio = StringIO.StringIO()
     configfile.ConfigFile().save_to(self.factory, sio)
     self.assertEqual(sio.getvalue(), HOSTONLY_CONFIG)