Ejemplo n.º 1
0
    def test_retrieve_projects_data_update_after_scan_loop(self):
        pm.create_project("my_awesome_project", "beauty isn't it ?", 30,
                          "3280x2464")
        data = pm.get_projects_data()

        self.assertEqual(1, len(data))
        project = data[0]

        self.assertEqual('my_awesome_project', project["name"])
        self.assertIsNotNone(project["preview_data"])
        self.assertEqual('beauty isn\'t it ?', project['description'])
        self.assertEqual(30, project['pict_per_rotation'])
        self.assertEqual('3280x2464', project['pict_res'])
        self.assertEqual(0, project['size'])

        scanner = Scanner()

        scanner.loop_capture(project['name'])

        data = pm.get_projects_data()
        self.assertEqual(1, len(data))
        project_after = data[0]

        self.assertNotEqual(project_after['size'], project['size'])
        self.assertNotEqual(project_after['preview_data'],
                            project['preview_data'])
        # Data's are updated

        pm.__remove_all_projects__()
Ejemplo n.º 2
0
 def test_remove_project_2(self):
     pm.create_project('foo')
     pm.create_project('bar')
     self.assertCountEqual(['foo', 'bar'], pm.list_projects())
     pm.remove_single_project('foo')
     self.assertListEqual(['bar'], pm.list_projects())
     pm.__remove_all_projects__()
Ejemplo n.º 3
0
    def test_retrieve_projects_data(self):
        pm.create_project("test1")
        data = pm.get_projects_data()
        self.assertEqual(1, len(data))

        project = data[0]
        self.assertEqual('test1', project["name"])
        self.assertIsNotNone(project["preview_data"])
        self.assertEqual('', project['description'])
        self.assertEqual(15, project['pict_per_rotation'])
        self.assertEqual('1640x1232', project['pict_res'])
        self.assertEqual(0, project['size'])

        pm.__remove_all_projects__()
Ejemplo n.º 4
0
    def test_retrieve_projects_data_2(self):
        pm.create_project("my_awesome_project", "beauty isn't it ?", 30,
                          "3280x2464")
        data = pm.get_projects_data()
        self.assertEqual(1, len(data))

        project = data[0]
        self.assertEqual('my_awesome_project', project["name"])
        self.assertIsNotNone(project["preview_data"])
        self.assertEqual('beauty isn\'t it ?', project['description'])
        self.assertEqual(30, project['pict_per_rotation'])
        self.assertEqual('3280x2464', project['pict_res'])
        self.assertEqual(0, project['size'])

        pm.__remove_all_projects__()
Ejemplo n.º 5
0
async def mainLoop(websocket, path):
    """
    Main loop that catch entry message given by users
    Send back a response, ex after a scan loop we send projects data
    :param websocket: websocket used for external communication (client)
    """
    await register(websocket)
    try:
        #await send_project_data_users()

        async for message in websocket:
            data = json.loads(message)
            logger.info("Message received : %s", str(data))

            if data['action'] == 'loop_capture':
                scanner.loop_capture(data['project_name'])
                await send_state_data()

            elif data['action'] == 'create_project':
                pm.create_project(data['project_name'], data['description'],
                                  data['pict_per_rotation'], data['pict_res'])
                await send_state_data()

            elif data['action'] == 'turn_bed_CW':
                angle = float(data['plateau_degree'])
                scanner.turn_bed(angle)
                await send_state_data()

            elif data['action'] == 'turn_bed_CCW':
                angle = float(data['plateau_degree'])
                scanner.turn_bed(-1 * angle)
                await send_state_data()

            elif data['action'] == 'request_project_info':
                await websocket.send(pm.get_projects_data())

            elif data['action'] == 'request_upload_email_project':
                project_name = data['project_name']
                email_to = data['email_to']
                pm.zip_project(project_name)

                upload.send_email_zip_project(project_name, email_to)
                await send_state_data()

            elif data['action'] == 'request_remove_project':
                project_name = data['project_name']
                pm.remove_single_project(project_name)
                await send_state_data()

            elif data['action'] == 'request_zip_data':
                project_name = data["project_name"]
                pm.zip_project(project_name)
                await send_download_ready(project_name)

            elif data['action'] == 'camera_preview':
                data = scanner.get_preview_capture()
                msg = {'type': 'camera_preview', 'data': data}
                await websocket.send(json.dumps(msg))

            else:
                logger.error("unsupported event: {}", data)

    finally:
        await unregister(websocket)
Ejemplo n.º 6
0
 def test_multiple_project_same_name(self):
     pm.create_project('foo')
     pm.create_project('foo')
     pm.create_project('foo')
     self.assertCountEqual(['foo', 'foo_1', 'foo_2'], pm.list_projects())
     pm.__remove_all_projects__()
Ejemplo n.º 7
0
 def test_multiple_project(self):
     pm.create_project('foo')
     pm.create_project('bar')
     self.assertCountEqual(['foo', 'bar'], pm.list_projects())
     pm.__remove_all_projects__()
Ejemplo n.º 8
0
 def test_remove_project(self):
     pm.create_project('foo')
     self.assertListEqual(['foo'], pm.list_projects())
     pm.remove_single_project('foo')
     self.assertListEqual([], pm.list_projects())
Ejemplo n.º 9
0
 def test_single_project(self):
     pm.create_project('test')
     self.assertListEqual(['test'], pm.list_projects())
     pm.__remove_all_projects__()
     self.assertCountEqual([], pm.list_projects())