Beispiel #1
0
 def test_getByIdentifier_returnsMatch(self):
     srv1 = Server()
     srv1.Path = '/path/to/gold'
     srv2 = Server()
     srv2.Path = '/not/the/answer'
     manager._servers = [srv1, srv2]
     result = manager.get_server_by_identifier(srv1.Path)
     self.assertEqual(srv1, result)
Beispiel #2
0
 def test_getByIdentifier_returnsNoneIfNoMatch(self):
     srv1 = Server()
     srv1.Path = '/path/to/gold'
     srv2 = Server()
     srv2.Path = '/not/the/answer'
     self.plant_server([srv1, srv2])
     result = manager.get_server_by_identifier('bruh')
     self.assertIsNone(result)
Beispiel #3
0
 def test_update_writesChangesToMemory(self):
     srv1 = Server()
     srv1.Path = '/road/to/riches'
     srv2 = Server()
     srv2.Path = '/another/one'
     srv_updated = Server()
     srv_updated.Path = '/road/to/owning a home'
     self.plant_server([srv1, srv2])
     manager.update_server('/road/to/riches', srv_updated)
     self.assertIn(srv_updated, manager._servers)
Beispiel #4
0
    def test_scan_removesDeletedServers(self, mock_register, mock_print,
                                        mock_is_forge):
        # Create two servers, but only keep 1 of them on disk
        srv_stays = Server()
        srv_stays.Path = '/srvs/creative1'
        srv_stays.Type = FORGE
        srv_delete = Server()
        srv_delete.Path = '/srvs/creative2'
        srv_delete.Type = FORGE
        self.fs.create_dir(srv_stays.Path)

        manager._servers = [srv_stays, srv_delete]
        result = manager.scan_directory_for_servers(scan_path='/srvs/',
                                                    verbosity=1)
        mock_register.assert_called_once_with(srv_stays.Path, FORGE)
        mock_print.assert_called_with('Found 1 servers')
        self.assertEqual(1, result)