#!/usr/bin/env python

from __future__ import print_function
from framework.tests.world import WorldHttpTest
from httpcommand import OHObjectTest
import os.path, random, socket

class ProximityTest(WorldHttpTest):
    script_paths = [ os.path.dirname(__file__) ]

class OneSS(object):
    '''
    Mixin to specify 1 space server, 1 OH
    '''

    services = [
        {
            'name' : 'space',
            'type' : 'space',
            'args' : lambda x: x.spaceArgs(),
            'wait' : False
            },
        {
            'name' : 'oh',
            'type' : 'cppoh',
            'args' : lambda x: x.ohArgs(),
            'default' : True
            }
        ]

    # Random port to avoid conflicts
    port = random.randint(2000, 3000)

    def spaceArgs(self):
        return { 'servermap-options' : '--port=' + str(self.port) }

    def ohArgs(self):
        return {
            'servermap-options' : '--port=' + str(self.port),
            'object-factory-opts': '--db=not-a-real-db.db', # Disable loading objects from db
            'mainspace' : '12345678-1111-1111-1111-DEFA01759ACE'
            }

class OneManualSS(OneSS):
    '''
    Mixin to specify 1 space server using manual querying, 1 OH