def test_new_floor():
    id = 1
    location_id = 456
    description = "First floor"
    new_floor = Floor(id=id, location_id=location_id, description=description)
    assert (new_floor.id == id and new_floor.location_id == location_id
            and new_floor.description == description)
Example #2
0
def test_cannot_access_tables_from_other_locations(app, db_session):
    """User with Location Admin role cannot access the tables
    from a Location which is not owned by the company they work at"""
    company = Company(id=1, name="Foo Inc.", code="code1", address="addr")
    other = Company(id=2, name="Other Foo Inc.", code="code2", address="addr2")
    location = Location(id=1,
                        name="name",
                        code="123",
                        company_id=other.id,
                        country="US",
                        region="region",
                        city="city",
                        address="address",
                        longitude="123",
                        latitude="123",
                        type="type",
                        status="status")
    floor = Floor(id=1, description="1st Floor", location_id=location.id)
    shape = TableShape(id=1,
                       description="Round Table",
                       picture="/path/to/file.jpg")
    table = Table(id=1,
                  name="some table",
                  floor_id=floor.id,
                  x=40,
                  y=50,
                  width=320,
                  height=150,
                  status=1,
                  max_capacity=12,
                  multiple=False,
                  playstation=False,
                  shape_id=1)
    db_session.add(company)
    db_session.add(other)
    db_session.add(location)
    db_session.add(floor)
    db_session.add(shape)
    db_session.commit()
    db_session.add(table)
    user = Employee(id=1,
                    first_name="Alice",
                    last_name="Cooper",
                    username="******",
                    phone_number="1",
                    birth_date=datetime.utcnow(),
                    pin_code=3333,
                    account_status="on",
                    user_status="on",
                    registration_date=datetime.utcnow(),
                    company_id=company.id,
                    email="*****@*****.**",
                    password="******")
    flask.g.user = user
    db_session.add(user)
    db_session.commit()
    assert not has_privilege(
        method=Method.READ, resource="tables", id=table.id)
Example #3
0
def test_list(client, db_session, clear_cache):
    """ Test getting list of Floors objects
    @todo #173:30min Once issue with cache (#273) is resolved, remove
     clear_cache fixture and make sure that test runs ok. Also remove it from
     if they use it.
    """
    db_session.add(Floor(location_id=None, description="Test floor"))
    db_session.commit()
    floors = client.get("/floors/")
    assert floors.status_code == HTTPStatus.OK
    assert b"Test floor" in floors.data
Example #4
0
def test_list(client, db_session):
    db_session.add(Floor(location_id=None, description="Test floor"))
    db_session.commit()
    floors = client.get("/floors/")
    assert floors.status_code == HTTPStatus.OK
    assert b"Test floor" in floors.data