Example #1
0
    def test_ok(self, use_db):
        factories.LocationFactory(id=1)
        factories.LocationFactory(id=3)
        factories.LocationFactory(id=55)
        factories.LocationFactory(id=34)

        ids = queries.get_locations_ids()

        assert ids == [1, 3, 34, 55]
Example #2
0
    def test_ok(self, use_db):
        factories.LocationFactory(id=1, minzdrav_name="Almaty")
        factories.LocationFactory(id=3, minzdrav_name="Astana")
        factories.LocationFactory(id=55, minzdrav_name="Shymkent")

        mapping = queries.get_locations_minzdrav_name_mapping()

        assert mapping == {
            "Almaty": 1,
            "Astana": 3,
            "Shymkent": 55,
        }
def test_delete(client):
    location = factories.LocationFactory()
    url = url_for("location.delete", id=location.id)
    response = client.post(url)
    assert response.status_code == HTTPStatus.FOUND
    assert response.location.endswith(url_for('location.list'))
    assert Location.query.count() == 0
def test_list(client):
    """ List all locations """
    location = factories.LocationFactory()
    response = client.get(url_for("location.list"))
    assert response.status_code == HTTPStatus.OK
    html = response.data.decode("utf-8")
    assert html.count(location.name) == 1
    assert html.count(location.comment) == 1
def test_create(client, auth):
    location = factories.LocationFactory()
    auth.login()
    floor_data = {"description": "Test floor", "location_id": location.id}
    response = client.post(url_for('floor.create'), data=floor_data)
    assert response.headers["Location"] == "http://localhost/floors/"
    assert response.status_code == HTTPStatus.FOUND
    assert Floor.query.count() == 1
    floor = Floor.query.first()
    assert floor.description == floor_data["description"]
    assert floor.location_id == floor_data["location_id"]
def test_edit(client):
    location_original = factories.LocationFactory()
    location_edited = factories.LocationFactory.get_edit_fields_dict()
    edit_url = url_for("location.edit", id=location_original.id)
    response = client.post(edit_url, data=location_edited)
    assert response.status_code == HTTPStatus.FOUND
    assert response.location.endswith(url_for('location.list'))
    assert Location.query.count() == 1
    location = Location.query.get(location_original.id)
    for attr in location_edited.keys():
        assert getattr(location, attr) == location_edited[attr]
Example #7
0
def test_list(client):
    """ Test list is okay """
    role = factories.RoleFactory(name=RoleType.Intern.name)
    company = factories.CompanyFactory()
    employee = factories.EmployeeFactory(company=company, role_id=role.id)
    location = factories.LocationFactory(company=company)
    floor = factories.FloorFactory(location=location)
    with client.session_transaction() as session:
        session["user_id"] = employee.id
    g.user = employee
    factories.TableFactory(floor_id=floor.id, name="Table 01")
    factories.TableFactory(floor_id=floor.id, name="Table 02")
    factories.TableFactory(floor_id=floor.id, name="Table 03")
    response = client.get(url_for("/tables/"))
    assert response.status_code == HTTPStatus.OK
    assert b"<div><h1>Table 01</h1></div>" in response.data
    assert b"<div><h1>Table 02</h1></div>" in response.data
    assert b"<div><h1>Table 03</h1></div>" in response.data
    assert b"<div><h1>Table " in response.data.count == 3
Example #8
0
    def test_with_data(self, use_db):
        location = factories.LocationFactory(id=1)

        records = factories.CaseDataFactory.create_batch(5, location=location)
        records = sorted(records, key=lambda x: x.date)

        df = queries.get_df()

        assert isinstance(df, pd.DataFrame)
        assert not df.empty

        assert list(df.index.names) == ["location_id", "date"]
        assert list(df.columns) == [
            "confirmed",
            "recovered",
            "fatal",
            "confirmed_cumulative",
            "recovered_cumulative",
            "fatal_cumulative",
            "name",
            "latitude",
            "longitude",
        ]