def test_get_items(monkeypatch):
    id1 = 'cardId1'
    id2 = 'cardId2'
    name1 = 'Clean flat'
    name2 = 'Clean room'
    desc1 = 'You need to clean the entire flat'
    desc2 = 'You need to clean the entire room'
    date1 = '2020-09-08'
    date2 = '2020-09-01'
    card1 = {
        'card_id': id1,
        'card_name': name1,
        'card_desc': desc1,
        'card_dateLastActivity': date1
    }
    card2 = {
        'card_id': id2,
        'card_name': name2,
        'card_desc': desc2,
        'card_dateLastActivity': date2
    }

    client = pymongo.MongoClient('server.example.com')
    collection = client.db.collection

    monkeypatch.setattr(collection, 'find_one', lambda obj: mock_find_one(obj))

    expected_result = [[Card(id1, name1, desc1, 'todo', date1)],
                       [Card(id2, name2, desc2, 'doing', date2)], []]
    actual_result = mongoDB.get_items(collection, 'board_id')
    same_items(expected_result, actual_result)
Esempio n. 2
0
    def __init__(self, x, y, *args):
        item = choice(items.get_items())()

        # while item in player.inventory():
        #     item = choice(items.get_items())()

        self.item = item
        super().__init__(x, y)
Esempio n. 3
0
    def __init__(self, x, y, *args):
        item = choice(items.get_items())()

        # while item in player.inventory():
        #     item = choice(items.get_items())()

        self.item = item
        super().__init__(x, y)
Esempio n. 4
0
 def test_get_items(self):
     i = items.get_items("W01","Iron Skin","A02")
     self.assertTrue(isinstance(i[0],items.Weapon))
     self.assertEqual("Empty Hands", i[0].name)
     self.assertTrue(isinstance(i[1],items.Armor))
     self.assertEqual("Iron Skin", i[1].name)
     self.assertTrue(isinstance(i[2],items.Armor))
     self.assertEqual("Headband", i[2].name)
Esempio n. 5
0
def home():
    tag = helpers.get_arg(request.args.get('tag'), 'untagged')
    page = int(helpers.get_arg(request.args.get('page'), 1))
    count = int(
        helpers.get_arg(request.args.get('count'), settings.items_per_page))
    itms = items.get_items()
    num_pages = items.get_num_pages(itms, count, tag='untagged')
    labels_json = items.get_page(items.get_tag(itms, tag), page, count)
    return render_template('custom/index.html',
                           labels_json=labels_json,
                           num_pages=num_pages,
                           page_num=page)
Esempio n. 6
0
def all():
    page = int(helpers.get_arg(request.args.get('page'), 1))
    count = int(
        helpers.get_arg(request.args.get('count'), settings.items_per_page))
    itms = items.get_items()
    num_pages = items.get_num_pages(itms, count)
    labels_json = items.get_page(itms, page, count)

    return render_template('custom/index.html',
                           labels_json=labels_json,
                           num_pages=num_pages,
                           page_num=page)
Esempio n. 7
0
def startGame(): #UNFINISHED
    logging.basicConfig(filename=Settings.log_loc, level=Settings.log_level, format='%(asctime)s %(levelname)s: %(message)s')
    logging.info("Starting Game")
    #reset_cooldown()
    get_boundaries()
    im = screenGrab()
    get_images()
    get_items()
    if len(Settings.Player.skills[0]) <= 1:
        logging.critical("skills not set, shutting down")
        SystemExit
    #print "%d enemies" %len(getEnemies(im))
    battle_end = False
    while not battle_end:
        if len(get_enemies(im)) == 0 or pony_time(im):
            press('spacebar')
            time.sleep(1.5)
            im = screenGrab()
            if len(get_enemies(im)) == 0 and not pony_time(im):
                logging.info("Battle ended: getEnemies was %d and Pony Time was %r" % (len(get_enemies(im)), pony_time(im)))
                #creenGrab_save()
                leftover_inventory()
                battle_end = True
        else:
            Settings.pony_timer = 0
            if not start_round():
                return False
            time.sleep(0.5)
            press('spacebar')
            im = screenGrab()
            if is_player_dead(im):
                logging.info("Player is dead")
                leftover_inventory()
                return False
            time.sleep(1)
            im = screenGrab()
    return True
Esempio n. 8
0
def choose_weapons(equipment_list):
    from items import get_items

    weapon_list = {}
    for weapon in get_items('Weapon').items():
        weapon_list[weapon[0]] = weapon[1].get_weapon_type()

    for n, item in enumerate(equipment_list):
        if item[0] == 'Weapon':
            choices = []
            for weapon in weapon_list.keys():
                if item[2] in ['Any', weapon_list[weapon][0]]:
                    if item[3] in ['Any', weapon_list[weapon][1]]:
                        choices.append(weapon)
            choice = choices[simple_choice(choices)]
            equipment_list[n] = (choice, item[1])

    return equipment_list
Esempio n. 9
0
def get_rooms():
    list1 = []
    global room_id_dict
    rooms = open("Texts/rooms.txt", "r")
    rooms.readline()

    for line in rooms:
        record = line.split(",")

        new = Room(record[1].strip(),record[2].strip(),\
                   record[3].strip(),record[4].strip())
        room_id_dict[str(record[0].strip())] = new
        list1.append(new)

        #add exits
        record5 = record[5].strip()
        exits = record5.split(";")
        for dirs in exits:
            order = dirs.split(":")[0]
            room = dirs.split(":")[1]
            if (order.startswith("CLOSED")):
                new.closed_exits[order.replace("CLOSED",
                                               "")] = room.replace("\n", "")
            else:
                new.exits[order] = room.replace("\n", "")
        #add items
        record6 = record[6].strip()
        items = record6.split(";")
        if (len(items) > 0):
            new.items = get_items(items)
        #add enemy:
        record7 = record[7].strip()
        temp = record7.split(":")
        if (temp[0] not in ("", " ")):
            number_of_enemies = int(temp[0])

            for i in range(number_of_enemies):
                new.enemies.append(get_enemy(temp[1]))

    return list1
Esempio n. 10
0
 def display_prices_list(self, lettre):
     self.display_metiers()
     self.write(u"""
     <table>
     <tr>
         <th>Nom</th>
         <th>Prix</th>
         <th></th>
     </tr>""")
     
     items = []
     for id in get_items():
         item = get_item(id)
         if item.get_name()[0] == lettre or (lettre in correspondances and item.get_name()[0] in correspondances[lettre]):
             items.append(item)
             
     items.sort(key = lambda item: item.get_name())
             
     for item in items:
         self.write(u"""
         <tr>
             <form action="/prices" method="get">
                 <td>
                     <input class="object_name" type="text" name="nom" disabled="disabled" value=\"""" + item.get_name() + u""""/>
                 </td>
                 <td>
                     <input class="object_price" type="number" name="prix" value=\"""" + unicode(item.get_price()) + """"/>
                 </td>
                 <td>
                     <input type="hidden" name="id" value=\"""" + unicode(id) + u""""/>
                     <input type="submit" name="submit" value="Modifier"/>
                 </td>
             </form>
         </tr>""")
     
     self.write(u"</table>")
Esempio n. 11
0
	k = i.keys()
	k.sort()
	id = glutCreateMenu(on_item)
	for key in k:
		if isinstance(i[key], types.DictionaryType):
			subid = create_menu(i[key])
			glutSetMenu(id)
			glutAddSubMenu(key, subid)
		else:
			glutAddMenuEntry(key, len(item_list))
			item_list.append(i[key])
	return id
	

glutInit(sys.argv)
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH)
window = glutCreateWindow('set')
glutDisplayFunc(on_display)
glutIdleFunc(on_idle)
glutReshapeFunc(on_reshape)
glutMotionFunc(on_motion)

item_list = []

create_menu(items.get_items())
glutAttachMenu(GLUT_RIGHT_BUTTON)

current_item = item_list[0]()

glutMainLoop()
Esempio n. 12
0
 def index():
     items = mongoDB.get_items(collection, board_id)
     item_view_model = ViewModel(items[0], items[1], items[2])
     return render_template('index.html', view_model=item_view_model)
Esempio n. 13
0
File: NPC.py Progetto: bpa/renegade
 def set_item_list(self, *list):
     self.item_list = items.get_items(*list)
     self.item_names = map(lambda i: "%5i %s"%(i.value,i.name), self.item_list)
     self.item_names.append('Never mind')
Esempio n. 14
0
def prepare_report():
    global ALL
    if not ALL:
        ALL = get_full_dict('T.CATADO.json')
    report = []
    # records
    report.append(('Total number of bibliographic records', len(ALL)))
    report.append(('Hidden records', len([e for e in ALL.items() if 'HIDE' in e[1]])))
    report.append(('Staff papers', len([e for e in ALL.items() if 'MTYPE' in e[1] and e[1]['MTYPE'].lower() == 'staff paper'])))
    from collections import Counter
    from mapping import mtype_fix, itype_fix, rtype_fix
    itypes = flatten_list([split_subfields(e[1]['ITYPE']) for e in ALL.items() if 'ITYPE' in e[1]])
    itypes = Counter([itype_fix.get(e, e) for e in itypes])
    itypes = sorted(itypes.items(), key=lambda x: x[1], reverse=True)
    report.append(('Item types', sum([e[1] for e in itypes])))
    report = report + itypes

    mtypes = flatten_list([split_subfields(e[1]['MTYPE']) for e in ALL.items() if 'MTYPE' in e[1]])
    mtypes = Counter([mtype_fix.get(e, e) for e in mtypes])
    mtypes = sorted(mtypes.items(), key=lambda x: x[1], reverse=True)
    report.append(('Media types', sum([e[1] for e in mtypes])))
    report = report + mtypes

    rtypes = flatten_list([split_subfields(e[1]['RTYPE']) for e in ALL.items() if 'RTYPE' in e[1]])
    rtypes = Counter([rtype_fix.get(e, e) for e in rtypes])
    rtypes = sorted(rtypes.items(), key=lambda x: x[1], reverse=True)
    report.append(('Record types', sum([e[1] for e in rtypes])))
    report = report + rtypes

    # items
    from items import get_items
    d = get_items('BARCD')
    report.append(('Records with items', len(d)))
    report.append(('Total number of items', sum([len(e[1]) for e in d.items()])))

    # circulation
    circs = get_full_dict('T.CATCIRC.json')
    report.append(('Total number of loans', len(circs)))
    report.append(('Active loans', len([e for e in circs.items() if not 'IDATE' in e[1]])))
    report.append(('Current reservations', len([e for e in ALL.items() if 'RES' in e[1]])))

    # orders
    orders = get_full_dict('T.ACQPOS.json')
    vendors = get_full_dict('T.LIBVENDORS.json')
    report.append(('Total number of orders', len(orders)))
    orders_by_year = sorted(Counter([e[1][-2:] for e in get_field('ODATE', False, orders)]).items())
    report = report + orders_by_year
    report.append(('Total number of vendors', len([e for e in vendors.items() if 'VCODE' in e[1]])))

    # patrons
    patrons = get_full_dict('T.APPUSERS.json')
    report.append(('Total number of users', len(patrons)))
    report.append(('Real users', len([e for e in patrons.items() if 'PA' not in e[1] or ('PA' in e[1] and len(e[1]['PA'])!=3)])))
    report.append(('ILL users', len([e for e in patrons.items() if 'PA' in e[1] and len(e[1]['PA']) == 3])))

    # serials
    serials = get_full_dict('T.SERHOLD.json')
    report.append(('Total number of serials', len(serials)))
    report.append(('Active serials', len([e for e in serials.items() if 'ACTIV' in e[1]])))

    print ''
    for k, v in report:
        print '%s;%d' % (k, v)
Esempio n. 15
0
def summary():
    return render_template('custom/summary.html',
                           data=items.summarise_items(items.get_items()))