示例#1
0
def handle_item_scan_out(item):
    if item['status'] == 'successful':
        item['item']['quantity'] = item['item']['quantity'] - 1
        repo.save(item['item'])
        item_found(item['item'])
    else:
        handle_new_item_entry(item)
    def test_it_should_raise_an_error_on_uom_missing(self):
        inventory_item = {
            '_id': '123456',
            'name': 'item_name',
            'quantity': 1,
            'size': 2
        }
        with pytest.raises(ValueError) as e:
            repo.save(inventory_item)

        assert 'Missing required field: uom' in str(e.value)
示例#3
0
def save_new_item():
    values = editable_text_widget.get_values()
    new_item = {}
    new_item['_id'] = barcode_widget.get_value()
    new_item['name'] = values['item_name_text_box']
    new_item['quantity'] = int(values['item_quantity_text_box'])
    new_item['image'] = found_item_image
    extract_response = string_tools.extract_size_and_uom(
        values['item_size_text_box'])
    if extract_response['successful'] is True:
        new_item['size'] = extract_response['size']
        new_item['uom'] = extract_response['uom']
        repo.save(new_item)

        reset_display()
class Test_when_round_tripping_inventory:
    _id = "123456"
    inventory_item = {
        '_id': _id,
        'name': 'item_name',
        'quantity': 1,
        'size': 8,
        'uom': 'oz',
        'image': 'https://cdn.com/item.jpg'
    }

    repo.save(inventory_item)
    saved_inventory_item = repo.find(_id)

    def test_it_should_have_the_correct_id(self):
        assert self.saved_inventory_item['_id'] == self._id

    def test_it_should_have_the_correct_name(self):
        assert self.saved_inventory_item['name'] == self.inventory_item['name']

    def test_it_should_have_the_correct_quantity(self):
        assert self.saved_inventory_item['quantity'] == self.inventory_item[
            'quantity']

    def test_it_should_have_the_correct_size(self):
        assert self.saved_inventory_item['size'] == self.inventory_item['size']

    def test_it_should_have_the_correct_uom(self):
        assert self.saved_inventory_item['uom'] == self.inventory_item['uom']

    def test_it_should_have_the_correct_image(self):
        assert self.saved_inventory_item['image'] == self.inventory_item[
            'image']

    repo.delete(_id)
    def test_it_should_raise_an_error_on_name_missing(self):
        inventory_item = {'_id': '123456'}
        with pytest.raises(ValueError) as e:
            repo.save(inventory_item)

        assert 'Missing required field: name' in str(e.value)