Esempio n. 1
0
    def test_get(self, client: FlaskClient):
        with client:

            result = client.get(f'/api/{BASE_ROUTE}/{test_uuid1}').get_json()
            expected = make_new_user(uuid=test_uuid1)

            assert result['userUUID'] == str(expected.uuid)
Esempio n. 2
0
def test_get_customer(client, db, customer_schema):
    CustomerService.create(CUSTOMER_DATA)

    response = client.get('/clientes/1').get_json()

    CUSTOMER_DATA['id'] = 1
    assert customer_schema.load(response) == CUSTOMER_DATA
Esempio n. 3
0
 def test_get(self, client: FlaskClient):  # noqa
     with client:
         results = client.get(f"/api/{BASE_ROUTE}/doodad", follow_redirects=True).get_json()
         expected = (
             DoodadSchema(many=True).dump([make_doodad(123, name="Test Doodad 1"), make_doodad(456, name="Test Doodad 2")]).data
         )
         for r in results:
             assert r in expected
Esempio n. 4
0
def test_get_order(client, db):
    OrderService.create(ORDER_DATA)

    response = client.get('/pedidos/1').get_json()

    assert response['status'] == ORDER_DATA['status'].value
    assert response['preco'] == ORDER_DATA['price']
    assert response['cliente_id'] == ORDER_DATA['customer_id']
 def test_get(self, client: FlaskClient):
     with client:
         results = client.get(f'/api/{BASE_ROUTE}',
                              follow_redirects=True).get_json()
         expected = ActivitySchema(many=True).dump(
             [make_new_activity(uuid=test_uuid)]).data
         for r in results:
             assert r in expected
Esempio n. 6
0
 def test_get(self, client: FlaskClient):  # noqa
     with client:
         result = client.get(f"/api/{BASE_ROUTE}/123").get_json()
         expected = dict(item=dict(id=123,
                                   name='Test entity',
                                   purpose='Test purpose',
                                   camelCase='Something'))
         print(f"result = ", result)
         print(f"expected = ", expected)
         assert result == expected
Esempio n. 7
0
 def test_get(self, client: FlaskClient):
     with client:
         results = client.get(f'/api/{BASE_ROUTE}',
                              follow_redirects=True).get_json()
         expected = (UserSchema(many=True).dump([
             make_user(),
             make_user(2, 'John', '*****@*****.**', b'metallica', 2)
         ]))
         for r in results:
             assert r in expected
Esempio n. 8
0
 def test_get(self, client: FlaskClient):  # noqa
     with client:
         results = client.get(f"/api/{BASE_ROUTE}/fizzbar", follow_redirects=True).get_json()
         expected = (
             FizzbarSchema(many=True)
             .dump([make_fizzbar(123, name="Test Fizzbar 1"), make_fizzbar(456, name="Test Fizzbar 2")])
             .data
         )
         for r in results:
             assert r in expected
Esempio n. 9
0
 def test_get(self, client: FlaskClient):  # noqa
     with client:
         results = client.get(f"/api/{BASE_ROUTE}/whatsit",
                              follow_redirects=True).get_json()
         expected = (WhatsitSchema(many=True).dump([
             make_whatsit(123, name="Test Whatsit 1"),
             make_whatsit(456, name="Test Whatsit 2"),
         ]))
         for r in results:
             assert r in expected
Esempio n. 10
0
 def test_get(self, client: FlaskClient):
     with client:
         results = client.get(f'/api/{BASE_ROUTE}',
                              follow_redirects=True).get_json()
         expected = (LocationSchema(many=True).dump([
             make_location(),
             make_location(location_id=2, city='Moscow', country='Russia')
         ]))
         for r in results:
             assert r in expected
Esempio n. 11
0
 def test_get(self, client: FlaskClient):  # noqa
     with client:
         results = client.get(f'/api/{BASE_ROUTE}/whatsit',
                              follow_redirects=True).get_json()
         expected = WhatsitSchema(many=True).dump(
             [make_whatsit(123, name='Test Whatsit 1'),
              make_whatsit(456, name='Test Whatsit 2')]
         ).data
         for r in results:
             assert r in expected
Esempio n. 12
0
 def test_get(self, client: FlaskClient):
     with client:
         results = client.get("nessus/plugins",
                              follow_redirects=True).get_json()
         expected = (PluginSchema(many=True).dump([
             make_plugin("123", published_date1, "asdf", "5",
                         ["cve1", "cve2"]),
             make_plugin("456", published_date2, "asdf", "5",
                         ["cve1", "cve2"]),
         ]))
         for r in results:
             assert r in expected
Esempio n. 13
0
def test_get_fizz(client):  # noqa
    results = [
        FizzSchema(**i) for i in client.get(f"/api/{BASE_ROUTE}").json()
    ]
    print(results)
    expected: List[FizzSchema] = [
        make_fizz(123, name="Test Fizz 1"),
        make_fizz(456, name="Test Fizz 2"),
    ]

    for r in results:
        assert r in expected
Esempio n. 14
0
 def test_get(self, client: FlaskClient):
     with client:
         results = client.get(f'/api/{BASE_ROUTE}/location/1',
                              follow_redirects=True).get_json()
         expected = (UserSchema(many=True).dump([
             make_user(),
             make_user(user_id=2,
                       name='Augustinho Carrara',
                       email='*****@*****.**',
                       password='******',
                       location_id=1)
         ]))
         for r in results:
             assert r in expected
Esempio n. 15
0
 def test_get(self, client: FlaskClient):
     with client:
         results = client.get(f'/api/{BASE_ROUTE}',
                              follow_redirects=True).get_json()
         expected = UserSchema(many=True).dump([
             make_new_user(test_uuid1,
                           username='******',
                           password='******',
                           email='*****@*****.**'),
             make_new_user(test_uuid2,
                           username='******',
                           password='******',
                           email='*****@*****.**')
         ]).data
         for r in results:
             assert r in expected
Esempio n. 16
0
 def test_get(self, client):
     """Should get the list of entities."""
     with client:
         result = client.get(f"/api/{BASE_ROUTE}/").get_json()
         expected = dict(
             items=[{
                 'id': 123,
                 'name': 'Test Entity 1',
                 'purpose': 'Test purpose',
                 'camelCase': 'Something'
             }, {
                 'id': 456,
                 'name': 'Test Entity 2',
                 'purpose': 'Test purpose',
                 'camelCase': 'Something'
             }],
             count=2,
             current='http://localhost/api/entity/?page=1&per_page=3',
             next='http://localhost/api/entity/?page=2&per_page=3')
         assert result == expected
Esempio n. 17
0
    def test_get(self, client: FlaskClient):  # noqa
        with client:
            results = client.get(f"/api/{BASE_ROUTE}",
                                 follow_redirects=True).get_json()
            expected = (UserSchema(many=True).dump([
                make_user(1, username="******", email="*****@*****.**"),
                make_user(2, username="******", email="*****@*****.**"),
                make_user(3, username="******", email="*****@*****.**")
            ]))

            for e in range(len(expected)):
                assert results[e]['id'] == expected[e]['id']
                assert results[e]['username'] == expected[e]['username']
                assert results[e]['email'] == expected[e]['email']
                assert results[e]['password_salt'] == expected[e][
                    'password_salt']
                assert results[e]['full_name'] == expected[e]['full_name']
                assert results[e]['date_of_birth'] == expected[e][
                    'date_of_birth']
                assert results[e]['admin_level'] == expected[e]['admin_level']
                assert results[e]['phone_number'] == expected[e][
                    'phone_number']
Esempio n. 18
0
 def test_get(self, client: FlaskClient):  # noqa
     with client:
         result = client.get(f'/api/{BASE_ROUTE}/whatsit/123').get_json()
         expected = Whatsit(whatsit_id=123)
         assert result['whatsitId'] == expected.whatsit_id
Esempio n. 19
0
    def test_get(self, client: FlaskClient):
        with client:
            result = client.get(f'/api/{BASE_ROUTE}/city/Dublin').get_json()
            expected = make_location(city='Dublin')

            assert result['city'] == expected.city
Esempio n. 20
0
 def test_get(self, client: FlaskClient):
     with client:
         result = client.get(f'/api/{BASE_ROUTE}/1').get_json()
         expected = make_location()
         assert result['locationId'] == expected.location_id
Esempio n. 21
0
 def test_get(self, client: FlaskClient):  # noqa
     with client:
         result = client.get(f"/api/{BASE_ROUTE}/123").get_json()
         expected = make_widget(id=123)
         print(f"result = ", result)
         assert result["widgetId"] == expected.widget_id
Esempio n. 22
0
def test_index(client):
    resp = client.get('/')
    assert resp.status_code == 200
    #assert b'Welcome home' in resp.data
Esempio n. 23
0
 def test_get_by_id(self, client: FlaskClient):
     with client:
         result = client.get("/nessus/plugins/888").get_json()
         expected = Plugin(plugin_id="888")
         assert result["id"] == expected.id
 def test_get(self, client: FlaskClient):  # noqa
     with client:
         result = client.get(f"/api/{BASE_ROUTE}/doodad/123").get_json()
         expected = Doodad(doodad_id=123)
         assert result["doodadId"] == expected.doodad_id
Esempio n. 25
0
def test_app_healthy(app, client):
    with client:
        resp = client.get("/hello")
        assert resp.status_code == 200
        assert resp.is_json
        assert resp.json == "Hello!"
Esempio n. 26
0
def test_app_healthy(app, client):  # noqa
    with client:
        resp = client.get("/health")
        assert resp.status_code == 200
        assert resp.is_json
        assert resp.json == "healthy"
Esempio n. 27
0
def test_app_healthy(app, client): # noqa
    with client:
        response = client.get('/healthz')
        data = json.loads(response.data)
        assert response.status_code == 200
        assert data['ok'] == True
Esempio n. 28
0
def test_get_order(client: FlaskClient):
    user_id = 1
    response = client.get(f'/api/{BASE_ROUTE}/{user_id}')

    assert response.status_code == 200
Esempio n. 29
0
 def test_get(self, client: FlaskClient):  # noqa
     with client:
         result = client.get(f"/api/{BASE_ROUTE}/fizzbaz/123").get_json()
         expected = Fizzbaz(fizzbaz_id=123)
         assert result["fizzbazId"] == expected.fizzbaz_id
Esempio n. 30
0
def test_global_state(app, client): #noqa
    with client:
        response = client.get('/healthz')
        assert g.page == app.config['PAGE']
        assert g.per_page == app.config['PER_PAGE']