Exemple #1
0
def page_contains_content(route, content='Queer Art and P**n Collective'):
    # essentially just testing that the page builds at all
    client  = app.test_client()
    page    = client.get(route)
    data    = str(page.data)
    pprint.pprint(data)
    return content in data
 def setUp(self):
     self.con = db.conn()
     self.app = app.test_client()
     self.username = '******'
     self.password = '******'
     self.username2 = 'testUser2'
     self.group_name = 'testGroupName1'
Exemple #3
0
def make_shell():
    """Interactive Flask Shell"""
    from flask import request
    #from hello import init_db as initdb
    app = make_app()
    http = app.test_client()
    reqctx = app.test_request_context
    return locals()
Exemple #4
0
 def setUp(self):
     self.db_fd, main.app.config['HEAPED_DATABASE_URL'] = tempfile.mkstemp()
     app.config['TESTING'] = True
     # app.config['CSRF_ENABLED'] = False
     # webstart.app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join(basedir, 'test.db')
     # app.config['HEAPED_DATABASE_URL'] = os.environ['HEAPED_DATABASE_URL']
     self.app = app.test_client()
     db.drop_all()
     db.create_all()
Exemple #5
0
def test_love_q2():
  with app.test_client() as c:
      resp = c.post('/bot', data=dict(user_name='my_username', text='runbotton: love me', trigger_word='runbotton:'))
      h.assert_that(json.loads(resp.data), h.equal_to({'text': 'I will be yours until I die.'}))

      resp = c.post('/bot', data=dict(user_name='my_username', text='runbotton: who do you love?', trigger_word='runbotton:'))
      h.assert_that(json.loads(resp.data), h.equal_to({'text': 'I will always love my_username!'}))

      resp = c.post('/bot', data=dict(user_name='my_username2', text='runbotton: love me', trigger_word='runbotton:'))
      h.assert_that(json.loads(resp.data), h.equal_to({'text': "my_username is dead to me. I'm all about my_username2 now!"}))
Exemple #6
0
 def setUp(self):
     self.app = app.test_client()
     self.comment_data = {
         "name": "admin",
         "email": "*****@*****.**",
         "url": "http://localhost",
         "ip_address": "127.0.0.1",
         "body": "test comment!",
         "entry_id": 1
     }
Exemple #7
0
 def setUp(self):
     app.config['TESTING'] = True
     app.config['CSRF_ENABLED'] = False
     self.app = app.test_client()
     # Setups app engine test bed. See: http://code.google.com/appengine/docs/python/tools/localunittesting.html#Introducing_the_Python_Testing_Utilities
     self.testbed = testbed.Testbed()
     self.testbed.activate()
     self.testbed.init_datastore_v3_stub()
     self.testbed.init_user_stub()
     self.testbed.init_memcache_stub()
     self.testbed.init_taskqueue_stub(root_path=".")
     self.task_stub = self.testbed.get_stub(testbed.TASKQUEUE_SERVICE_NAME)
 def setUp(self):
     # Flask apps testing. See: http://flask.pocoo.org/docs/testing/
     app.config.from_pyfile(os.path.join(config.BASE_DIR, 'config.py'))
     self.flask_app = app
     self.app = app.test_client()
     # Setups app engine test bed.
     # See: http://code.google.com/
     # appengine/docs/python/tools/localunittesting.html#Introducing_the_Python_Testing_Utilities
     self.testbed = testbed.Testbed()
     self.testbed.activate()
     self.testbed.init_datastore_v3_stub()
     self.testbed.init_user_stub()
     self.testbed.init_memcache_stub()
Exemple #9
0
    def setUp(self):
        ndb.get_context().clear_cache()

        app.config['TESTING'] = True
        app.config['WTF_CSRF_ENABLED'] = False
        self.app = app.test_client()

        self.user_data = {
            'email': '*****@*****.**',
            'password': '******',
            'password_confirm': 'password1',
            'first_name': 'John',
            'last_name': 'Doe',
            'zipcode': '90210'
        }
Exemple #10
0
def test_valid_delete(_set_up_client, _reset_limits, _clear_db):
    response = create_email_alias()
    assert len(VirtualAlias.query.all()) == 1
    json_data = json.loads(response.get_data())
    email = json_data['email']

    client = app.test_client()
    timestamp = int(time.time())
    token = generate_token(email, timestamp=timestamp)
    data = dict(email=email, timestamp=timestamp, token=token)
    data = json.dumps(data)
    response = client.post('/api/delete',
                           data=data,
                           content_type='application/json')
    assert response.status_code == status.HTTP_200_OK
    assert 'OK' in str(response.data)
    assert len(VirtualAlias.query.all()) == 1
    assert not VirtualAlias.query.get(1).enabled
Exemple #11
0
    def test_exception_handling_from_get_page_count(
            self, mocker, test_input_query: dict) -> None:
        """Test other exception handling by get_page_count raises a HTTP 500 status code."""

        # Patch the get_page_hash, and get_page_count functions
        _ = mocker.patch("main.get_page_hash")
        _ = mocker.patch("main.get_page_count", side_effect=Exception())

        # Set up the app test client
        client = app.test_client()

        # Get the /badge page of the app, and assert it returns a HTTP 500 status code
        get_client = client.get("/badge",
                                query_string={
                                    "page": "example",
                                    **test_input_query
                                })
        assert get_client.status_code == HTTPStatus.INTERNAL_SERVER_ERROR
Exemple #12
0
    def test_api_get_stat_vars_union(self, send_request):
        req = {'dcids': ['geoId/10001', 'geoId/10003', 'geoId/10005']}
        result = ["sv1", "sv2", "sv3"]

        def side_effect(req_url,
                        req_json={},
                        compress=False,
                        post=True,
                        has_payload=True):
            if (req_url == dc.API_ROOT + "/place/stat-vars/union"
                    and req_json == req and post and not has_payload):
                return {'statVars': {'statVars': result}}

        send_request.side_effect = side_effect
        response = app.test_client().post('/api/place/stat-vars/union',
                                          json=req)
        assert response.status_code == 200
        assert json.loads(response.data) == result
def test_retrieve_task_by_id_must_returns_json():
    with app.test_client() as client:
        import json
        response = client.post(
            '/tasks',
            data=json.dumps(
                {
                    'title': 'The Awesome Title',
                    'description': 'The Awesome Description'
                }
            ),
            content_type='application/json'
        )

        data = json.loads(response.data.decode('utf-8'))
        inserted_id = data['_id']['$oid']
        response = client.get('/tasks/%s' % inserted_id)
        assert response.content_type == 'application/json'
def test_create_task_returns_created_task():
    with app.test_client() as client:
        import json
        response = client.post(
            '/tasks',
            data=json.dumps(
                {
                    'title': 'The Best Title',
                    'description': 'The Best Description'
                }
            ),
            content_type='application/json'
        )

        data = json.loads(response.data.decode('utf-8'))
        assert data['title'] == 'The Best Title'
        assert data['description'] == 'The Best Description'
        assert data['done'] == False
Exemple #15
0
    def test_showQuestion(self):

        print("\n Enter the id Session")
        idSession = input()

        print("\n Enter the question number")
        numQ = input()
        
        url = '/api/v1/assessment/' + idSession + '/question/' + numQ
        print ("\n Loading... \n")

        responseDB = lookQuestion(idSession,numQ)

        tester = app.test_client(self)
        response = tester.get(
            url, content_type='json')
        self.assertEqual(response.status_code, 200)
        self.assertEqual(json.loads(response.get_data().decode(sys.getdefaultencoding())), responseDB)
Exemple #16
0
    def setUp(self):
        """Set up test environment."""
        super(ApisTestCase, self).setUp()
        app = create_app()
        app.config['TESTING'] = True
        app.config['WTF_CSRF_ENABLED'] = False
        app.config['DEBUG'] = False
        self.app = app
        self.test_client = app.test_client()
        self.assertEqual(app.debug, False)

        responses.add(responses.GET,
                      'https://api.github.com/users/BirdOnTheBranch/repos',
                      json=self.mock_repos,
                      status=200)
        responses.add(responses.GET,
                      'https://www.codewars.com/api/v1/users/BirdOnTheBranch',
                      json=self.mock_codewars_stats,
                      status=200)
Exemple #17
0
    def setUpClass(self):
        # config app
        app.config["TESTING"] = True
        self.app = app.test_client()

        # config databases
        User.client = MongoClient(database_config.TESTING_DATABASE_URL)
        User.db = User.client.user

        Info.client = MongoClient(database_config.TESTING_DATABASE_URL)
        Info.db = Info.client.info

        # create user
        response = self.register(
            self, '_FpCerpd9Z7SIbjmN81Jy_test_profile', '12345678',
            'Ognian Baruh', '*****@*****.**')

        self.verify(self, '_FpCerpd9Z7SIbjmN81Jy_test_profile')
        self.login(self, '_FpCerpd9Z7SIbjmN81Jy_test_profile', '12345678')
Exemple #18
0
    def test_addCSV2(self):
        with app.test_client() as client:

            tupleadd = {
                "FName": "Varun",
                "LName": "V",
                "Math": -45,
                "Chem": -81,
                "Bio": -94,
                "CS": -98,
                "Sports": -1
            }

            response = client.post(
                '/api/v1/student',
                data=json.dumps(tupleadd),
                headers={"Content-Type": "application/json"})

            self.assertEqual(response.status_code, 200)
Exemple #19
0
 def test_correct_create_channel(self):
     weekday = [
         "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday",
         "Sunday"
     ]
     tester = app.test_client(self)
     tester.post('/login',
                 data=dict(Username="******", Password="******"),
                 follow_redirects=True)
     response = tester.post('/user_panel',
                            data=dict(Nickname="admin",
                                      Channel_Name="NewChannel",
                                      Channel_Password="******",
                                      Start_Time="00:01",
                                      End_Time="23:59",
                                      days=",".join(weekday)),
                            follow_redirects=True)
     self.assertIn(b'Leave this channel!', response.data)
     print("testing that channel creation is done correctly")
Exemple #20
0
    def test_get_page_count_called_correctly(self, mocker,
                                             test_input_page: str,
                                             test_input_query: dict) -> None:
        """Test that get_page_count is called with the correct arguments."""

        # Patch the get_page_hash, and get_page_count functions
        patch_get_page_hash = mocker.patch("main.get_page_hash")
        patch_get_page_count = mocker.patch("main.get_page_count")

        # Get the /badge page of the app
        _ = app.test_client().get("/badge",
                                  query_string={
                                      "page": test_input_page,
                                      **test_input_query
                                  })

        # Assert get_page_count is called correctly
        patch_get_page_count.assert_called_once_with(
            patch_get_page_hash.return_value[:64])
def test_add_user():
    app.config['TESTING'] = True
    json_in = {
        'name': 'A',
    }

    with app.test_client() as client:
        rv = client.post('/addgroup', json=json_in)
        result_data = json.loads(rv.get_data(as_text=True))
        group_id = result_data['group_id']
        assert db.session.query(Group).count() == 1

        user_in = {
            'name': "user-A",
            'group_id': group_id,
            'email': '*****@*****.**'
        }
        client.post('/adduser', json=user_in)
        assert db.session.query(User).count() == 1
Exemple #22
0
def test_request_delete_user_disabled(_set_up_client, _reset_limits,
                                      _clear_db):
    response = create_email_alias()
    assert len(VirtualAlias.query.all()) == 1
    json_data = json.loads(response.get_data())
    email = json_data['email']

    VirtualAlias.query.get(1).enabled = False
    db.session.commit()
    assert not VirtualAlias.query.get(1).enabled

    client = app.test_client()
    data = dict(email=email, )
    data = json.dumps(data)
    response = client.post('/api/request_delete',
                           data=data,
                           content_type='application/json')
    assert response.status_code == status.HTTP_400_BAD_REQUEST
    assert 'Email address not found' in str(response.data)
    def test_callSession(self):

        print("\n Enter the is Session")
        idSession = input()

        print("\n Enter the tsp")
        idTest = input()

        url = '/api/v1/assessment/' + idSession + '/' + idTest
        print("\n Loading... \n")

        responseDB = lookS(idSession)

        tester = app.test_client(self)
        response = tester.get(url, content_type='json')
        self.assertEqual(response.status_code, 200)
        self.assertEqual(
            json.loads(response.get_data().decode(sys.getdefaultencoding())),
            responseDB)
Exemple #24
0
 def test_api_parent_places(self, mock_send_request):
     mock_send_request.side_effect = self.side_effect
     response = app.test_client().get('/api/parent-place/geoId/0649670')
     assert response.status_code == 200
     assert json.loads(response.data) == [{
         "dcid": "geoId/06085",
         "name": "Santa Clara County",
         "provenanceId": "dc/sm3m2w3",
         "types": ["County"]
     }, {
         "dcid": "geoId/06",
         "name": "California",
         "provenanceId": "dc/sm3m2w3",
         "types": ["State"]
     }, {
         "dcid": "country/USA",
         "name": "United States",
         "provenanceId": "dc/sm3m2w3",
         "types": ["Country"]
     }]
Exemple #25
0
    def test_sendAnswers(self):

        print("\n Enter the idSession")
        idSession = input()

        print("\n Enter the Body request")
        body = input()

        url = '/api/v1/assessment/' + idSession + '/answerAll'

        tester = app.test_client(self)
        response = tester.post(url, content_type='application/json', data=body)

        self.assertEqual(response.status_code, 200)
        self.assertEqual(
            json.loads(response.get_data().decode(sys.getdefaultencoding())), {
                "Status": 1,
                "Message": "success",
                "Data": True
            })
 def test_post(self):
     tester = app.test_client()
     filename = 'test.jpg'
     response = tester.post('/api/upload',
                            content_type='multipart/form-data',
                            data=dict(file={'file': open(filename, 'rb')},
                                      height='100',
                                      width='100'),
                            follow_redirects=True)
     data = json.loads(response.get_data(as_text=True))
     # check if id in response
     self.assertIn('id', data)
     # check last record id in db == id in reponse
     self.assertEqual(
         Pictures.query.order_by(Pictures.id.desc()).first().id, data["id"])
     # check picture resized
     self.assertEqual(
         Pictures.query.order_by(Pictures.id.desc()).first().status, 'Done')
     # check if everything fine
     return self.assertEqual(response.status_code, 200)
Exemple #27
0
    def test_home(self):
        tester = app.test_client(self)

        response = tester.put("/")
        self.assertEqual(response.status_code, 405)

        response = tester.post("/")
        self.assertEqual(response.status_code, 405)

        response = tester.delete("/")
        self.assertEqual(response.status_code, 405)

        response = tester.get("/test_string")
        self.assertEqual(response.status_code, 404)

        response = tester.get("/")
        self.assertEqual(response.status_code, 200)

        self.assertIn("keywords", response.json)
        self.assertEqual(5, len(response.json["keywords"]))
Exemple #28
0
    def setUp(self):
        # set up the test DB
        self.db = tested_db
        self.db.create_all()
        self.db.session.add(User(id=1, username="******"))
        self.db.session.add(
            Question(id=1,
                     title="When is the A1 due?",
                     content="Is it due this Sunday?",
                     user_id=1))
        self.db.session.add(
            Question(id=2,
                     title="When is the A2 due?",
                     content="Is it due this Monday?",
                     user_id=1))
        self.db.session.add(
            Answer(id=1, content="Yes, It is.", user_id=1, question_id=1))
        self.db.session.commit()

        self.app = tested_app.test_client()
Exemple #29
0
    def setUp(self):
        self.client = app.test_client()
        self.busObj = Business(1234545543, 'somebusiness', 123132123,
                               'somelocation', 'somecategory',
                               'somedescription')

        self.client.post('/api/v1/auth/register',
                         content_type='application/json',
                         data=json.dumps({
                             "username": "******",
                             "password": "******",
                             "email": "*****@*****.**"
                         }))

        self.client.post('/api/v1/auth/login',
                         content_type='application/json',
                         data=json.dumps({
                             "username": "******",
                             "password": "******"
                         }))
Exemple #30
0
def client(request):
    test_client = app.test_client()
    db = MySQLdb.connect(os.environ['RDS_HOSTNAME'], os.environ['RDS_USERNAME'], os.environ['RDS_PASSWORD'],
                         os.environ['RDS_DB_NAME'])
    cursor = db.cursor(MySQLdb.cursors.DictCursor)
    cursor.execute("TRUNCATE TABLE authenticator")
    db.commit()
    db.close()

    def teardown():
        db = MySQLdb.connect(os.environ['RDS_HOSTNAME'], os.environ['RDS_USERNAME'], os.environ['RDS_PASSWORD'], os.environ['RDS_DB_NAME'])
        cursor = db.cursor(MySQLdb.cursors.DictCursor)
        cursor.execute("TRUNCATE TABLE authenticator")
        db.commit()
        cursor.execute("DELETE FROM user")
        db.commit()
        db.close()

    request.addfinalizer(teardown)
    return test_client
Exemple #31
0
    def test_with_optional_predicates(self, mock_query):
        expected_query = '''
        SELECT ?dcid ?mmethod ?obsPeriod
        WHERE {
            ?svObservation typeOf StatVarObservation .
            ?svObservation variableMeasured test_stat_var .
            ?svObservation observationAbout geoId/06 .
            ?svObservation dcid ?dcid .
            ?svObservation measurementMethod ?mmethod .
            ?svObservation observationPeriod ?obsPeriod .
            ?svObservation observationDate "2021" .
        }
    '''
        expected_obs_id = "test_obs_id"

        def side_effect(query):
            if query == expected_query:
                return (['?dcid', '?mmethod', '?obsPeriod', '?obsDate'], [{
                    'cells': [{
                        'value': 'obs_id1'
                    }, {
                        'value': 'test_mmethod'
                    }, {}]
                }, {
                    'cells': [{
                        'value': expected_obs_id
                    }, {
                        'value': 'testMethod'
                    }, {
                        'value': 'testObsPeriod'
                    }]
                }])
            else:
                return ([], [])

        mock_query.side_effect = side_effect
        response = app.test_client().get(
            'api/browser/observation-id?statVar=test_stat_var&place=geoId/06&date=2021&measurementMethod=testMethod&obsPeriod=testObsPeriod'
        )
        assert response.status_code == 200
        assert json.loads(response.data) == expected_obs_id
Exemple #32
0
    def setUpClass(TestIntegration):
        app.testing = True
        app.debug = True
        app.config['SECRET_KEY'] = 'testing_secret'
        TestIntegration.app_client = app.test_client()

        with TestIntegration.app_client.session_transaction() as sess:
            sess['logged_in'] = 'positive-test-gid'

        os.environ['ENV_VAR_FILE_PATH'] = 'static/env.yaml'
        with open('static/env.yaml') as y:
            env_var = yaml.load(y, Loader=yaml.FullLoader)

        TestIntegration.datastore_client = datastore.Client()

        TestIntegration.storage_client = storage.Client()
        TestIntegration.bucket1 = TestIntegration.storage_client.bucket(
            env_var['BUCKET1'])
        TestIntegration.bucket2 = TestIntegration.storage_client.bucket(
            env_var['BUCKET2'])

        img = Image.new('RGB', (512, 512), color='red')

        d = ImageDraw.Draw(img)
        d.text((100, 100), "Hello World", fill=(255, 255, 0))

        byte_arr = io.BytesIO()
        img.save(byte_arr, format='PNG')
        byte_arr = byte_arr.getvalue()

        TestIntegration.app_client.post(
            '/',
            data={
                'file': (io.BytesIO(byte_arr), 'test_integration.png'),
                'email': '*****@*****.**',
                'gid': 'positive-test-gid'
            },
            follow_redirects=False,
            content_type='multipart/form-data')

        sleep(20)
 def setUp(self):
     # 1. ARRANGE
     self.app = app.test_client()
     # initialize app with first boardgame
     self.app.post('/boardgames',
                   json={
                       "name":
                       "Wingspan",
                       "designer":
                       "Elizabeth Hargrave",
                       "playing_time":
                       "60 Min",
                       "rating":
                       8.1,
                       "id":
                       "1",
                       "expansions": [{
                           "name": "European Expansion",
                           "rating": 8.5
                       }]
                   })
Exemple #34
0
    def test_homepage(self, mock_get_display_name):
        mock_get_display_name.return_value = {
            'geoId/1150000': 'Washington, DC',
            'geoId/3651000': 'New York City, NY',
            'geoId/0649670': 'Mountain View, CA',
            'geoId/4805000': 'Austin, TX'
        }

        response = app.test_client().get('/')
        assert response.status_code == 200
        assert b"Data Commons is an open knowledge repository" in response.data
        assert b"July 26, 2021" in response.data
        assert b"We have launched exciting new features" in response.data
        assert b"Use the Python and REST API's to do your own custom analysis" in response.data
        assert b"We cleaned and processed the data so you don't have to" in response.data
        assert b"Join the effort." in response.data
        assert b"Open sourced" in response.data
        assert b"Schema.org" in response.data
        assert b"Explore the data" in response.data
        assert b"Mountain View, CA" in response.data
        assert b"more ..." in response.data
Exemple #35
0
    def setUp(self):
        # set up the test DB
        self.db = tested_db
        self.db.create_all()
        self.db.session.add(City(id=1, city_name="new york", country="us"))
        self.db.session.add(City(id=2, city_name="columbus", country="us"))
        self.db.session.add(
            Team(id=1,
                 team_name="islanders",
                 association="east",
                 division="metropolitan",
                 city_id=1))
        self.db.session.add(
            Team(id=2,
                 team_name="blue jackets",
                 association="east",
                 division="metropolitan",
                 city_id=2))
        self.db.session.commit()

        self.app = tested_app.test_client()
Exemple #36
0
    def test_requests_get_is_called_correctly(self, mocker,
                                              test_input_page: str,
                                              test_input_query: dict) -> None:
        """Test requests.get function is called correctly."""

        # Patch the get_page_count, compile_shields_io_url, and requests.get functions
        _ = mocker.patch("main.get_page_count")
        patch_compile_shields_io_url = mocker.patch(
            "main.compile_shields_io_url")
        patch_requests_get = mocker.patch("requests.get")

        # Get the /badge page of the app
        _ = app.test_client().get("/badge",
                                  query_string={
                                      "page": test_input_page,
                                      **test_input_query
                                  })

        # Assert requests.get is called with the correct arguments
        patch_requests_get.assert_called_once_with(
            patch_compile_shields_io_url.return_value)
Exemple #37
0
    def test_api_get_places_in_names(self, send_request, display_name):

        def send_request_side_effect(req_url,
                                     req_json={},
                                     compress=False,
                                     post=True,
                                     has_payload=True):
            if req_url == dc.API_ROOT + "/node/places-in" and req_json == {
                    'dcids': ['geoId/10'],
                    'place_type': 'County'
            } and not post:
                return [{
                    "dcid": "geoId/10",
                    "place": "geoId/10001"
                }, {
                    "dcid": "geoId/10",
                    "place": "geoId/10003"
                }, {
                    "dcid": "geoId/10",
                    "place": "geoId/10005"
                }]

        def display_name_side_effect(dcids):
            if dcids == "geoId/10001^geoId/10003^geoId/10005":
                return {
                    "geoId/10001": "Kent County, DE",
                    "geoId/10003": "New Castle County, DE",
                    "geoId/10005": "Sussex County, DE",
                }

        send_request.side_effect = send_request_side_effect
        display_name.side_effect = display_name_side_effect
        response = app.test_client().get(
            '/api/place/places-in-names?dcid=geoId/10&placeType=County')
        assert response.status_code == 200
        assert json.loads(response.data) == {
            "geoId/10001": "Kent County, DE",
            "geoId/10003": "New Castle County, DE",
            "geoId/10005": "Sussex County, DE",
        }
Exemple #38
0
    def test_api_get_stats_value(self, send_request):
        def side_effect(req_url,
                        req_json={},
                        compress=False,
                        post=True,
                        has_payload=True):
            if req_url == dc.API_ROOT + "/stat/value" and req_json == {
                    'place': 'geoId/06',
                    'stat_var': 'Count_Person_Male',
                    'date': None,
                    'measurement_method': None,
                    'observation_period': None,
                    'unit': None,
                    'scaling_factor': None
            } and not post and not has_payload:
                return {'value': 19640794}

        send_request.side_effect = side_effect
        response = app.test_client().get(
            '/api/stats/value?place=geoId/06&stat_var=Count_Person_Male')
        assert response.status_code == 200
        assert json.loads(response.data) == {"value": 19640794}
Exemple #39
0
 def test_index(self, mock_fetch_data):
     mock_response = {
         'geoId/06': {
             'in': [{
                 'dcid': 'dcid1',
                 'name': 'name1',
                 'types': ['County', 'AdministrativeArea'],
             }, {
                 'dcid': 'dcid2',
                 'name': 'name2',
                 'types': ['County'],
             }, {
                 'dcid': 'dcid3',
                 'name': 'name3',
                 'types': ['State'],
             }, {
                 'dcid': 'dcid3',
                 'name': 'name3',
                 'types': ['CensusTract'],
             }]
         }
     }
     mock_fetch_data.side_effect = (
         lambda url, req, compress, post: mock_response)
     response = app.test_client().get('/api/place/child/geoId/06')
     assert response.status_code == 200
     assert json.loads(response.data) == {
         'County': [{
             'dcid': 'dcid1',
             'name': 'name1'
         }, {
             'dcid': 'dcid2',
             'name': 'name2'
         }],
         'State': [{
             'dcid': 'dcid3',
             'name': 'name3'
         }]
     }
Exemple #40
0
 def setUp(self):
     self.app = app.test_client()
     self.db = mock()
     def get_fake_db():
         return self.db
     app.get_db = get_fake_db
Exemple #41
0
def test_love_q():
  with app.test_client() as c:
      resp = c.post('/bot', data=dict(user_name='my_username', text='runbotton: who do you love?', trigger_word='runbotton:'))
      h.assert_that(json.loads(resp.data), h.equal_to({'text': 'I will always love nobody!'}))
Exemple #42
0
def test_destroy_all():
  with app.test_client() as c:
      resp = c.post('/bot', data=dict(user_name='my_username', text='runbotton: destroy', trigger_word='runbotton:'))
      h.assert_that(json.loads(resp.data), h.equal_to({'text': 'Launching ICBMs at EVERYBODY.'}))
 def setUp(self):
     self.app = app.test_client()
     self.app.delete("/position")  # clean all data
 def setUp(self):
     app.config['TESTING'] = True
     self.client = app.test_client()
Exemple #45
0
 def setUp(self):
     app.config['TESTING'] = True
     app.config['CSRF_ENABLED'] = False
     app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://root@localhost/flask2'
     self.app = app.test_client()
     db.create_all()
Exemple #46
0
 def setUp(self):
     app.config['TESTING'] = True
     app.config['WTF_CSRF_ENABLED'] = False
     app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join(basedir, 'test.db')
     self.app = app.test_client()
     db.create_all()
Exemple #47
0
def client():
    """ Instantiate Flask's modified Werkzeug client to use in tests """
    app.config["TESTING"] = True
    client = app.test_client()
    return client
Exemple #48
0
 def test_client(self):
     app.testing = True
     return app.test_client()
 def test_redirect_teacher_page_to_login_if_not_soft_logged_in(self):
     tester = app.test_client(self)
     response = tester.get('teacher/lewlaoshi/home', content_type="html/text")
     self.assertEqual(response.status_code, 301)
 def test_public_episodes(self):
     tester = app.test_client(self)
     with app.test_request_context('/lewlaoshi/home?studentID=A9'):
         assert request.path == '/lewlaoshi/home'
         assert request.args['studentID'] == 'A9'
 def setUp(self):
     self.driver = webdriver.PhantomJS()
     self.driver.set_window_size(1120, 550)
     self.tester = app.test_client(self)
Exemple #52
0
 def setUp(self):
     app.config['TESTING'] = True
     app.config['']
     app.test_client()
Exemple #53
0
 def setUp(self):
     app.config['TESTING'] = True
     app.config['DEBUG'] = True
     self.app = app.test_client()
 def testHealthHandler(self):
     rv = app.test_client().get('/_ah/health')
     assert rv.status == '200 OK'
Exemple #55
0
 def setUp(cls):
     print('Running setup')
     cls.app = app.test_client()
     cls.app.testing = True
 def setUp(self):
     self.db_fd, self.db_file = tempfile.mkstemp()
     app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite:///" + self.db_file
     self.app = app.test_client()
     with app.app_context():
         database.init_db()
Exemple #57
0
 def setUp(self):
     self.app = app.test_client()
Exemple #58
0
def test_hello():
    with app.test_client() as c:
        resp = c.post('/bot', data=dict(user_name='my_username', text='runbotton: hi', trigger_word='runbotton:'))
        h.assert_that(json.loads(resp.data), h.equal_to({'text': 'Hello, my_username'}))
Exemple #59
0
 def setUp(self):
     self.client = my_app.test_client()
Exemple #60
0
def test_kyle():
  with app.test_client() as c:
      resp = c.post('/bot', data=dict(user_name='19letterslong', text='runbotton: hi', trigger_word='runbotton:'))
      h.assert_that(json.loads(resp.data), h.equal_to({'text': 'Kiss off, twit!'}))