Пример #1
0
def test_main():
    root_dir = Path(__file__).parent.parent
    result_csv = root_dir / 'result.csv'
    if result_csv.exists():
        result_csv.unlink()
    main(root_dir / 'cargo.csv', root_dir / 'trucks.csv')
    assert result_csv.exists()
Пример #2
0
 def test_version(self, versionarg, capsys):
     with raises(SystemExit) as exc_info:
         main(['progname', versionarg])
     out, err = capsys.readouterr()
     # Should print out version.
     assert err == '{0} {1}\n'.format(metadata.project, metadata.version)
     # Should exit with zero return code.
     assert exc_info.value.code == 0
Пример #3
0
 def test_settings_are_initiated_when_app_running(self):
     mock = self.settings_patcher.start()
     with patch('sys.argv', ['_', r'./resources/specimen.tif']):
         main()
     self.settings_patcher.stop()
     mock.assert_called_once_with(
         debug_mode=False,
         output=None,
         path='./resources/specimen.tif',
     )
Пример #4
0
    def test_main_heals_correctly(self):
        main.uploader.heal = Mock(side_effect=AbortException)

        with self.assertRaises(AbortException):
            # Call under test
            main.main(sleep_time=0)

        main.uploader.scan.assert_called_with(constants.UPLOAD_DIR,
                                              file_ready=main.file_ready)
        main.uploader.upload.assert_called_with(self.files)
        exp_errors = main.uploader.upload(self.files)
        main.uploader.heal.assert_called_with(exp_errors)
Пример #5
0
 def test_help(self, helparg, capsys):
     with raises(SystemExit) as exc_info:
         main(['progname', helparg])
     out, err = capsys.readouterr()
     # Should have printed some sort of usage message. We don't
     # need to explicitly test the content of the message.
     assert 'usage' in out
     # Should have used the program name from the argument
     # vector.
     assert 'progname' in out
     # Should exit with zero return code.
     assert exc_info.value.code == 0
Пример #6
0
    def test_main_loops_forever(self):
        for num_safe_calls in (100, 10, 0, 200):
            side_effects = [None for _ in range(num_safe_calls)]
            side_effects.append(AbortException)

            main.uploader.heal = Mock(side_effect=side_effects)

            with self.assertRaises(AbortException):
                # Call under test
                main.main(sleep_time=0)

            self.assertEqual(len(main.uploader.heal.mock_calls),
                             num_safe_calls + 1)
Пример #7
0
def calculate():
    if request.method == "POST":
        data = request.form.to_dict(flat=False)
        reactors = data['reactors[]']
        start = data['start'][0]
        end = data['end'][0]
        data = main.main(start, end, reactors)
        data = json.dumps(data)
        return data
Пример #8
0
def run(args):
    """Run the package's main script. All arguments are passed to it."""
    # The main script expects to get the called executable's name as
    # argv[0]. However, paver doesn't provide that in args. Even if it did (or
    # we dove into sys.argv), it wouldn't be useful because it would be paver's
    # executable. So we just pass the package name in as the executable name,
    # since it's close enough. This should never be seen by an end user
    # installing through Setuptools anyway.
    from app.main import main
    raise SystemExit(main([CODE_DIRECTORY] + args))
Пример #9
0
def uploadImg(request):
    """
    图片上传
    :param request: 
    :return: 
    """
    context = {}
    if request.method == 'POST':
        new_img = IMG(img=request.FILES.get('img'),
                      name=request.FILES.get('img').name)
        new_img.save()
        context[
            "imgurl"] = "http://oken.club:81" + "/media/" + new_img.img.name
        context["data"] = main.main(context["imgurl"])
    return render(request, 'app/upload.html', context)
Пример #10
0
def process(request):
    if request.method == 'POST':
        repoName = request.POST['repo']
        call_func = main.main(repoName)

        return HttpResponseRedirect('/result/')
Пример #11
0
        file_path = "./tsx_1B.csv"
    return utils.read_stock_file(file_path)


def read_arguments(args):
    is_year_valid(args)
    is_period_valid(args)
    start_date, end_date = build_period_dates(args)
    stocks = get_stocks(args)
    return start_date, end_date, stocks


def output_results(best_stocks):
    print("The best stocks are: ", end='')
    print(", ".join(best_stocks))
    print()
    with open("output.txt", "w") as file:
        for stock in best_stocks:
            file.write(stock + ", ")


def set_thread_number(args):
    threads = int(args.thread)
    fetcher.thread_nb = threads


args = initialize_argparser()
set_thread_number(args)
start_date, end_date, stocks = read_arguments(args)
best_stocks = main(start_date, end_date, stocks)
output_results(best_stocks)
Пример #12
0
 def test_calls_proper_method_on_book(self, mock_book) -> None:
     main()
     mock_book.return_value.dump.assert_called_once()
Пример #13
0
 def test_initiates_settings_singleton(self, mock_book, mock_os) -> None:
     main()
     self.assertEqual(Settings().base_path, 'foo/bar/baz')
Пример #14
0
"""
Copyright (C) 2018-2019 Intel Corporation

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""

import sys
from app.main import main

if __name__ == "__main__":
    sys.exit(main() or 0)
Пример #15
0
#!/usr/bin/env python
import argparse
from app.main import main

parser = argparse.ArgumentParser(description='Write description here')
parser.add_argument('basic_arguments', nargs='*')

args = parser.parse_args()

main(args.basic_arguments, args)
Пример #16
0
 def test_reads_passed_arguments(self, mock_book) -> None:
     main()
     mock_book.assert_called_with('path_name')
Пример #17
0
from asyncio import run
from app.main import main

if __name__ == '__main__':
    run(main())
Пример #18
0
def test_main():

    main()
Пример #19
0
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
Entry point when run as a module.
See https://docs.python.org/3/library/__main__.html.
"""

from app import main

main.main()
Пример #20
0
 def get_Pass(self,passw):
     password = main(passw)
     return {'num_it': password}
Пример #21
0
def get_players(summoner_names):

    players = main(summoner_names)

    return jsonify(players)
Пример #22
0
from app.main import main

if __name__ == "__main__":
    main()
Пример #23
0
 def ready(self):
     from app.main import main
     main()
Пример #24
0
"""
This module is called when the package is executed as a module.
"""

import sys


if __name__ == "__main__":
    from app.main import main

    sys.exit(main())
Пример #25
0
 def test_app_is_closed_when_no_required_args_provided(self):
     with self.assertRaises(SystemExit):
         main()
Пример #26
0
def test_smoke():
    main.main()
Пример #27
0
import sys
from app.main import main

main(sys.argv[1:])
Пример #28
0
 def test_app_is_running_when_required_args_provided(self):
     with patch('sys.argv', ['_', r'./resources/specimen.tif']):
         main()
     self.app_mock.run.assert_called_once()
Пример #29
0
from app.main import main

if __name__ == '__main__':
    main()
Пример #30
0
def execute():
    main.main()
    print('subindo')
    app.run()
    print('subiu')