コード例 #1
0
class TestUserAuthentication(unittest.TestCase):
    """
    Class to test the user authentication, both the registration
    and login.
    """

    def setUp(self):
        self.user = User('jokamjohn', '123456', 'John')
        self.app = Application()

    def test_user_is_added_to_dictionary_when_created(self):
        self.assertTrue(self.app.register_user(User('jokam', '123456', 'John')))

    def test_user_already_exists_in_user_dictionary(self):
        self.app.users = {'jokamjohn': self.user}
        self.assertFalse(self.app.register_user(self.user))

    def test_user_sigining_in_is_already_registered(self):
        self.app.users = {'jokamjohn': self.user}
        self.assertTrue(self.app.does_user_exist('jokamjohn'))

    def test_user_trying_to_login_has_entered_a_correct_password(self):
        self.app.users = {'jokamjohn': self.user}
        self.assertTrue(self.app.login_user('jokamjohn', '123456'))

    def test_user_trying_to_login_has_entered_a_wrong_password(self):
        self.app.users = {'jokamjohn': self.user}
        self.assertFalse(self.app.login_user('jokamjohn', 'sdfgdsfj'))
コード例 #2
0
ファイル: main.py プロジェクト: spyc/elearn-api
def main():
    tornado.options.parse_command_line()
    app = Application()
    app.load()
    server = HTTPServer(app)
    server.listen(3000, '127.0.1.4')
    tornado.ioloop.IOLoop.current().start()
コード例 #3
0
ファイル: runner.py プロジェクト: haoleism/gui-demo
def run_widget(widget):
    import sys
    import traceback
    import compile_ui
    compile_ui.ui()
    compile_ui.resource()
    app = Application(sys.argv, widget)
    sys.excepthook = traceback.print_exception
    sys.exit(app.exec_())
コード例 #4
0
def main():
    app = Application(sys.argv)
    try:
        rc = app.exec_()
    except Exception:
        rc = 1
    finally:
        stop_event.set()
        print("set stop_event")
        sys.exit(rc)
コード例 #5
0
def before_scenario(context, scenario):

    caps = {
        "platformName": "Android",
        "platformVersion": "10",
        "deviceName": "Android Emulator",
        "app": Application.app_dir()
    }

    context.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_capabilities=caps)
    context.app = Application(context.driver)
コード例 #6
0
def main():
    """Method used to set the game output to either terminal or PyGame."""

    choice = {"1": "cli", "2": "pygame"}
    output = input(
        "How do you want to play the game?\n1: Terminal\n2: PyGame\nChoice: ")

    if output not in choice:
        main()
    else:
        app = Application(choice[output])
        app.run()
コード例 #7
0
class PolyInf:
    def __init__(self, args):
        self.app = Application(args)
        self.start()

    def __managers(self) -> List[Manager]:
        return [
            PluginManager(self.app),
            AuthManager(self.app),
        ]

    def start(self) -> int:
        self.__bind()
        self.__boot_managers()
        self.app.start()

    def __boot_managers(self) -> None:
        for manager in self.__managers():
            manager.call_booting_callbacks()
            manager.boot()
            manager.call_booted_callbacks()
            self.app.bind('managers', manager)

    def __bind(self) -> None:
        self.app.bind('loggers', SimpleLogger())
        self.app.bind('parsers', MetaParser('meta/create-migration.sql', True))
コード例 #8
0
def apply_now():
    form = ApplicationForm()
    if form.validate_on_submit():
        # TODO: Save the form to db
        application = Application(
            provider=int(form.provider.data),
            first_name=form.first_name.data,
            last_name=form.last_name.data,
            dob=form.dob.data,
            address=form.address.data,
            housing_type=form.housing_type.data,
            email=form.email.data,
            phone=form.phone.data,
            phone_type=form.phone_type.data,
            ssn=form.ssn.data,
            income=form.income.data,
            initial_purchase=form.initial_purchase_amt.data,
        )
        db.session.add(application)
        db.session.commit()
        flash('Your application has been submitted successfully.')
        return redirect(url_for('index'))
    # Default invalid provider ID (will get caught in form validation)
    provider = -1
    if 'provider' in request.args:
        provider = int(request.args['provider'])
    return render_template('apply.html',
                           form=form,
                           provider=provider,
                           title="Apply Now")
コード例 #9
0
ファイル: environment.py プロジェクト: olenaprokopiv/HOS247
def browser_init(context):
    """
    :param context: Behave context
    """
    chrome_options = webdriver.ChromeOptions()
    chrome_options.add_argument("--incognito")
    context.driver = webdriver.Chrome(chrome_options=chrome_options)

    # BrowserStack
    # desired_capabilities = {
    #     "os": "OS X",
    #     "os_version": "Catalina",
    #     "browser": "Safari",
    #     "browser_version": "13.0",
    #     "resolution": "1600x1200",
    #     "name": "Bstack-[Python] Sample Test"
    # }
    # desired_capabilities = {
    #      "os": "Windows",
    #      "os_version": "10",
    #      "browser": "Chrome",
    #      "browser_version": "80",
    #      "resolution": "1600x1200",
    #      "name": "Bstack-[Python] Sample Test Chrome 1"
    #  }

    # url = f"http://*****:*****@hub-cloud.browserstack.com/wd/hub"
    # context.driver = webdriver.Remote(url, desired_capabilities = desired_capabilities)
    # context.driver = EventFiringWebDriver(webdriver.Chrome(chrome_options=chrome_options), MyListner())

    context.driver.maximize_window()
    context.driver.implicitly_wait(5)
    context.app = Application(context.driver)
    context.wait = WebDriverWait(context.driver, 15)
コード例 #10
0
ファイル: server.py プロジェクト: DarkLuk42/hn-web-forum
def main():
    # Get current directory
    try:
        current_dir = os.path.dirname(os.path.abspath(__file__))
    except:
        import sys
        current_dir = os.path.dirname(os.path.abspath(sys.executable))
    # disable autoreload and timeout_monitor
    cherrypy.engine.autoreload.unsubscribe()
    cherrypy.engine.timeout_monitor.unsubscribe()
    # Static content config
    app = Application()
    static_config = {
        '/': {
            'tools.staticdir.root': current_dir,
            'tools.staticdir.on': True,
            'tools.staticdir.dir': './content',
            'tools.sessions.on': True,
            'tools.sessions.storage_type': "File",
            'tools.sessions.storage_path': './data/sessions',
            'tools.sessions.timeout': 10,
            'tools.encode.on': True,
            'tools.encode.encoding': "utf-8",
            'error_page.403': app.error_page_403,
            'error_page.404': app.error_page_404,
            'request.error_response': app.handle_error
        }
    }
    # Mount static content handler
    root_o = cherrypy.tree.mount(app, '/', static_config)
    # suppress traceback-info
    cherrypy.config.update({'request.show_tracebacks': False})
    # Start server
    cherrypy.engine.start()
    cherrypy.engine.block()
コード例 #11
0
 def get_app(self):
     return Application([
         (r"/api/v1/event-setting", EventSettingHandler,
          dict(
              auth_compare_func=lambda x, y: x == 'admin' and y == '123456',
              wechat_event_setting=self.wechat_event_setting))
     ])
コード例 #12
0
def app(request, config):
    global fixture
    browser = request.config.getoption("--browser")
    web_config = load_config(request.config.getoption("--target"))["web"]
    if fixture is None or not fixture.is_valid():
        fixture = Application(browser=browser, base_url=web_config['baseUrl'], config=config)
    return fixture
コード例 #13
0
 def get_app(self):
     return Application([
         (r"/api/v1/getAccessToken", TokenHandler,
          dict(wechat_access_token_provider=self.mock_provider,
               token_request_validator=live800.TokenRequestValidator(
                   'token')))
     ])
コード例 #14
0
 def create_app(self):
     app = Application.create({
         'database': 'sqlite://',
         'api_token': 'test-token',
     })
     app.config['TESTING'] = True
     return app
コード例 #15
0
def main():
    # options.logging = "warning"debug message
    # options.log_file_prefix = config.log_path
    tornado.options.parse_command_line()
    app = Application(urls, **config.settings)
    http_server = tornado.httpserver.HTTPServer(app)
    http_server.listen(options.port)
    tornado.ioloop.IOLoop.current().start()
コード例 #16
0
 def get_app(self):
     return Application([
         (r"/api/v1/menu", MenuHandler,
          dict(
              auth_compare_func=lambda x, y: x == 'admin' and y == '123456',
              wechat_client=self.mock_client,
              wechat_access_token_provider=self.mock_provider))
     ])
コード例 #17
0
def main(app: Application, view: Window):
    log = logging.getLogger(__name__)
    log.debug(STARTED)
    while True:
        log.debug(DRAWN(view))
        running_status = app.running()
        if running_status == 'done':
            break
コード例 #18
0
ファイル: test_phone_bill.py プロジェクト: crowleyfelix/olist
    def setUp(self):
        records = [fixtures.call_record_start(), fixtures.call_record_end()]

        service = services.build_call_record()
        for record in records:
            record["type"] = CallRecordType(record["type"])
            service.create(record)

        self.engine = Application.build_engine()
コード例 #19
0
def browser_init(context):
    """
    :param context: Behave context
    """
    context.driver = webdriver.Chrome()

    context.driver.maximize_window()
    context.driver.implicitly_wait(4)
    context.app = Application(context.driver)
コード例 #20
0
def before_scenario(context, scenario):
    desired_capabilities = {
        "deviceName": "Pixel 2 API 26",
        "platformName": "Android",
        "version": "8.0+",
        "app": "/Users/rubanenko.sergii/PycharmProjects/WikiApp/app_binary/Calculator.apk"
    }
    context.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_capabilities=desired_capabilities)
    context.driver.implicitly_wait(5)
    context.app = Application(context.driver)
コード例 #21
0
ファイル: environment.py プロジェクト: lleonova/Automation2
def browser_init(context):
    context.driver = webdriver.Chrome(executable_path='./chromedriver')
    # context.browser = webdriver.Safari()
    # context.browser = webdriver.Firefox(executable_path='./geckodriver')

    context.driver.maximize_window()
    context.driver.implicitly_wait(4)
    context.app = Application(context.driver)

    context.driver.wait = WebDriverWait(context.driver, 10)
コード例 #22
0
def before_scenario(context, scenario):

    desired_capabilities = {
        "platformName": "Android",
        "platformVersion": "9",
        "deviceName": "Android Emulator",
        "app": "/Users/dariasamarets/Workspace/Appium-Automation/Automate-Calculator/app_binaries/Calculator_v7.8 (271241277)_apkpure.com.apk",
    }
    context.driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", desired_capabilities=desired_capabilities)
    context.app = Application(context.driver)
    context.driver.implicitly_wait(10)
コード例 #23
0
 def setUp(self):
     """
     This method activates the flask testing config flag, which disables
     error catching during request handling.
     The testing client always provided an interface to the application.
     :return: 
     """
     app.testing = True
     self.app = app.test_client()
     self.application = Application()
     app.secret_key = "sdgsdgsjbdvskdxljvs"
コード例 #24
0
def browser_init(context):
    """
    :param context: Behave context
    """
    context.driver = webdriver.Chrome()
    # context.browser = webdriver.Safari()
    # context.browser = webdriver.Firefox()

    context.driver.maximize_window()
    context.app = Application(context.driver)
    context.driver.wait = WebDriverWait(context.driver, 15)
コード例 #25
0
def before_scenario(context, scenario):
    desired_capabilities = {
        "platformName": "Android",
        "platformVersion": "10",
        "deviceName": "Android Emulator",
        "app": "D:\\Projects\\BoxingTime\\app_binaries\\Boxing Timer.apk"
    }

    context.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_capabilities=desired_capabilities)
    context.driver.implicitly_wait(5)
    context.app = Application(context.driver)
コード例 #26
0
def browser_init(context):
    """
    :param context: Behave context
    """
    context.driver = webdriver.Chrome()
    # context.browser = webdriver.Safari()
    #context.driver = webdriver.Firefox(executable_path = 'C:\geckodriver\geckodriver.exe')
    context.driver.wait = WebDriverWait(context.driver, 25)

    context.driver.maximize_window()
    context.driver.implicitly_wait(5)
    context.app = Application(context.driver)
コード例 #27
0
def browser_init(context):
    """
    :param context: Behave context
    """
    context.driver = webdriver.Chrome(executable_path='C:\Vallikannu\Learning\Automation\Chromedriver\chromedriver.exe')
    # context.browser = webdriver.Safari()
    # context.browser = webdriver.Firefox()
    context.driver.maximize_window()
    context.driver.implicitly_wait(4)
    # context.driver.wait = WebDriverWait(context.driver, 15)

    context.app = Application(context.driver)
コード例 #28
0
def browser_init(context):
    """
    :param context: Behave context
    """
    context.driver = webdriver.Chrome(
        executable_path='/Users/romanshcherbakov/Downloads/chromedriver')
    # context.browser = webdriver.Safari()
    # context.browser = webdriver.Firefox()
    context.driver.maximize_window()
    context.driver.implicitly_wait(4)

    context.app = Application(context.driver)
コード例 #29
0
def browser_init(context):
    """
    :param context: Behave context
    """
    context.driver = webdriver.Chrome()

    context.driver.maximize_window()
    context.driver.implicitly_wait(5)
    # 10 sec changed to 3 sec since 10 sec is too long time
    context.driver.wait = WebDriverWait(context.driver, 3)

    context.app = Application(context.driver)
コード例 #30
0
def browser_init(context):
    """
    :param context: Behave context
    """
    context.chrome_instance = webdriver.Chrome()
    # context.browser = webdriver.Safari()
    # context.browser = webdriver.Firefox()

    context.chrome_instance.maximize_window()
    context.chrome_instance.implicitly_wait(4)

    context.app = Application(context.chrome_instance)
コード例 #31
0
def main():
    application = Application()
    application.run()
コード例 #32
0
ファイル: roboc.py プロジェクト: VincentMardon/python_maze
# -*- coding: utf-8 -*-

from app.home import homecontroller
from app.application import Application



# home page
homePageOpened = True
while homePageOpened:
    user = homecontroller.executeHome()
    
    if user != '':
        print('\n' + '\033[1;35m' + 'Bienvenue {} !'.format(user) + '\033[0m')
        homePageOpened = False
    else:
        print('\n' + '\033[1;31m' + 'ENTREZ VRAIMENT UN PSEUDO !' + '\033[0m')

# game
gameOpened = True
while gameOpened:
    app = Application(user)
    gameOpened = app.run()
コード例 #33
0
Copyright (C) 2015 Jeison Pacateque, Santiago Puerto, Wilmar Fernandez

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>
'''

import sys
from PyQt5 import QtWidgets

if __name__ == '__main__':
    from app.application import Application

    qApp = QtWidgets.QApplication(sys.argv)

    asphalt_simulator = Application()
    asphalt_simulator.setWindowTitle("Asphalt Mixtures Aging Simulator")
    asphalt_simulator.show()

    sys.exit(qApp.exec())