예제 #1
0
class ApiBridge(object):
    def __init__(self):
        # client = interop.Client(url='http://172.17.0.1:8000', username='******',password='******')
        # missions = client.get_missions()
        # print(missions)
        # stationary_obstacles, moving_obstacles = client.get_obstacles()
        # print(stationary_obstacles, moving_obstacles)
        server = os.getenv('TEST_INTEROP_SERVER', 'http://localhost:8000')
        username = os.getenv('TEST_INTEROP_USER', 'testuser')
        password = os.getenv('TEST_INTEROP_USER_PASS', 'testpass')
        admin_username = os.getenv('TEST_INTEROP_ADMIN', 'testadmin')
        admin_password = os.getenv('TEST_INTEROP_ADMIN_PASS', 'testpass')
        """Create a logged in Client."""
        # Create an admin client to clear cache.
        self.admin_client = Client(server, admin_username, admin_password)
        self.admin_client.get('/api/clear_cache')
        # Test rest with non-admin clients.
        self.client = Client(server, username, password)
        self.async_client = AsyncClient(server, username, password)

    def getObsta(self):
        """Test getting missions."""
        async_future = self.async_client.get_obstacles()
        async_stationary, async_moving = async_future.result()
        return async_stationary, async_moving

    def getMis(self):
        """Test getting missions."""
        # missions = self.client.get_missions()
        async_missions = self.async_client.get_missions().result()
        return async_missions
예제 #2
0
def myfunc():
    server = os.getenv('TEST_INTEROP_SERVER', 'http://localhost:8000')
    username = os.getenv('TEST_INTEROP_USER', 'testuser')
    password = os.getenv('TEST_INTEROP_USER_PASS', 'testpass')
    admin_username = os.getenv('TEST_INTEROP_ADMIN', 'testadmin')
    admin_password = os.getenv('TEST_INTEROP_ADMIN_PASS', 'testpass')
    admin_client = Client(server, admin_username, admin_password)
    admin_client.get('/api/clear_cache')
    async_client = AsyncClient(server, username, password)
    async_missions = async_client.get_missions().result()
    return async_missions
예제 #3
0
server = os.getenv('TEST_INTEROP_SERVER', 'http://localhost:8000')
username = os.getenv('TEST_INTEROP_USER', 'testuser')
password = os.getenv('TEST_INTEROP_USER_PASS', 'testpass')
admin_username = os.getenv('TEST_INTEROP_ADMIN', 'testadmin')
admin_password = os.getenv('TEST_INTEROP_ADMIN_PASS', 'testpass')
"""Create a logged in Client."""
# Create an admin client to clear cache.
admin_client = Client(server, admin_username, admin_password)
admin_client.get('/api/clear_cache')

# Test rest with non-admin clients.
client = Client(server, username, password)
async_client = AsyncClient(server, username, password)
"""Test getting missions."""
missions = client.get_missions()
async_missions = async_client.get_missions().result()

# # Check one mission returned.
# self.assertEqual(1, len(missions))
# self.assertEqual(1, len(async_missions))
# # Check a few fields.
# self.assertTrue(missions[0].active)
# self.assertTrue(async_missions[0].active)
# self.assertEqual(1, missions[0].id)
# self.assertEqual(1, async_missions[0].id)
# self.assertEqual(38.14792, missions[0].home_pos.latitude)
# self.assertEqual(38.14792, async_missions[0].home_pos.latitude)

admin_client.get('/api/clear_cache')
"""Test getting obstacles."""
stationary, moving = client.get_obstacles()