コード例 #1
0
 def setup_class(cls):
     cls.port = free_port()
     start_server(cls.port,
                  locations={"data": "test_data"},
                  tables={"data": "test_data"},
                  customers={"data": "test_data"})
     cls.poster = Poster(url=f"http://localhost:{cls.port}")
コード例 #2
0
ファイル: test_poster.py プロジェクト: bkuzmic/timelessis-1
def poster():
    port = free_port()
    start_server(port,
                 locations={"data": "test_data"},
                 tables={"data": "test_data"},
                 customers={"data": "test_data"})
    return Poster(url=f"http://localhost:{port}")
コード例 #3
0
ファイル: it_sync_test.py プロジェクト: bkuzmic/timelessis-1
 def setup_class(cls, mocked_auth):
     cls.port = free_port()
     start_server(cls.port, locations=cls.locations)
     cls.company = Company(
         name="Any company",
         code="Cpny",
         employees=[
             Employee(username="******",
                      password="******",
                      first_name="Richard",
                      last_name="Myers",
                      phone_number="112233",
                      user_status="U",
                      birth_date=datetime.datetime.utcnow(),
                      pin_code=4567,
                      email="*****@*****.**",
                      account_status="A",
                      registration_date=datetime.datetime(2019, 1, 1))
         ],
         locations=[
             Location(id=40,
                      name="Tapper",
                      code="T",
                      company_id=50,
                      poster_id=2,
                      country="United States",
                      region="Nay",
                      city="South",
                      type="L",
                      address="Delta Park, 145",
                      longitude=640,
                      latitude=480,
                      status="open",
                      synchronized_on=datetime.datetime(1983, 5, 10)),
             Location(id=150,
                      name="Hard Rock",
                      code="H",
                      company_id=50,
                      poster_id=10,
                      country="United States",
                      region="Manhattan",
                      city="New York",
                      type="C",
                      address="5th Avenue 145",
                      longitude=1024,
                      latitude=720,
                      status="open",
                      synchronized_on=datetime.datetime(1983, 5, 10))
         ])
     access_token = Authenticated(
         PosterAuthData(
             application_id="test_application_id",
             application_secret="test_application_secret",
             redirect_uri="test_redirect_uri",
             code="test_code",
         ))
     cls.poster_sync = PosterSync
     cls.poster = Poster(url="http://localhost:{port}".format(
         port=cls.port))
コード例 #4
0
def test_sync_location(db_session):
    port = free_port()
    start_server(port,
                 locations=[{
                     "id": 100,
                     "name": "Coco Bongo",
                     "code": "C",
                     "company_id": 50,
                     "country": "United States",
                     "region": "East Coast",
                     "city": "Edge City",
                     "address": "Blvd. Kukulcan Km 9.5 #30, Plaza Forum",
                     "longitude": 21.1326063,
                     "latitude": -86.7473191,
                     "type": "L",
                     "status": "open",
                     "comment": "Nightclub from a famous movie"
                 }])
    company = Company(id=50,
                      name="Company of Heroes",
                      code="Cpny",
                      address="Somewhere in the bermuda triangle")
    db_session.add(company)
    db_session.commit()
    location = Location(id=100,
                        name="Coconut Bongolive",
                        code="C",
                        company_id=50,
                        country="United States of America",
                        region="West Coast",
                        city="Another city",
                        address="Some address in Another City",
                        longitude=42.2642026,
                        latitude=-172.148146,
                        type="L",
                        status="closed",
                        comment="A location with ")
    db_session.add(location)
    db_session.commit()
    SyncedLocation(
        location=location,
        poster_sync=Poster(url="http://localhost:{port}".format(port=port)),
        db_session=db_session).sync()
    row = Location.query.filter_by(id=location.id).one()
    assert row.id == 100
    assert row.name == "Coco Bongo"
    assert row.code == "C"
    assert row.company_id == 50
    assert row.country == "United States"
    assert row.region == "East Coast"
    assert row.city == "Edge City"
    assert row.address == "Blvd. Kukulcan Km 9.5 #30, Plaza Forum"
    assert row.longitude == 21.1326063
    assert row.latitude == -86.7473191
    assert row.type == "L"
    assert row.status == "open"
    assert row.comment == "Nightclub from a famous movie"
コード例 #5
0
 def setup_class(cls, mocked_auth):
     cls.port = free_port()
     start_server(cls.port, locations=cls.locations)
     cls.company = Company(
         name="Any company",
         code="Cpny",
         employees=[
             Employee(username="******",
                      password="******",
                      first_name="Richard",
                      last_name="Myers",
                      phone_number="112233",
                      birth_date=datetime.datetime.utcnow(),
                      pin_code=4567,
                      email="*****@*****.**")
         ],
         locations=[
             Location(id=40,
                      name="Tapper",
                      code="T",
                      company_id=50,
                      poster_id=2,
                      synchronized_on=datetime.datetime(1983, 5, 10)),
             Location(id=150,
                      name="Hard Rock",
                      code="H",
                      company_id=50,
                      poster_id=10,
                      synchronized_on=datetime.datetime(1983, 5, 10))
         ])
     access_token = Authenticated(
         PosterAuthData(
             application_id="test_application_id",
             application_secret="test_application_secret",
             redirect_uri="test_redirect_uri",
             code="test_code",
         ))
     cls.poster_sync = PosterSync
     cls.poster = Poster(url="http://localhost:{port}".format(
         port=cls.port))
コード例 #6
0
def test_sync_table(db_session):
    port = free_port()
    poster_table_id = 10
    poster_table_name = "Round Table of The Knights"
    poster_table_floor_id = 5
    poster_table_x = 640
    poster_table_y = 480
    poster_table_width = 200
    poster_table_height = 200
    poster_table_status = "active"
    poster_table_max_capacity = 5
    poster_table_multiple = False
    poster_table_playstation = True
    poster_table_shape_id = 1
    poster_table_min_capacity = 1
    poster_table_created = datetime.utcnow
    poster_table_updated = datetime.utcnow
    start_server(port,
                 tables=[{
                     "id": poster_table_id,
                     "name": poster_table_name,
                     "floor_id": poster_table_floor_id,
                     "x": poster_table_x,
                     "y": poster_table_y,
                     "width": poster_table_width,
                     "height": poster_table_height,
                     "status": poster_table_status,
                     "max_capacity": poster_table_max_capacity,
                     "multiple": poster_table_multiple,
                     "playstation": poster_table_playstation,
                     "shape_id": poster_table_shape_id,
                     "min_capacity": poster_table_min_capacity,
                     "created": poster_table_created,
                     "updated": poster_table_updated
                 }])
    table_in_database = Table(id=10,
                              name="Table for Knights that Are Round",
                              floor_id=6,
                              x=800,
                              y=600,
                              width=400,
                              height=400,
                              status="inactive",
                              max_capacity=4,
                              multiple=True,
                              playstation=False,
                              shape_id=3,
                              min_capacity=2,
                              created=date.today() - timedelta(5),
                              updated=date.today() - timedelta(5))
    db_session.add(table_in_database)
    db_session.commit()
    synced_table = SyncedTable(table_in_database).sync(
        Poster(url=f"http://localhost:{port}"))
    row = db_session.query(Table).get(synced_table.id)
    assert row.id == poster_table_id
    assert row.name == poster_table_name
    assert row.floor_id == poster_table_floor_id
    assert row.x == poster_table_x
    assert row.y == poster_table_y
    assert row.width == poster_table_width
    assert row.height == poster_table_height
    assert row.status == poster_table_status
    assert row.max_capacity == poster_table_max_capacity
    assert row.multiple == poster_table_multiple
    assert row.playstation == poster_table_playstation
    assert row.shape_id == poster_table_shape_id
    assert row.min_capacity == poster_table_min_capacity
    assert row.created == poster_table_created
    assert row.updated == poster_table_updated