Exemple #1
0
def run_gui():
    receiver_port = sys.argv[1]
    app = QApplication(sys.argv)
    ex = App(receiver_port)
    ex.show()
    app.exec_()
    print('[GUI] GUI closed')
Exemple #2
0
    def test_main_diff(self, sync_mock, teamleader_client_mock, *models_mock):
        app = App()
        app.teamleader_sync(full_sync=False)

        assert sync_mock.call_count == 1
        call_arg = sync_mock.call_args[1]
        assert call_arg['full_sync'] is False
Exemple #3
0
class AppTests(TestCase):
    """
    Test App.
    """
    def setUp(self):
        self.app = App()

    def test_run(self):
        """
        Test the run code.
        """
        args = []
        if self.app.TYPE == 'ds':
            args.append(
                'inputdir')  # you may want to change this inputdir mock
        args.append('outputdir')  # you may want to change this outputdir mock

        # you may want to add more of your custom defined optional arguments to test
        # your app with
        # eg.
        # args.append('--custom-int')
        # args.append(10)

        options = self.app.parse_args(args)
        self.app.run(options)

        # write your own assertions
        self.assertEqual(options.outputdir, 'outputdir')
    def test_program_cleanup_mqtt(self, mqttclientmock):
        app = App(cfg='cfg', pid='pid', nodaemon=False)

        app.mqttclient = mqttclientmock

        app.close_resources()

        mqttclientmock.close.assert_called_with()
    def test_program_cleanup_engine(self, enginemock):
        app = App(cfg='cfg', pid='pid', nodaemon=False)

        app.engine = enginemock

        app.close_resources()

        enginemock.close.assert_called_with()
Exemple #6
0
def main(stdscr):
    app = App(stdscr)

    app.add_window(Window(30, 10, "Window one").move_to(3, 1))
    app.add_window(Window(30, 10, "Window two").move_to(10, 7))
    app.add_window(Window(30, 10, "Window three").move_to(17, 13))

    app.start()
Exemple #7
0
	def start(self):
		self.log.print("validating wifi credentials...","OK")
		while True:
			if(self.manage_wifi()):
				break
		self.log.print("Configuration complete...","OK")
		self.log.print("Starting new instance of the app...","OK")
		app=App(CONFIG['app_name'],CONFIG['app_key'],CONFIG['app_version'])
		app.start()
Exemple #8
0
def _delete_holding():
    app = App(DATA_STORE_FILENAME)
    try:
        ticker = request.form['ticker'].upper()
        app.remove_holding(ticker)
        return Response('', status=204)
    except ValueError:
        abort(404)
    except OSError as e:
        abort(500)
Exemple #9
0
def _add_holding():
    app = App(DATA_STORE_FILENAME)
    try:
        ticker, units = request.form['ticker'].upper(), int(request.form['units'])
        app.add_holding(ticker, units)
        return Response('', status=201)
    except ValueError:
        abort(400)
    except OSError as e:
        abort(500)
def run_app():
    #initialize our app class with empty values for taxon and protein as we will set these after we decide what the user wishes to run and what advanced settings will be changed before setting taxon and protein query. The classes need to beinitialized in order to save any changes to the state
    app = App("", "")
    #here, the welcome information is printed, a list of what the user may want to run is displayed and features can be turned on or off, or advanced settings like bootstrapping, esearch retmax, max accessions processed can all be tweaked. Handler.path_list booleans are turned on or off here which will be used to navigate the program's steps in handle()
    handler = Handler.welcome(app)
    #have the user assign their taxon and protein choices, user input for this is handled in the user_input class
    app.taxon_query = "taxonomy"
    app.protein_query = "protein"
    #run the function above with our basal set parameters
    handle(app, handler)
    def test_readConfig_fileread_noname(self, configparsermock, grpmock):
        app = App(cfg='cfg', pid='pid', nodaemon=True)

        instance = configparsermock.return_value

        grpmock.getgrnam.return_value(('name', 'passwd', 1, 'users'))

        app.readConfig(None)

        instance.read.assert_called_with('mqtt_db_gateway.ini')
Exemple #12
0
class Worker:
    def __init__(self):
        self.teamleader_running = False
        self.sync_app = SyncApp()

    @property
    def app(self):
        return self.sync_app

    def teamleader_job(self, full_sync):
        self.teamleader_running = True
        self.sync_app.teamleader_sync(full_sync)
        self.teamleader_running = False
Exemple #13
0
def acMain(ac_version):
	try:
		global ov1_info
		# initialize the app
		ov1_info = App()
		# create the app objects
		ov1_info.start_up()
		# add render callback
		ov1_info.window.onRenderCallback(onFormRender)
		# return the app's ID
		return "OV1Info"
	
	except Exception as e:
		ac.console("OV1: Error in function acMain(): %s" % e)
		ac.log("OV1: Error in function acMain(): %s" % e)
Exemple #14
0
    def test_no_yaml(self):
        """Testing that a new config.yaml gets created if it isn't present
        """
        path = '{}/tests/dirs/test_no_yaml'.format(os.getcwd())
        conf_path = '{}/config.yaml'.format(path)

        # remove any present config file at path
        try:
            os.remove(conf_path)
        except:
            pass

        # create directory path if non existent
        try:
            os.makedirs(path)
        except OSError:
            print('Could not make directories')

        # move to create directory path
        try:
            os.chdir(path)
        except OSError:
            print('Could not change path to {}'.path)

        # run __init__ with no config file
        app = App()
        self.assertTrue(os.path.isfile(conf_path))

        test_dict = {}
        with open(conf_path, 'r') as handle:
            test_dict = yaml.full_load(handle)

        self.assertEqual(test_dict['yaml_path'], conf_path)
        self.assertEqual(test_dict['root'], os.getcwd())
Exemple #15
0
class CsvWorker:
    def __init__(self):
        self.export_running = False
        self.last_export = 'Please run an export first with POST /export/export_csv'
        self.sync_app = SyncApp()

    @property
    def app(self):
        return self.sync_app

    def export_job(self):
        self.export_running = True
        self.last_export = 'New contacts export to csv is in progress...'
        self.sync_app.export_csv()
        self.export_running = False
        self.last_export = datetime.now().isoformat()
Exemple #16
0
def app(request):

    global browser

    if browser is None:
        browser = App()

    # if server == 'stage':
    #     browser.wd.get('http://*****:*****@stage.restaurantsupply.com')

    if is_logged == True:
        get(base_url)
        browser.index_page.login()
        sleep(
            3
        )  # значение подгружается через какое-то время, а не при открытии страницы
        if int(browser.index_page.cart_counter_number.text) > 0:
            browser.cart_page.empty_cart()

    def fin():
        global browser
        browser.destroy()
        browser = None

    request.addfinalizer(fin)
    return browser
def main():
    parser = argparse.ArgumentParser(description="MQTT DB gateway")

    parser.add_argument('method', choices=['start', 'stop', 'reload'])

    parser.add_argument("--cfg", dest="cfg", action="store",
                        default="/etc/mqtt_db_gateway/mqtt_db_gateway.ini",
                        help="Full path to configuration")

    parser.add_argument("--pid", dest="pid", action="store",
                        default="/var/run/mqtt_db_gateway/mqtt_db_gateway.pid",
                        help="Full path to PID file")

    parser.add_argument("--nodaemon", dest="nodaemon", action="store_true",
                        help="Do not daemonize, run in foreground")

    parsed_args = parser.parse_args()

    if parsed_args.method == 'stop':
        Daemon.stop(parsed_args.pid)

    elif parsed_args.method == 'start':
        app = App(
            cfg=parsed_args.cfg,
            pid=parsed_args.pid,
            nodaemon=parsed_args.nodaemon
        )
        Daemon.start(app)

    elif parsed_args.method == 'reload':
        Daemon.reload(parsed_args.pid)
Exemple #18
0
class AppTestCase(TestCase):
    def setUp(self) -> None:
        self.app = App()

    @unittest.mock.patch('pygame.event.get', return_value=[EventMother.quit()])
    def test_app_should_run_and_stop_when_quit(self, event_mock):
        self.assertEqual(0, self.app.run())
 def test_authcode_callback_invalid(self, mock_requests, mock_auth_table,
                                    *models):
     ma = mock_auth_table.return_value
     ma.count.return_value = 0
     app = App()
     result = app.tlc.authcode_callback('auth_code', 'wrong_state')
     assert result == 'code rejected'
def predictor():
    ''''
    Receives the file to be classified. It translates to another unique name.
    '''
    filename = request.args.get('filename')
    image_path = os.path.join(app.config['UPLOAD_FOLDER'], filename)
    message = App().predict(os.path.abspath(image_path))
    return render_template('prediction.html', label=message, filename=filename)
 def test_authcode_callback_valid(self, mock_requests, mock_auth_table,
                                  *models):
     ma = mock_auth_table.return_value
     ma.count.return_value = 0
     app = App()
     result = app.tlc.authcode_callback('auth_code',
                                        'code_to_validate_callback')
     assert result == 'code accepted'
Exemple #22
0
    def test_main_full(self, sync_mock, teamleader_client_mock, tl_auth_mock,
                       contacts_mock, companies_mock, departments_mock,
                       events_mock, invoices_mock, projects_mock, users_mock):
        # Mock max_last_modified_timestamp to return None
        companies_mock().max_last_modified_timestamp.return_value = None
        contacts_mock().max_last_modified_timestamp.return_value = None
        departments_mock().max_last_modified_timestamp.return_value = None
        events_mock().max_last_modified_timestamp.return_value = None
        invoices_mock().max_last_modified_timestamp.return_value = None
        projects_mock().max_last_modified_timestamp.return_value = None
        users_mock().max_last_modified_timestamp.return_value = None

        app = App()
        app.teamleader_sync(full_sync=True)

        assert sync_mock.call_count == 1
        call_arg = sync_mock.call_args[1]
        assert call_arg['full_sync'] is True
Exemple #23
0
 def _load_autoscaler_apps(self):
     apps = []
     for app in config['APPS']:
         try:
             apps.append(App(**app))
         except Exception as e:
             msg = "Could not load {}: The error was: {}".format(app, e)
             logging.critical(msg)
             raise CannotLoadConfig(msg)
     self.autoscaler_apps = apps
Exemple #24
0
class TestXueQiu:
    def setup_class(self):
        self.app = App()
        self.start = self.app.start()

    def test_xueqiu(self):
        ell = self.start.goto_main_app().goto_market().goto_search(
        ).search_input('阿里巴巴-SW').search_click('阿里巴巴-SW').optional(
            '阿里巴巴-SW').goto_toaset('阿里巴巴-SW')
        assert ell == True
    def test_readConfig_mandatorysection_daemon(self, configparsermock,
                                                grpmock, daemonmock,
                                                loggermock):
        app = App(cfg='cfg', pid='pid', nodaemon=False)

        daemonmock.is_open.return_value = True
        app.daemon = daemonmock

        instance = configparsermock.return_value

        grpmock.getgrnam.return_value(('name', 'passwd', 1, 'users'))

        def get_side_effect(section, key):
            if section == 'sqlalchemy' and key == 'uri':
                raise NoSectionError('Mandatory config test')
            else:
                return DEFAULT

        instance.get.side_effect = get_side_effect
        self.assertIsNone(app.readConfig(conf_file=None))
    def test_unauth_details(self, mock_requests, mock_auth_table, *models):
        ma = mock_auth_table.return_value
        ma.count.return_value = 0
        app = App()
        self.details_unauthorized = True
        self.resource_name = 'contacts'
        mock_requests.get = MagicMock(side_effect=self.mock_api_calls)

        result = app.tlc.request_item(f'/{self.resource_name}.info', 'uuid1')

        assert result == {'data': 'resource data here', 'id': 'uuid1'}
        assert not self.details_unauthorized
Exemple #27
0
    def test_good_root(self):
        '''Test
        '''
        path = '/home/smadonna/Downloads'
        app = App(path)
        self.assertEqual(App._config['root'], path)

        test_dict = {}
        with open('config.yaml', 'r') as handle:
            test_dict = yaml.full_load(handle)
        self.assertEqual(test_dict['root'], path)

        self.assertEqual(os.getcwd(), path)
    def test_unauth_listing(self, mock_requests, mock_auth_table, *models):
        ma = mock_auth_table.return_value
        ma.count.return_value = 0
        app = App()
        self.list_unauthorized = True
        self.resource_name = 'contacts'
        mock_requests.get = MagicMock(side_effect=self.mock_api_calls)

        result = app.tlc.request_page(f'/{self.resource_name}.list', 1, 20,
                                      None)

        assert result == [{'id': 'uuid1'}]
        assert not self.list_unauthorized
    def test_current_user(self, mock_requests, mock_auth_table, *models):
        ma = mock_auth_table.return_value
        ma.count.return_value = 0
        app = App()
        # mock requests.get so that api call returns something we want
        user_data = {'data': {'name': 'current_user'}}
        mresp = Mock()
        mock_requests.get.return_value = mresp
        mresp.status_code = 200
        mresp.json.return_value = user_data
        result = app.tlc.current_user()

        assert mresp.json.call_count == 1
        assert result == user_data['data']
    def test_custom_field_get(self, mock_requests, mock_auth_table, *models):
        ma = mock_auth_table.return_value
        ma.count.return_value = 0
        app = App()
        # mock requests.get so that api call returns something we want
        field_data = {'data': {'id': 'uidhere'}}
        mresp = Mock()
        mock_requests.get.return_value = mresp
        mresp.status_code = 200
        mresp.json.return_value = field_data
        result = app.tlc.get_custom_field('uidhere')

        assert mresp.json.call_count == 1
        assert result == field_data['data']
    def test_custom_fields(self, mock_requests, mock_auth_table, *models):
        ma = mock_auth_table.return_value
        ma.count.return_value = 0
        app = App()
        # mock requests.get so that api call returns something we want
        fields_data = {'data': []}
        mresp = Mock()
        mock_requests.get.return_value = mresp
        mresp.status_code = 200
        mresp.json.return_value = fields_data
        fields = app.tlc.list_custom_fields()

        assert mresp.json.call_count == 1
        assert fields == fields_data['data']