예제 #1
0
    def test__main__make_app__WillStartCataloger__WhenCalled(
            self, _, __, ___, mock_collector):

        make_app()
        collector_instance = mock_collector.return_value
        assert collector_instance.collect_reviews.called
        assert collector_instance.collect_releases.called
예제 #2
0
    def test__main__make_app__WillInjectStoreIntoReviewsHandler__WhenCalled(self, mock_app, mock_review_store, mock_score_store, _, __):

        review_store_instance = mock_review_store.return_value
        score_store_instance = mock_score_store.return_value

        expected_arg = [
            (r'/', ScoresHandler, {'store': score_store_instance}),
            (r'/public/(.*)', tornado.web.StaticFileHandler, {'path': PUBLIC_ROOT}),
            ('/reviews', ReviewsHandler, {'store': review_store_instance})]

        make_app()

        mock_app.assert_called_with(expected_arg)
예제 #3
0
 def get_app(self):
     """
     Overrides basic method, gets app
     """
     # Assumption is environment has already been loaded by the test runner,
     # else the below will fail
     application = make_app()
     return application
예제 #4
0
    def test__main__make_app__WillInjectSearcherIntoTheSearchHandler__WhenCalled(
            self, mock_app, mock_searcher):

        main_path = os.path.abspath(
            os.path.join(os.path.dirname(__file__), os.pardir))

        searcher_instance = mock_searcher.return_value
        expected_args = [('/', HomePageHandler),
                         ('/public/(.*)', StaticFileHandler, {
                             'path': main_path + '/static'
                         }),
                         ('/search', SearchHandler, {
                             'searcher': searcher_instance
                         })]

        make_app()

        mock_app.assert_called_with(expected_args)
예제 #5
0
def test_sync():
    app = make_app()

    @app.route('/test')
    def handler(request):
        return text('Hello')

    request, response = sanic_endpoint_test(app, uri='/test')

    assert response.text == 'Hello'
예제 #6
0
    def test__main__make_app__WillInjectStoreIntoReviewsHandler__WhenCalled(
            self, mock_app, mock_review_store, mock_score_store, _, __):

        review_store_instance = mock_review_store.return_value
        score_store_instance = mock_score_store.return_value

        expected_arg = [(r'/', ScoresHandler, {
            'store': score_store_instance
        }),
                        (r'/public/(.*)', tornado.web.StaticFileHandler, {
                            'path': PUBLIC_ROOT
                        }),
                        ('/reviews', ReviewsHandler, {
                            'store': review_store_instance
                        })]

        make_app()

        mock_app.assert_called_with(expected_arg)
예제 #7
0
    def test__main__make_app__WillInitialiseTornadoApplicationWithCorrectHandlers__WhenCalled(
            self, mock_app, mock_sql):

        mock_sql_instance = mock_sql.return_value

        expected_args = [('/check-vulnerability', CheckVulnerabilityHandler,
                          dict(spider=DVWASpider,
                               injector=mock_sql_instance,
                               crawled_site='dvwa')),
                         ('/get-db-users', GetDbUsersHandler,
                          dict(spider=DVWASpider,
                               injector=mock_sql_instance,
                               crawled_site='dvwa')),
                         ('/get-db-version', GetDbVersionHandler,
                          dict(spider=DVWASpider,
                               injector=mock_sql_instance,
                               crawled_site='dvwa'))]

        make_app()

        mock_app.assert_called_with(expected_args)
    def get_app(self):
        class TestMeView(CacheMixin, JinjaTemplateMixin, RequestHandler):
            @gen.coroutine
            def get(self):
                self.write('chunk-1*')
                self.write('chunk-2*')
                self.write('chunk-3')

        self.application = main.make_app([
            (r'/testme/', TestMeView),
        ])
        return self.application
예제 #9
0
    def insert_data():
        from main import make_app, db
        app = make_app()
        with app.app_context():
            with open('fake_data.csv', 'r', newline='') as file:
                reader = csv.DictReader(file)
                for row in reader:
                    doctor = Doctor(name=row['name'],
                                    occupation=row['occupation'])
                    address = Address(phone_number=int(row['phone_number']),
                                      street_address=row['street_address'],
                                      city=row['city'],
                                      state=row['state'],
                                      zipcode=int(row['zipcode']),
                                      long=float(row['long']),
                                      lat=float(row['lat']))
                    doctor.addresses.append(address)

                    db.session.add(doctor)
                db.session.commit()
    def get_app(self):

        class TestMeView(
            CacheMixin,
            JinjaTemplateMixin,
            RequestHandler
        ):

            @gen.coroutine
            def get(self):
                self.write('chunk-1*')
                self.write('chunk-2*')
                self.write('chunk-3')

        self.application = main.make_app(
            [
                (r'/testme/', TestMeView),
            ]
        )
        return self.application
예제 #11
0
    def test__main__make_app__WillStartCollector__WhenCalled(self, _, __, ___, mock_collector):

        make_app()
        collector_instance = mock_collector.return_value
        assert collector_instance.start.called
예제 #12
0
 def get_app(self):
     app = make_app()
     app.objects = peewee_async.Manager(db)
     return app
예제 #13
0
 def get_app(self):
     return main.make_app()
예제 #14
0
def zeus(loop, aiohttp_client):
    app = make_app()
    return loop.run_until_complete(aiohttp_client(app))
예제 #15
0
def app():
    app = make_app()
    yield app
예제 #16
0
    def test__main__make_app__WillInstantiateTMDBSearcher__WhenCalled(
            self, mock_app, mock_searcher):

        make_app()

        mock_searcher.assert_called_with()
예제 #17
0
 def get_app(self):
     from main import make_app
     return make_app()
예제 #18
0
    def test__main__make_app__WillStartAggregatorService__WhenCalled(
            self, _, __, ___, mock_aggregator):

        make_app()
        aggregator_instance = mock_aggregator.return_value
        assert aggregator_instance.start.called
예제 #19
0
파일: test.py 프로젝트: magic-coder/daping
 def get_app(self):
     self.app = make_app()
     return self.app
예제 #20
0
 def get_app(self):
     return main.make_app()
예제 #21
0
 def get_app(self):
     import main
     return main.make_app()
예제 #22
0
import pytest
from main import make_app
from tornado.options import define
import os

define('static_path',
       default=os.path.join(os.path.dirname(__file__), "static"),
       help='static file path')

application = make_app()


@pytest.fixture
def app():
    return application


@pytest.mark.gen_test
def test_hello_world(http_client, base_url):
    response = yield http_client.fetch(f"{base_url}/ping")
    assert response.code == 200
    assert response.body == b"Hello, world"


@pytest.mark.gen_test
def test_static(http_client, base_url):
    response = yield http_client.fetch(f"{base_url}/static/test.txt")
    assert response.code == 200
    assert response.body == b"Hello, world from static!"

예제 #23
0
    def test__main__make_app__WillStartAggregatorService__WhenCalled(self, _, __, ___, mock_aggregator):

        make_app()
        aggregator_instance = mock_aggregator.return_value
        assert aggregator_instance.start.called
예제 #24
0
import pytest, os
from webtest import TestApp

try:
    from main import make_app
except ImportError:
    print(
        "If you see this, you didn't install the package before running the tests"
    )
    print("Please install the pacakge with 'pip install -e .'")

app = make_app()


@pytest.fixture
def testapp():
    """A fixture to test the web application"""
    yield TestApp(app)
예제 #25
0
def run_dev(ctx):
    server = HTTPServer(make_app())
    server.bind(PORT)
    server.start(0)
    tornado.ioloop.IOLoop.current().start()