Ejemplo n.º 1
0
def test_update_list(client, list_, access_token, variables):
    url = url_for("graphql")

    list_id = to_global_id("TypeList", list_.id)
    res = client.post(
        url,
        headers={"Authorization": f"Bearer {access_token}"},
        json={
            "query": update_list_query,
            "variables": {
                "id": list_id,
                **variables
            }
        },
    )

    assert res.status_code == HTTPStatus.OK

    res = res.json
    assert res["data"]["updateList"]["list"]

    updated_list = List.get(id=list_.id)
    if variables.get("name"):
        assert updated_list.name == variables["name"]
        assert updated_list.slug == slugify(variables["name"])
    else:
        assert updated_list.name == list_.name
        assert updated_list.slug == list_.slug

    if "description" in variables:
        assert updated_list.description == variables["description"]
    else:
        assert updated_list.description == list_.description
Ejemplo n.º 2
0
def deleting_list(msg):
    user = User.get_by_id(msg.chat.id)
    if msg.text.startswith("🔙 "):
        bot.send_message(msg.chat.id,
                         _("Canceled"),
                         reply_markup=mps.main_mp(user.id))
        return
    try:
        list_name = msg.text[4:]
        list_ = List.get((List.name == list_name) & (List.owner == user))
    except (IndexError, DoesNotExist):
        bot.send_message(
            msg.chat.id,
            _("This list doesn't exist, choose from keyboard below"),
            reply_markup=mps.delete_list_mp(user.id))
        bot.register_next_step_handler_by_chat_id(user.id, deleting_list)
        return
    if list_ == list_.subscribed_by:
        for sub in List.select().where(List.subscribed_by == list_):
            bot.delete_message(sub.owner.id, sub.last_message_id)
            sub.delete_instance()
            bot.send_message(sub.owner.id,
                             _("List _%s_ was deleted") % sub.name,
                             reply_markup=mps.main_mp(sub.owner.id),
                             parse_mode='markdown',
                             disable_notification=True)
    else:
        bot.delete_message(msg.chat.id, list_.last_message_id)
        list_.delete_instance()
        bot.send_message(
            msg.chat.id,
            _("You were successfully unsubscribed from list _%s_ ") %
            list_name,
            reply_markup=mps.main_mp(msg.chat.id),
            parse_mode='markdown')
Ejemplo n.º 3
0
    def test_post_update(self):
        response = self.post("/admin/api/v1/service-lists/foo",
                    data={"name": "bar"})
        self.assertEquals(response.headers["Content-Type"], "application/json")
        self.assertEquals(response.status_code, 200)

        service = List.get(self.service_list.key())
        self.assertEquals(service.name, "bar")
Ejemplo n.º 4
0
    def test_post_update_desc(self):
        response = self.post("/admin/api/v1/service-lists/foo",
                data={"description": "hello"})
        self.assertEquals(response.headers["Content-Type"], "application/json")
        self.assertEquals(response.status_code, 200)

        service = List.get(self.service_list.key())
        self.assertEquals(service.description, "hello")
Ejemplo n.º 5
0
    def test_post_update(self):
        response = self.post("/admin/api/v1/service-lists/foo",
                             data={"name": "bar"})
        self.assertEquals(response.headers["Content-Type"], "application/json")
        self.assertEquals(response.status_code, 200)

        service = List.get(self.service_list.key())
        self.assertEquals(service.name, "bar")
Ejemplo n.º 6
0
    def test_post_update_desc(self):
        response = self.post("/admin/api/v1/service-lists/foo",
                             data={"description": "hello"})
        self.assertEquals(response.headers["Content-Type"], "application/json")
        self.assertEquals(response.status_code, 200)

        service = List.get(self.service_list.key())
        self.assertEquals(service.description, "hello")
Ejemplo n.º 7
0
def share_table(q: types.InlineQuery):
    list_ = List.get((List.owner == q.from_user.id) & (List.name == q.query))
    bot.answer_inline_query(q.id,
                            mps.inline_share_list((list_, ), me),
                            cache_time=5,
                            is_personal=True,
                            switch_pm_text=_("➕ Create list ➕"),
                            switch_pm_parameter='createlist')
Ejemplo n.º 8
0
def name_changer(msg: types.Message):
    try:
        list_ = List.get(List.name == msg.reply_to_message.text[2:])
        bot.edit_message_text(f"📝 *{msg.text}*",
                              msg.chat.id,
                              list_.last_message_id,
                              parse_mode='markdown',
                              reply_markup=mps.list_mp(list_.id))
        list_.name = msg.text
        list_.save()
        bot.send_message(msg.chat.id,
                         _("List name changed."),
                         reply_markup=mps.main_mp(msg.chat.id))
    except (DoesNotExist, IndexError):
        pass
Ejemplo n.º 9
0
def show_list(msg):
    user = User.get_by_id(msg.chat.id)
    if msg.text.startswith("🔗 "):
        list_name = msg.text[4:]
    else:
        list_name = msg.text[2:]
    try:
        list_ = List.get((List.owner == user) & (List.name == list_name))
    except DoesNotExist:
        bot.send_message(user.id,
                         _("This list doesn't exist"),
                         reply_markup=mps.main_mp(user.id))
        return
    list_name = msg.text
    new_list_msg = bot.send_message(chat_id=user.id,
                                    text=f"*{list_name}*",
                                    parse_mode='markdown',
                                    reply_markup=mps.list_mp(list_.id))
    try:
        bot.delete_message(msg.chat.id, list_.last_message_id)
    except telebot.apihelper.ApiException:
        pass
    list_.last_message_id = new_list_msg.message_id
    list_.save()
Ejemplo n.º 10
0
def get_List_Object(market):
    listObject = List.get(List.market == market)
    return listObject
Ejemplo n.º 11
0
def get_Mini_Sellers_ListNumbers(sellersListName):
    sellersListNumbers = []
    sellersList = List.get(List.name == sellersListName)
    for listRelationship in ListRelationship.select().where(ListRelationship.listName == sellersList):
        sellersListNumbers.append(listRelationship.number)
    return sellersListNumbers
Ejemplo n.º 12
0
def get_Mini_List(name):
    l = List.get(List.name == name)
    return l
Ejemplo n.º 13
0
def get_Mini_Sellers_List(seller, name):
    l = List.get(List.name == name and List.seller == seller)
    return l
Ejemplo n.º 14
0
	def get(self, list_id=None):
		if not list_id:
			return self._get_all()
		_list = objList.get(list_id)
		return jsonify(_list)