Beispiel #1
0
def test_update_random_group_name(app):
    if app.group.count() == 0:
        app.group.create(Group(name="Group to be updated"))
    old_groups = app.group.get_group_list()
    index = randrange(len(old_groups))
    group = Group(name="Updated Group Name")
    group.id = old_groups[index].id
    app.group.update_group_by_index(group, index)
    assert len(old_groups) == app.group.count()
    new_groups = app.group.get_group_list()
    group.header = old_groups[index].header
    group.footer = old_groups[index].footer
    group.id = old_groups[index].id
    old_groups[index] = group
    assert sorted(old_groups, key=Group.id_or_max) == sorted(new_groups, key=Group.id_or_max)
Beispiel #2
0
def test_modify_group(app, db, check_ui):
    with allure.step("If there are no group create one"):
        if len(db.get_group_list()) == 0:
            app.group.create(Group(name="Group for modification"))
    with allure.step("Given a list of groups and the data for modification"):
        old_groups = db.get_group_list()
        old_group = random.choice(old_groups)
        group = Group()
        # Prepare data
        group.name = "%s %s" % (old_group.name, RandomData.get_random_string())
        group.header = "%s %s" % (old_group.header,
                                  RandomData.get_random_string())
        group.footer = "%s %s" % (old_group.footer,
                                  RandomData.get_random_string())
        group.id = old_group.id
    with allure.step("When modifying the group"):
        app.group.modify_by_id(group.id, group)
    with allure.step(
            "Then the new list of groups is equal to the old list with a modified group"
    ):
        new_groups = db.get_group_list()
        old_groups.remove(old_group)
        old_groups.append(group)
        assert sorted(old_groups,
                      key=Group.id_or_max) == sorted(new_groups,
                                                     key=Group.id_or_max)
        if check_ui:
            for i in range(0, len(new_groups)):
                new_groups[i] = new_groups[i].clear()
            assert sorted(new_groups, key=Group.id_or_max) == sorted(
                app.group.get_group_list(), key=Group.id_or_max)
Beispiel #3
0
def test_modify_group_name(app, db, check_ui):
    with allure.step("If there are no groups create one"):
        if len(db.get_group_list()) == 0:
            app.group.create(Group(name="Group for modification"))
    with allure.step("Given a list of groups"):
        old_groups = db.get_group_list()
        old_group = random.choice(old_groups)
        group = Group(name="Only name " + str(old_group.id))
        group.id = old_group.id
    with allure.step("When modifying only the name of the group"):
        app.group.modify_by_id(old_group.id, group)
    with allure.step(
            "Then the new list of groups is equal to the old list with a modified group"
    ):
        new_groups = db.get_group_list()
        old_groups.remove(old_group)
        old_groups.append(group.clear())
        assert sorted(old_groups,
                      key=Group.id_or_max) == sorted(new_groups,
                                                     key=Group.id_or_max)
        if check_ui:
            for i in range(0, len(new_groups)):
                new_groups[i] = new_groups[i].clear()
            assert sorted(new_groups, key=Group.id_or_max) == sorted(
                app.group.get_group_list(), key=Group.id_or_max)
Beispiel #4
0
    def get_groups(self, uname):
        # get all groups for this user
        group = None
        user_groups = None
        try:
            collection = self.user_collection
            user_groups = collection.find_one({'_id':uname},{"groups":True})
        except Exception as inst:
            print "error reading groups"
            print inst

        if user_groups != None:
            
            group_cursor = user_groups["groups"]
            groups = []

            for item in group_cursor:
                print item
                group = Group()
                group.id = str(item["_id"])
                group.name = item["name"]
                group.hash = item["hash"]

                groups.append(group)

            return groups
        else:
            return None
Beispiel #5
0
def test_edit_group_name(app, db, check_ui):

    if app.group.count() == 0: # falls keine Gruppe gibt´s

        app.group.create(Group(name="New_group")) # erstellen wir eine Gruppe

    old_groups = db.get_group_list() # Liste der Gruppen bevors Hinzufügen einer neuen Gruppe

   # index = randrange(len(old_groups))

    group = random.choice(old_groups)

    old_groups.remove(group)

    edit_group = Group(name="Edit_group")

    edit_group.id = group.id          # eine id von der alte gruppe behalten wir bei

    old_groups.append(edit_group)

    app.group.edit_group_by_id(group.id, edit_group)

    new_groups = db.get_group_list()

    #assert len(old_groups) == len(new_groups)

    assert sorted(new_groups, key=Group.id_or_max) == sorted(old_groups, key=Group.id_or_max)

    if check_ui:
        assert sorted(new_groups, key=Group.id_or_max) == sorted(app.group.get_group_list(), key=Group.id_or_max)
def test_edit_random_group(app, db, check_ui):
    with allure.step('Create group if not exists'):
        if app.group.count() == 0:
            app.group.create(
                Group(name="created group",
                      footer="created logo of group",
                      header="created comment for group"))
        group = Group(name="edited_test group",
                      footer="edited_logo of group",
                      header="edited_comment for group")
    with allure.step('Get group list from DB'):
        old_groups = db.get_group_list()
    with allure.step('Get random group'):
        group_for_edit = random.choice(old_groups)
        id = group_for_edit.id
        group.id = id
    with allure.step('Edit group %s' % group_for_edit):
        app.group.edit_by_id(group_for_edit.id, group)
    with allure.step('Verify group was edited'):
        new_groups = db.get_group_list()
        assert len(old_groups) == len(new_groups)
        for i in range(len(old_groups)):
            if old_groups[i].id == group_for_edit.id:
                old_groups[i] = group
        assert sorted(old_groups,
                      key=Group.id_or_max) == sorted(new_groups,
                                                     key=Group.id_or_max)
        if check_ui:
            assert sorted(new_groups, key=Group.id_or_max) == sorted(
                app.group.get_group_list(), key=Group.id_or_max)
Beispiel #7
0
def test_modify_group_name(
        app, db, check_ui):  #модификация случайной группы- проверки из БД
    group = Group(name="Моя группа", header="Моя группа", footer="Моя группа"
                  )  #значение, на  которое будем менять выбранную группу
    if len(db.get_group_list()) == 0:  #предусловие
        app.group.create(group)
    old_groups = db.get_group_list()  #читаем группы до модификации
    old_group = random.choice(
        old_groups)  # выбираем случайную группу из старого списка групп
    group.id = old_group.id  # меняем id у новой группы на тот, который есть у группы, кот.собираемся менять
    app.group.modify_group_by_id(
        old_group.id, group
    )  #модифицируем у группы,выбранной по id, значения (имя, header,footer)
    new_groups = db.get_group_list()  #читаем группы после модификации
    old_groups.remove(old_group)  #удаляем из списка старую группу
    old_groups.append(group)  #добавляем новую группу
    assert sorted(old_groups,
                  key=Group.id_or_max) == sorted(new_groups,
                                                 key=Group.id_or_max)
    if check_ui:
        ui_list = app.group.get_groups_list()  # список, загруженный через UI##
        clean = app.group.clean_name()
        db_list = map(clean,
                      db.get_group_list())  # список, загруженный через БД
        assert sorted(db_list,
                      key=Group.id_or_max) == sorted(ui_list,
                                                     key=Group.id_or_max)
Beispiel #8
0
def test_edit_group_by_id(app, db, check_ui):
    if app.group.count() == 0:
        app.group.create(Group(name="wwww", header="qqqq", footer="rrrr"))
    old_groups = db.get_group_list()
    index = randrange(len(old_groups))
    group = Group(name="xxxx", header="yyyyy", footer="zzzz")
    group.id = old_groups[index].id
    app.group.edit_group_by_id(group, group.id)
    new_groups = db.get_group_list()
    old_groups[index] = group
    assert sorted(old_groups, key=Group.id_or_max) == sorted(new_groups, key=Group.id_or_max)
    if check_ui:
        assert sorted(new_groups, key=Group.id_or_max) == sorted(app.group.get_group_list(), key=Group.id_or_max)

# Редактирование группы по индексу
#def test_edit_group(app):
#    if app.group.count() == 0:
#        app.group.create(Group(name="wwww", header="qqqq", footer="rrrr"))
#    old_groups = app.group.get_group_list()
#    index = randrange(len(old_groups))
#    group = Group(name="xxxx", header="yyyyy", footer="zzzz")
#    group.id = old_groups[index].id
#    app.group.edit_group_by_index(group, index)
#    new_groups = app.group.get_group_list()
#    assert len(old_groups) == len(new_groups)
#    old_groups[index] = group
#    assert sorted(old_groups, key=Group.id_or_max) == sorted(new_groups, key=Group.id_or_max)
Beispiel #9
0
def test_edit_some_group(app, db, check_ui):
    if app.group.count() == 0:
        app.group.create(
            Group(name="test group",
                  header="test group header",
                  footer="test group footer"))
    with allure.step('Select group for edit'):
        old_groups = db.get_group_list()
        group_to_edit = random.choice(old_groups)
        group = Group(name="testEdit group",
                      header="testEdit group header",
                      footer="testEdit group footer")
        group.id = group_to_edit.id
    with allure.step('Edit selected group'):
        app.group.edit_group_by_id(group, group.id)
    with allure.step('Check that group is edited'):
        assert len(old_groups) == app.group.count()
        new_groups = db.get_group_list()
        old_groups[old_groups.index(group_to_edit)] = group
        assert sorted(old_groups,
                      key=Group.id_or_max) == sorted(new_groups,
                                                     key=Group.id_or_max)
        if check_ui:
            assert sorted(new_groups, key=Group.id_or_max) == sorted(
                app.group.get_group_list(), key=Group.id_or_max)
def test_modify_group(app, db, check_ui):
    if len(db.get_group_list()) == 0:
        test_group = Group()
        test_group.dummy()
        app.group.create(test_group)

    old_groups = db.get_group_list()

    group = random.choice(old_groups)

    test_group_new = Group(name = "random")
    test_group_new.id = group.id

    app.group.modify_by_id(group.id, test_group_new)

    new_groups = db.get_group_list()

    assert len(old_groups) == len(new_groups)

    old_groups[old_groups.index(group)] = test_group_new

    assert old_groups == new_groups

    if check_ui:
        assert sorted(map(clean, new_groups), key = Group.id_or_max) == \
            sorted(app.group.get_group_list(), key = Group.id_or_max)
Beispiel #11
0
def test_edit_first_group_name(app, db):
    # Если список групп отсутствует его необходимо создать
    if app.group.count() == 0:
        app.group.create(
            Group(name="Group1",
                  header="Group1_Header",
                  footer="Group1_Footer"))
    # Получение списка групп из пользовательского интерфейса
    #old_groups = app.group.get_group_list()
    # Получение списка групп из БД
    old_groups = db.get_group_list()
    # Генерируем индекс в пределах полученного списка
    index = randrange(len(old_groups))
    # Создаем новый объект по которому будут изменения
    group = Group(name="Edit_name",
                  header="Group1_Header",
                  footer="Group1_Footer")
    # Получаем ид элемента у у объекта с сгенерированным индексом
    group.id = old_groups[index].id
    # Изменяем выбранный элемент
    app.group.edit_group_by_index(group, index)
    # Получение списка групп из пользовательского интерфейса
    #new_groups = app.group.get_group_list()
    new_groups = db.get_group_list()
    # Сравнивваем длинну списков до изменения и после изменения
    assert len(old_groups) == len(new_groups)
    # Присваиваем рпанее полученному объекту с выбранным индексом новое значение поля
    old_groups[index] = group
    # Сравниваем отсортированные списки групп до изменения и после
    assert sorted(old_groups,
                  key=Group.id_or_max) == sorted(new_groups,
                                                 key=Group.id_or_max)
def test_modify_some_group(app, db, check_ui):
    if len(db.get_group_list()) == 0:
        app.group.create(Group(name='', header="", footer=""))
    old_groups = db.get_group_list()
    index = randrange(len(old_groups))
    group = Group(name="Group_Mod",
                  header="Test 08.02.21_mod",
                  footer="test 08.02.21_mod")
    group.id = old_groups[index].id
    app.group.modify_group_by_id(group.id, group)
    assert len(old_groups) == app.group.count()
    new_groups = db.get_group_list()
    old_groups[index] = group
    assert sorted(old_groups,
                  key=Group.id_or_max) == sorted(new_groups,
                                                 key=Group.id_or_max)
    if check_ui:
        assert sorted(new_groups, key=Group.id_or_max) == sorted(
            app.group.get_group_list(), key=Group.id_or_max)


#def test_modify_some_group(app):
#    if app.group.count() == 0:
#        app.group.create(Group(name='', header="", footer=""))
#    old_groups = app.group.get_group_list()
#    index = randrange(len(old_groups))
#    group = Group(name="Group_Mod", header="Test 08.02.21_mod", footer="test 08.02.21_mod")
#    group.id = old_groups[index].id
#    app.group.modify_group_by_index(index, group)
#    assert len(old_groups) == app.group.count()
#    new_groups = app.group.get_group_list()
#    old_groups[index] = group
#    assert sorted(old_groups, key=Group.id_or_max) == sorted(new_groups, key=Group.id_or_max)
def test_edit_any_group(app):
    if app.group.count() == 0:
        group = Group().set_all_parameters_to_random_value()
        app.group.create(group)
    old_groups = app.group.get_group_list()
    group_new_state = Group().set_random_parameters_to_random_value()

    # get id of randomly chosen group
    group_id = app.group.edit_any_group(group_new_state)

    # check len of list was not changed
    assert app.group.count() == len(old_groups)

    # next(iterator, None) returns first group by condition or None if no element found
    # but we already got its id, so element exists! And we will not get None
    # so we can replace old group by new_state with new id is set
    edited_group = next(
        (group for group in old_groups if group.id == group_id), None)
    index = old_groups.index(edited_group)
    group_new_state.id = group_id
    old_groups[index] = group_new_state

    # if new list length is correct, then we can compare lists.
    # so we can get new list
    new_groups = app.group.get_group_list()

    # check equalizing of sorted lists
    assert new_groups.sort() == old_groups.sort()
Beispiel #14
0
def test_modify_group_name(app, db):
    if app.group.count() == 0:
        app.group.create()
    old_groups = db.get_group_list()
    index = randrange(len(old_groups))
    group = Group(name="test")
    group.id = old_groups[index].id
    app.group.modify_group_by_index(index, group)
    assert len(old_groups) == app.group.count()
    new_groups = db.get_group_list()
    old_groups[index] = group
    assert sorted(old_groups,
                  key=Group.id_or_max) == sorted(new_groups,
                                                 key=Group.id_or_max)


#def test_modify_group_header(app):
#    old_groups = app.group.get_group_list()
#    if app.group.count() == 0:
#        app.group.create(Group(name = "test"))
#    app.group.modify_first_group((Group(header="New header")))
#    new_groups = app.group.get_group_list()
#    assert len(old_groups) == len(new_groups)

#def test_modify_group_footer(app):
#    old_groups = app.group.get_group_list()
#    if app.group.count() == 0:
#        app.group.create(Group(name = "test"))
#    app.group.modify_first_group((Group(footer="New footer")))
#    new_groups = app.group.get_group_list()
#    assert len(old_groups) == len(new_groups)
Beispiel #15
0
def test_edit_group_name(app):
    if app.group.count() == 0:
        app.group.create(Group(name="test", header="test", footer="test"))
    old_groups = app.group.get_group_list()
    index = randrange(len(old_groups))
    group = Group(name="new")
    group.id = old_groups[index].id
    app.group.edit_group_by_index(index, group)
    new_groups = app.group.get_group_list()
    assert len(old_groups) == len(new_groups)
    old_groups[index]=group
    assert sorted(old_groups, key=Group.id_or_max) == sorted(new_groups, key=Group.id_or_max)


#def test_edit_group_header(app):
#    if app.group.count() == 0:
#        app.group.create(Group(name="test", header="test", footer="test"))
#    old_groups = app.group.get_group_list()
#    group = Group(header="new")
#    group.id = old_groups[0].id
#    app.group.edit_first_group(group)
#    new_groups = app.group.get_group_list()
#    assert len(old_groups) == len(new_groups)
#    old_groups[0]=group
#    assert sorted(old_groups, key=Group.id_or_max) == sorted(new_groups, key=Group.id_or_max)
def test_edit_some_group_name(app, db, check_ui):
    with allure.step('When no groups presented in list'):
        if app.group.count() == 0:
            app.group.create(
                Group(name="test name",
                      header="test header",
                      footer="test footer"))
    with allure.step('Given a group list'):
        old_groups = db.get_group_list()
    with allure.step('Random group selected'):
        random_index = randrange(len(old_groups))
        group = old_groups[random_index]
    with allure.step('Given a new data for group'):
        updated_group = Group(name="New test group")
        updated_group.id = group.id
    with allure.step('When I edit a group to new one %s' % updated_group):
        app.group.modify_group_by_id(group.id, updated_group)
        new_groups = db.get_group_list()
    with allure.step(
            'Then the new group list is equal to the old list without modified group'
    ):
        assert len(old_groups) == len(new_groups)
        old_groups[random_index] = updated_group
        assert sorted(old_groups,
                      key=Group.id_or_max) == sorted(new_groups,
                                                     key=Group.id_or_max)
        if check_ui:
            assert sorted(new_groups, key=Group.id_or_max) == sorted(
                app.group.get_group_list(), key=Group.id_or_max)
Beispiel #17
0
def test_edit_some_group(app, db, check_ui):
    if len(db.get_group_list()) == 0:
        app.group.create(Group(name="test1", header="test11",
                               footer="test111"))
    with allure.step("Given a non-empty group list"):
        old_groups = db.get_group_list()
    with allure.step("Given a random group from the list"):
        edit_group = random.choice(old_groups)
    with allure.step("Given a new data for edited group"):
        group = Group(name="group2", header="group22", footer="group222")
        group.id = edit_group.id
    with allure.step("When I edit the group %s from list" % group):
        app.group.edit_group_by_id(edit_group.id, group)
    with allure.step(
            "Then the new group list is equal to the old with the edit group"):
        new_groups = db.get_group_list()
        assert len(old_groups) == len(new_groups)
        old_groups.remove(edit_group)
        old_groups.append(group)
        assert sorted(old_groups,
                      key=Group.id_or_max) == sorted(new_groups,
                                                     key=Group.id_or_max)
        if check_ui:
            assert sorted(new_groups, key=Group.id_or_max) == sorted(
                app.group.get_group_list(), key=Group.id_or_max)
def test_modify_group_name(app, db, check_ui):
    if len(db.get_group_list()
           ) == 0:  # Если в базе данных нет групп, создаем группу
        app.group.create(
            Group(name="Group Test",
                  header="Header Test",
                  footer="Footer Test"))  # Создаём новую группу
    group = Group(name="New Group", header="New Header",
                  footer="New Footer")  # Новые параметры заносим в переменную
    old_groups = db.get_group_list(
    )  # Получение списка групп из БД до модификации
    index = randrange(
        len(old_groups))  # Получение номера случайной группы для модификации
    group.id = old_groups[index].id  # Получаем id выбранной группы
    app.group.modify_group_by_id(group.id,
                                 group)  # Модифицируем выбранную группу по id
    new_groups = db.get_group_list(
    )  # Сохранение списка групп ПОСЛЕ модификации
    old_groups[
        index] = group  # Добавляем параметры в выбранную группу по index
    # Сравниваем отсортированные по ключу (id) списки групп
    assert sorted(old_groups,
                  key=Group.id_or_max) == sorted(new_groups,
                                                 key=Group.id_or_max)
    if check_ui:  # Включение проверки графического интерфейса при наличии ключа "--check_ui"
        # Сравниваем отсортированные по ключу (id) списки групп
        assert sorted(new_groups, key=Group.id_or_max) == sorted(
            app.group.get_group_list(), key=Group.id_or_max)
def test_edit_any_group(app, db, check_ui):
    with allure.step(f'Given non-empty group list'):
        if len(db.get_group_list()) == 0:
            group = Group().set_all_parameters_to_random_value()
            app.group.create(group)
        old_groups = db.get_group_list()

    with allure.step(f'Given new state for group to edit'):
        group_new_state = Group().set_random_parameters_to_random_value()

    with allure.step(f'When edit random group to new state {group_new_state}'):
        # get id of randomly chosen group
        group_id = app.group.edit_any_group(group_new_state)

    with allure.step(f'Then group list count is not changed'):
        # check len of list was not changed
        assert app.group.count() == len(old_groups)

    with allure.step(f'Then new group list is equals to the old group list with 1 group changed'):
        # next(iterator, None) returns first group by condition or None if no element found
        # but we already got its id, so element exists! And we will not get None
        # so we can replace old group by new_state with new id is set
        edited_group = next((group for group in old_groups if group.id == group_id), None)
        index = old_groups.index(edited_group)
        group_new_state.id = group_id
        old_groups[index].update(group_new_state)

        # if new list length is correct, then we can compare lists.
        # so we can get new list
        new_groups = db.get_group_list()

        # check equalizing of sorted lists
        assert sorted(new_groups) == sorted(old_groups)
        if check_ui:
            assert sorted(new_groups) == sorted(app.group.get_group_list())
def test_edit_group_name(app, db, check_ui):
    if app.group.count() == 0:
        app.group.create(Group(name="test"))
    old_groups = db.get_group_list()
    index = randrange(len(old_groups))
    group = Group(name="uweywu")
    group.id = old_groups[index].id
    app.group.edit_group_by_id(group.id, group)
    new_groups = app.group.get_group_list()
    assert len(old_groups) == len(new_groups)
    old_groups[index] = group
    assert sorted(old_groups,
                  key=Group.id_or_max) == sorted(new_groups,
                                                 key=Group.id_or_max)
    if check_ui:
        new_groups = map(app.group.clean_group_name, db.get_group_list())
        assert sorted(new_groups, key=Group.id_or_max) == sorted(
            app.group.get_group_list(), key=Group.id_or_max)


# def test_edit_group_header(app):
#     if app.group.count() == 0:
#         app.group.create(Group(name="test"))
#     old_groups = app.group.get_group_list()
#     index = randrange(len(old_groups))
#     group = Group(header="leiiwwq")
#     group.id = old_groups[index].id
#     app.group.edit_group_by_index(index, group)
#     new_groups = app.group.get_group_list()
#     assert len(old_groups) == len(new_groups)
#     old_groups[index] = group
#     assert sorted(old_groups, key=Group.id_or_max) == sorted(new_groups, key=Group.id_or_max)
def test_modify_group_name(app):
    if app.group.count() == 0:
        app.group.create(Group(name="test"))
    old_groups = app.group.get_group_list()
    index = randrange(len(old_groups))
    app.group.open_groups_page()
    group = Group(name="New group")
    group.id = old_groups[index].id
    app.group.modify_group_by_index(index, group)
    app.contact.return_to_home()
    new_groups = app.group.get_group_list()
    assert len(old_groups) == len(new_groups)
    old_groups[index] = group
    assert sorted(old_groups,
                  key=Group.id_or_max) == sorted(new_groups,
                                                 key=Group.id_or_max)


#def test_modify_group_header(app):
#if app.group.count() == 0:
#app.group.create(Group(header="test"))
#old_groups = app.group.get_group_list()
#app.group.open_groups_page()
#app.group.modify_first_group(Group(header="New header"))
#app.contact.return_to_home()
#new_groups = app.group.get_group_list()
#assert len(old_groups) == len(new_groups)
def test_modify_group_name(app):
    group = Group(name="To be modified")
    if app.group.count() == 0:
        app.group.create(Group(name="New group name"))
    old_groups = app.group.get_group_list()
    index = randrange(len(old_groups))
    group.id = old_groups[index].id
    app.group.modify_group_by_index(group, index)
    assert len(old_groups) == app.group.count()
    new_groups = app.group.get_group_list()
    old_groups[index] = group
    assert sorted(old_groups, key = Group.id_or_max) == sorted(new_groups, key = Group.id_or_max)

# def test_modify_group_header(app):
#     if app.group.count() == 0:
#         app.group.create(Group(header="To be modified"))
#     app.group.modify_first_group(Group(header="New group header"))
#     old_groups = app.group.get_group_list()
#     new_groups = app.group.get_group_list()
#     assert len(old_groups) == len(new_groups)
#
# def test_modify_group_footer(app):
#     if app.group.count() == 0:
#         app.group.create(Group(footer="To be modified"))
#     app.group.modify_first_group(Group(footer="New group footer"))
#     old_groups = app.group.get_group_list()
#     new_groups = app.group.get_group_list()
#     assert len(old_groups) == len(new_groups)
def test_editing_some_name(app, db, check_ui):
    if len(db.get_group_list()) == 0:
        app.group.create(Group(name="test"))
    old_groups = db.get_group_list()
    group = random.choice(old_groups)
    new_group_date = Group(name="New group")
    new_group_date.id = group.id
    app.group.editing_group_by_id(group.id, new_group_date)
    new_groups = db.get_group_list()
    old_groups.remove(group)
    old_groups.append(new_group_date)
    assert sorted(old_groups,
                  key=Group.id_or_max) == sorted(new_groups,
                                                 key=Group.id_or_max)
    if check_ui:
        groups_from_ui = app.group.get_group_list()

        def clean(group):
            return Group(id=group.id, name=group.name.strip())

        groups_from_db = map(clean, new_groups)
        assert sorted(groups_from_db,
                      key=Group.id_or_max) == sorted(groups_from_ui,
                                                     key=Group.id_or_max)


#def test_editing_first_header(app):
#    old_groups = app.group.get_group_list()
#    app.group.editing_first_group(Group(header="New header"))
#    new_groups = app.group.get_group_list()
#    #сделаем простую проверку, убедимся, что новый список длинее чем старый на ед-цу
#    assert len(old_groups) == len(new_groups)
Beispiel #24
0
def test_modify_some_group(app, db, check_ui):
    if len(db.get_group_list()) == 0:
        app.group.create(Group(name="test"))
    old_groups = db.get_group_list()
    modified_group = random.choice(old_groups)
    group = Group(name="modified", header="modified", footer="modified")
    group.id = modified_group.id
    app.group.modify_by_id(group, group.id)
    assert len(old_groups) == app.group.count()
    new_groups = db.get_group_list()
    index = old_groups.index(modified_group)
    old_groups[index] = group
    assert sorted(old_groups,
                  key=Group.id_or_max) == sorted(new_groups,
                                                 key=Group.id_or_max)
    if check_ui:
        assert sorted(new_groups, key=Group.id_or_max) == sorted(
            app.group.get_group_list(), key=Group.id_or_max)


#def test_modify_group_name(app):
#    if app.group.count() == 0:
#        app.group.create(Group(name="test"))
#    old_groups = app.group.get_group_list()
#    app.group.modify_first(Group(name="New group"))
#    new_groups = app.group.get_group_list()
#    assert len(old_groups) == len(new_groups)

#def test_modify_group_header(app):
#    if app.group.count() == 0:
#        app.group.create(Group(name="test"))
#    old_groups = app.group.get_group_list()
#    app.group.modify_first(Group(header="New header"))
#    new_groups = app.group.get_group_list()
#    assert len(old_groups) == len(new_groups)
def test_add_contact_in_group(app, db, check_ui):
    new_contact = Contact(first_name="name_" + str(random.randint(1, 9999)),
                          last_name="aosdksp" + str(random.randint(1, 9999)),
                          address="somewhere",
                          birthday="25-November-1765")
    new_group = Group(name="superGroup" + str(random.randint(1, 9999)),
                      header="abcd",
                      footer="asd6577")

    old_contacts_list = db.get_contact_list()
    old_groups = db.get_group_list()
    #Create contact and check
    app.contact.add(new_contact)
    new_contacts_list = db.get_contact_list()
    old_contacts_list.append(new_contact)
    assert sorted(old_contacts_list, key=Contact.id_or_max) == sorted(new_contacts_list, key=Contact.id_or_max), \
        "Contact wasn't added"
    #Create group and check
    app.group.create(new_group)
    new_group.id = db.get_group_id(new_group)
    new_groups = db.get_group_list()
    old_groups.append(new_group)
    assert sorted(old_groups, key=Group.id_or_max) == sorted(new_groups, key=Group.id_or_max) , \
        "Group wasn't added"

    #Add contact to the group
    app.contact.add_contact_to_group(new_contact, new_group)
    assert db.is_contact_in_group(
        new_contact, new_group), "Contact wasn't added to the group"
    if check_ui:
        assert app.contact.is_contact_in_group(
            new_contact, new_group), "Contact wasn't added to the group"
def test_edit_some_group(app):
    if app.group.count() == 0:
        app.group.create(Group(name="for edition"))
    old_groups = app.group.get_groups_list()
    group = Group("EditName", "EditHeader", "EditFooter")
    index = randrange(len(old_groups))
    group.id = old_groups[index].id
    app.group.edit_group_by_index(group, index)
    assert len(old_groups) == app.group.count()
    new_groups = app.group.get_groups_list()
    old_groups[index] = group
    assert sorted(old_groups,
                  key=Group.id_or_max) == sorted(new_groups,
                                                 key=Group.id_or_max)


#def test_edit_first_group_name(app):
#   if app.group.count() == 0:
#       app.group.create(Group(name="for edition"))
#   old_groups = app.group.get_groups_list()
#  app.group.edit_first(Group(name="JustName"))
#  new_groups = app.group.get_groups_list()
#  assert len(old_groups) == len(new_groups)

#def test_edit_first_group_header(app):
# if app.group.count() == 0:
#     app.group.create(Group(name="for edition"))
#old_groups = app.group.get_groups_list()
# app.group.edit_first(Group(header="JustHeader"))
# new_groups = app.group.get_groups_list()
# assert len(old_groups) == len(new_groups)
Beispiel #27
0
def test_modify_group_name(app):
    # Проверяем наличие групп. Если их нет, то создаем.
    if app.group.count() == 0:
        app.group.create(Group(name="test"))
    # Получаем старый список групп
    old_groups = app.group.get_group_list()
    # Вычисляем случайный индекс модифицируемой группы и длинны списка групп
    index = randrange(len(old_groups))
    # Создаем локальную переменную для передачи в не объекта модифицируемой группы
    group = Group(name="New group")
    # Сохраняем ид модифицируемой группы из старого списка  и присваиваем его первому элементу списка который будем
    # добавлять для сравнения. Нужно для сравнения. т.к. ид измениться не должен.
    group.id = old_groups[index].id
    # Модификация первой группы. Изменение имени.
    app.group.modify_group_by_index(group, index)
    # Получаем новый список групп
    new_groups = app.group.get_group_list()
    # Проверяем что длина предыдущего списка групп равнасписку групп после изменения
    assert len(old_groups) == len(new_groups)
    # Присваиваем первому элементу списка с которым будем сравнивать, сохраненный ранее элемент с полученным из него ид.
    old_groups[index] = group
    assert sorted(old_groups,
                  key=Group.id_or_max) == sorted(new_groups,
                                                 key=Group.id_or_max)
    # Возврат на страницу со списком групп
    app.session.return_home_page()
def test_modify_group(app, db, check_ui):
    if len(db.get_group_list()) == 0:
        test_group = Group()
        test_group.dummy()
        app.group.create(test_group)

    old_groups = db.get_group_list()

    group = random.choice(old_groups)

    test_group_new = Group(name="random")
    test_group_new.id = group.id

    app.group.modify_by_id(group.id, test_group_new)

    new_groups = db.get_group_list()

    assert len(old_groups) == len(new_groups)

    old_groups[old_groups.index(group)] = test_group_new

    assert old_groups == new_groups

    if check_ui:
        assert sorted(map(clean, new_groups), key = Group.id_or_max) == \
            sorted(app.group.get_group_list(), key = Group.id_or_max)
Beispiel #29
0
def test_edit_some_group(app, db, check_ui):
    group = Group(name="Some name", header="Some header", footer="Some footer")
    if len(db.get_group_list()) == 0:
        app.group.create(group)
    old_groups = db.get_group_list()
    random_group = random.choice(old_groups)
    app.group.modify_group_by_id(random_group.id, group)
    # assert len(old_groups) == app.group.count()
    new_groups = db.get_group_list()
    # need to select group with same id from the list of old groups and replace with already edited group
    group.id = random_group.id
    old_groups.remove(random_group)
    old_groups.append(group)
    assert sorted(old_groups,
                  key=Group.id_or_max) == sorted(new_groups,
                                                 key=Group.id_or_max)

    def clean(group):
        return Group(id=group.id, name=group.name.strip())

    new_groups = map(clean, db.get_group_list())
    if check_ui:
        assert sorted(new_groups, key=Group.id_or_max) == sorted(
            app.group.get_group_list(), key=Group.id_or_max)


#def test_edit_first_group_header(app):
#    if app.group.count() == 0:
#        app.group.create(Group(header="Some header"))
#    old_groups = app.group.get_group_list()
#    app.group.modify(Group(header="New edited header"))
#    new_groups = app.group.get_group_list()
#    assert len(old_groups) == len(new_groups)
def test_modify_group(app, db, check_ui):

    with allure.step('I check if exist any group in group list'):
        if len(db.get_group_list()) == 0:
            app.group.create(Group(name="test"))

    with allure.step('Given a group list from database'):
        old_groups = db.get_group_list()

    with allure.step('Random group selected from list'):
        random_group = random.choice(old_groups)
        index = old_groups.index(random_group)

    with allure.step('Given a new group data'):
        new_group_data = Group(name="New group")
        new_group_data.id = old_groups[index].id

    with allure.step('When I add new data to a group %s from the list' %
                     new_group_data.id):
        app.group.modify_group_by_id(random_group.id, new_group_data)

    with allure.step(
            'Then the new group list is equal to the old list with the added new data %s'
            % new_group_data):
        new_groups = db.get_group_list()
        old_groups[index] = new_group_data
        assert len(old_groups) == len(new_groups)
        assert old_groups == new_groups
        if check_ui:
            assert sorted(new_groups, key=Group.id_or_max) == sorted(
                app.group.get_group_list(), key=Group.id_or_max)
def test_update_group(app, db, check_ui):
    app.group.create_if_absent()
    # preparation
    new_group = Group(name='groupUpdated',
                      header='headerUpdated',
                      footer='footerUpdated')
    old_groups = db.get_group_list()
    random_group = random.choice(old_groups)
    new_group.id = random_group.id

    app.group.update_by_id(random_group.id, new_group)

    # checking
    new_groups = db.get_group_list()
    # replacing old contact which was updated
    for n in range(len(old_groups)):
        if old_groups[n].id == new_group.id:
            old_groups[n] = new_group
            break
    assert sorted(old_groups,
                  key=Group.id_or_max) == sorted(new_groups,
                                                 key=Group.id_or_max)
    if check_ui:
        assert sorted(new_groups, key=Group.id_or_max) == sorted(
            app.group.get_group_list(), key=Group.id_or_max)
def test_modify_some_group(app, db, check_ui):
    if len(db.get_group_list()) == 0:
        app.group.create(Group(name='test'))
    old_groups = db.get_group_list()
    random_group = random.choice(old_groups)
    group = Group(name="update")
    group.id = random_group.id
    app.group.modify_group_by_id(group)
    new_groups = db.get_group_list()
    assert len(old_groups) == len(new_groups)
    i = 0
    for x in old_groups:
        if x.id == random_group.id:
            old_groups[i] = group
        i += 1
    assert old_groups == new_groups
    if check_ui:
        assert sorted(new_groups, key=Group.id_or_max) == sorted(app.group.get_group_list(), key=Group.id_or_max)


#def test_modify_group_header(app):
#    old_groups = app.group.get_group_list()
#    app.group.modify_first_group(Group(header="update"))
#    new_groups = app.group.get_group_list()
#    assert len(old_groups) == len(new_groups)
Beispiel #33
0
def test_edit_group_name_by_index(app, db, check_ui):
    if len(db.get_group_list()) == 0:
        app.groups.create(Group(name="Test"))
    old_groups = db.get_group_list()
    group = random.choice(old_groups)
    newG = Group(name="New name")
    newG.id = group.id
    app.groups.edit_by_id(group.id, newG)
    new_groups = db.get_group_list()
    old_groups.remove(group)
    old_groups.append(newG)
    assert sorted(old_groups,
                  key=Group.id_or_max) == sorted(new_groups,
                                                 key=Group.id_or_max)

    def clean(group):
        group.name = re.sub(" +", " ", group.name)
        return Group(id=group.id, name=group.name.strip())

    if check_ui:
        ui_list = app.groups.get_groups_list()
        db_list = map(clean, new_groups)
        assert sorted(db_list,
                      key=Group.id_or_max) == sorted(ui_list,
                                                     key=Group.id_or_max)
def test_modify_gname(app):
	old_groups = app.group.get_group_list()
	group = Group(name= 'New Group')
	group.id = old_groups[0].id
	app.group.modify_first_group(group)
	new_groups = app.group.get_group_list()
	assert len(old_groups) == len(new_groups)
	old_groups[0]= group
	assert  sorted(old_groups,key=Group.id_or_max) == sorted(new_groups,key=Group.id_or_max)
Beispiel #35
0
def test_modify_group_name(app):
    old_groups = app.group.get_group_list()
    group = Group(name="New name")
    group.id = old_groups[0].id
    app.group.modify_first_group(group)
    new_groups = app.group.get_group_list()
    assert_that(len(old_groups) == len(new_groups)).is_true()
    old_groups[0] = group
    assert_that(old_groups == new_groups)
def test_modify_group_name(app, db, check_ui):
    if app.group.count() == 0:
        app.group.create(Group(name="TestGroupName"))
    old_groups = db.get_group_list()
    old_group = random.choice(old_groups)
    group = Group(name="ModifyGroup")
    group.id = old_group.id
    old_groups.remove(old_group)
    app.group.modify_group_by_id(group)
    app.group.check_add_or_modify_success(db, group, old_groups, check_ui)
Beispiel #37
0
def test_modify_group_name(app):
    if app.group.count() == 0:
        app.group.create(Group(name="test", header="test", footer="test"))
    old_groups = app.group.get_group_list()
    index = randrange(len(old_groups))
    group = Group(name="Change name")
    group.id = old_groups[index].id
    app.group.modify_group_by_index(index, group)
    new_groups = app.group.get_group_list()
    assert len(old_groups) == len(new_groups)
Beispiel #38
0
def test_modify_group_name(app, orm):
    check_for_group(app)
    old_groups = orm.get_group_list()
    group = random.choice(old_groups)
    gr_obj = Group(name="popopo")
    gr_obj.id = group.id
    old_groups.remove(group)
    old_groups.append(gr_obj)
    app.group.modify_by_id(gr_obj)
    new_groups = orm.get_group_list()
    assert sorted(old_groups, key=Group.id_or_max) == sorted(new_groups, key=Group.id_or_max)
def test_modify_group_name(app):
    if app.group.count() == 0:
        app.group.create(Group(name="testing"))
    old_groups = app.group.get_group_list()
    group = Group (name= "NewGroup")
    group.id = old_groups[0].id
    app.group.modify_first_group(group)
    new_groups = app.group.get_group_list()
    assert len(old_groups) == len (new_groups)
    old_groups[0]=group
    assert sorted(old_groups,key=Group.id_or_max) == sorted(new_groups,key=Group.id_or_max)
def test_modify_group_name(app):
   if app.group.count() == 0:
      app.group.create(Group(name="some name", header="some logo", footer="some footer"))
   old_groups = app.group.get_groups_list()
   index = randrange(len(old_groups))
   group = Group(name="new name")
   group.id = old_groups[index].id
   app.group.modify_group_by_index(index, group)
   new_groups = app.group.get_groups_list()
   assert len(old_groups) == len(new_groups)
   old_groups[index] = group
   assert sorted(old_groups, key=Group.id_or_max) == sorted(new_groups, key=Group.id_or_max)
def test_edit_some_group_name(app):
    if app.group.count() ==0:
        app.group.create(Group(gr_name="for edit group"))
    old_groups = app.group.get_group_list()
    index = randrange(len(old_groups))
    group = Group(gr_name="edit_test111111")
    group.id = old_groups[index].id
    app.group.edit_group_by_index(index, group)
    new_groups = app.group.get_group_list()
    assert len(old_groups) == len(new_groups)
    old_groups[index] = group
    assert sorted(old_groups, key=Group.id_or_max) == sorted(new_groups, key=Group.id_or_max)
Beispiel #42
0
def test_edit_group_name(gen):
    if gen.group.count() == 0:
        gen.group.create(Group(name="test"))
    old_groups = gen.group.get_group_list()
    index = randrange(len(old_groups))
    group = Group(name="New name")
    group.id = old_groups[index].id
    gen.group.edit_group_by_index(index, group)
    assert len(old_groups) == gen.group.count()
    new_groups = gen.group.get_group_list()
    old_groups[index] = group
    assert sorted(old_groups, key=Group.id_or_max) == sorted(new_groups, key=Group.id_or_max)
Beispiel #43
0
def test_modify_some_group(app):
    group = Group(name="New group")
    if app.group.count() == 0:
        app.group.create(group)
    old_groups = app.group.get_group_list()
    index = randrange(len(old_groups))
    group.id = old_groups[index].id
    app.group.modify_group_by_index(index, group)
    assert len(old_groups) == app.group.count()
    new_groups = app.group.get_group_list()
    old_groups[index] = group
    assert sorted(old_groups, key=Group.id_or_max) == sorted(new_groups, key=Group.id_or_max)
def test_modify_group_by_index(app):
    old_groups = app.group.get_group_list()
    index = randrange(len(old_groups))
    group = Group(name="test group")
    group.id = old_groups[index].id
    if app.group.count()== 0:
        app.group.create(Group(name="test group"))
    app.group.modify_group_by_index(index, group)
    new_groups = app.group.get_group_list()
    assert len(old_groups) == len(new_groups)
    old_groups[index] = group
    assert sorted(old_groups, key=Group.id_or_max)== sorted (new_groups, key=Group.id_or_max)
Beispiel #45
0
def test_edit_group(app, db, check_ui):
    if len(db.get_group_list()) == 0:
        app.group.create(Group(name="name_name", header="head_head"))
    old_groups = db.get_group_list()
    group = random.choice(old_groups)
    group_new = Group(name="new_name", header="new_header", footer="new_footer")
    group_new.id = group.id
    app.group.edit_group_by_id(group.id, group_new)
    new_groups = db.get_group_list()
    # assert sorted(old_groups, key=Group.id_or_max) == sorted(new_groups, key=Group.id_or_max)
    if check_ui:
        assert sorted(new_groups, key=Group.id_or_max) == sorted(app.group.get_group_list(), key=Group.id_or_max)
def test_mod_some_group_name(app):
    if app.group.count() == 0:
        app.group.create(Group(name="test"))
    old_groups = app.group.get_group_list()
    index = randrange(len(old_groups))
    group = Group(name="new group")
    group.id = old_groups[index].id
    app.group.modify_group_by(group,index)
    new_groups = app.group.get_group_list()
    assert len(old_groups) == app.group.count()
    old_groups[index] = group
    assert sorted(old_groups, key=Group.id_or_max) == sorted(new_groups, key=Group.id_or_max)
def test_edit_group(app):
    if app.group.count() == 0:
        app.group.create(Group(name="test"))
    old_groups = app.group.get_group_list()
    index = randrange(len(old_groups))
    group=Group(name="aaaaa", header="kkk", footer="ccc")
    group.id = old_groups[index].id
    app.group.edit_group_by_index(index, group)
    new_groups = app.group.get_group_list()
    assert len(old_groups) == len(new_groups)
    old_groups[index] =group
    assert sorted(old_groups, key=Group.id_or_max) == sorted(new_groups, key=Group.id_or_max)
def test_edit_first_group(app, db):
    if len(db.get_group_list()) == 0:
        app.group.create(Group(name="sdfsf"))
    old_groups = db.get_group_list()
    target_group = random.choice(old_groups)
    group = Group(name="test")
    group.id = target_group.id
    app.group.edit_by_id(target_group.id, group)
    assert len(old_groups) == app.group.count()
    new_groups = db.get_group_list()
    old_groups = [group if gr.id == group.id else gr for gr in old_groups]
    assert sorted(old_groups, key=Group.id_or_max) == sorted(new_groups, key=Group.id_or_max)
def test_edit_some_group(app, db, check_ui):
    if len(db.get_group_list()) == 0:
        app.group.create(Group(name="not enough groups"))
    old_groups = db.get_group_list()
    group = random.choice(old_groups)
    edited_group = Group(name="edited_name", header="edited_header", footer="edited_footer")
    edited_group.id = group.id
    app.group.edit_group_by_id(edited_group, group.id)
    new_groups = db.get_group_list()
    old_groups.remove(group)
    old_groups.append(edited_group)
    assert sorted(old_groups, key=Group.id_or_max) == sorted(new_groups, key=Group.id_or_max)
    if check_ui:
        assert sorted(new_groups, key=Group.id_or_max) == sorted(app.group.get_groups_list(), key=Group.id_or_max)
Beispiel #50
0
def test_edit_some_group_name(app, db, check_ui):
    if len(db.get_group_list())==0:
        app.group.create(Group(name="test"))
    old_groups = db.get_group_list()
    group = random.choice(old_groups)
    group_new = Group(name="new name")
    app.group.edit_group_by_id(group.id, group_new)
    group_new.id=group.id
    new_groups = db.get_group_list()
    old_groups.remove(group)
    old_groups.append(group_new)
    assert sorted(old_groups, key = Group.id_gr_max) == sorted(new_groups, key = Group.id_gr_max)
    if check_ui:
        assert sorted(new_groups, key=Group.id_gr_max) == sorted(app.group.get_group_list(), key=Group.id_gr_max)
def test_modify_group_fields(app):
    app.session.login(username="******", password="******")
    if app.group.count() == 0:
        app.group.create(Group(name="test", header="test", footer="test"))

    old_groups = app.group.get_group_list()
    group = Group(name="updated", header="updated", footer="updated")
    group.id = old_groups[0].id
    app.group.modify_first_group(group)
    assert len(old_groups) == app.group.count()
    new_groups = app.group.get_group_list()
    old_groups[0] = group
    assert sorted(old_groups, key=Group.id_or_max) == sorted(new_groups, key=Group.id_or_max)
    app.session.logout()
def test_modify_group_name(app, db, check_ui):
    if len(db.get_group_list()) == 0:
        app.group.create(Group(name="test"))
    old_groups = db.get_group_list()
    group = random.choice(old_groups)
    modified_group = Group(name="New group")
    modified_group.id = group.id
    app.group.modify_group_by_id(modified_group.id, modified_group)
    new_groups = db.get_group_list()
    old_groups.remove(group)
    old_groups.append(modified_group)
    assert sorted(old_groups, key=Group.id_or_max) == sorted(new_groups, key=Group.id_or_max)
    if check_ui:
        assert sorted(new_groups, key=Group.id_or_max) == sorted(app.group.get_group_list(), key=Group.id_or_max)
def test_modify_group_name(app, db, check_ui):
    if len(db.get_group_list()) == 0:
        app.group.create(Group(name="new", header="header", footer="footer"))
    old_groups = db.get_group_list()
    random_group = random.choice(old_groups)
    group_index = old_groups.index(random_group)
    group = Group(name="updated group", header="updated header", footer="updated footer")
    group.id = random_group.id
    app.group.modify_group_by_id(group, random_group.id)
    new_groups = db.get_group_list()
    old_groups[group_index] = group
    assert sorted(old_groups, key = Group.id_or_max) == sorted(new_groups, key = Group.id_or_max)
    if check_ui:
        assert sorted(new_groups, key=Group.id_or_max) == sorted(app.group.get_group_list(), key=Group.id_or_max)
Beispiel #54
0
def create_user_groups():

    user = validate_cookie(request)
    print user.__str__()
    responseWrapper = ResponseWrapper()

    print "hello new group"
    response = any_response(request)

    if user != None:

        group = Group()
        try:
            # form_data = request.form['data']
            print request.form
            form_data = request.form['data']
            json_data = json.loads(form_data)
            group.name = json_data['group_name']
            print "appending to group user ", user.id
            group.users.append(user.id)

        except Exception as inst:
            print inst
            print "Error reading form data"
            responseWrapper.set_error(True)
            responseWrapper.set_data([inst])
            response.data = json.dumps(responseWrapper, default=ResponseWrapper.__str__)
            response.mimetype = "application/json"
            return response

        new_group_id = groupDAO.insert_group(group)
        group.id = new_group_id
        result = userDAO.append_group(user.id,group)

        if result != None:
            responseWrapper.set_error(False)
            new_group_id = str(new_group_id)
            responseWrapper.set_data([{"group_id":new_group_id}])
        else:
            responseWrapper.set_error(True)
            responseWrapper.set_data(["error writing group"])

    else:
        responseWrapper.set_error(True)
        responseWrapper.set_data(["User not found. Please login again"])
        response.status_code = 302

    response.data = json.dumps(responseWrapper, default=ResponseWrapper.__str__)
    response.mimetype = "application/json"
    return response
Beispiel #55
0
def test_change_some_group_name(app, db, check_ui):
    if len(db.get_group_list()) == 0:
        app.group.create(Group(name="group", header="new", footer="new_1"))
    old_groups = db.get_group_list()
    old_group = random.choice(old_groups)
    id = old_group.id
    group = Group(name="change_group")
    app.group.change_by_id(id, group)
    new_groups = db.get_group_list()
    group.id = id
    old_groups.insert(old_groups.index(old_group), group)
    old_groups.remove(old_group)
    assert sorted(old_groups, key=Group.id_or_max) == sorted(new_groups, key=Group.id_or_max)
    if check_ui:
        assert sorted(new_groups, key=Group.id_or_max) == sorted(app.group.get_group_list(), key=Group.id_or_max)
Beispiel #56
0
def test_edit_first_group(app, db, check_ui, data_groups):
    with pytest.allure.step('Given a non-empty group list'):
        if len(db.get_list_groups()) == 0:
            app.group.create(data_groups)
        old_list_groups = db.get_list_groups()
    edit_group = Group(name="Name_of_group_new", header="Header_of_group_new", footer="Footer_of_group_new")
    with pytest.allure.step('When I edit a first group from the list to edit group %s' % edit_group):
        edit_group.id = old_list_groups[0].id
        app.group.edit_group_by_id(edit_group)
    with pytest.allure.step('Then the new group list is equal to the old group list with edited group'):
        new_list_groups = db.get_list_groups()
        old_list_groups[0] = edit_group
        assert sorted(new_list_groups, key=Group.id_or_max) == sorted(old_list_groups, key=Group.id_or_max)
        if check_ui:
            assert sorted(new_list_groups, key=Group.id_or_max) == sorted(app.group.get_list_groups(), key=Group.id_or_max)
def test_modify_group_name(app, db, check_ui):
    odl_groups = db.get_group_list()
    if len(db.get_group_list()) == 0:
        app.group.create(Group(name="test"))
    new_data= Group(name="New Name of Group")
    index = randrange(len(odl_groups))
    new_data.id = odl_groups[index].id
    app.group.modify_group_by_id(new_data.id, new_data)
    new_groups = db.get_group_list()
    assert len(odl_groups) == len(new_groups)
    odl_groups[index] = new_data
    assert sorted(odl_groups, key=Group.id_or_max) == sorted(new_groups, key=Group.id_or_max)
    if check_ui:
        list_group_after_mod = app.group.get_group_list()
        assert sorted(list_group_after_mod, key=Group.id_or_max) == sorted(new_groups, key=Group.id_or_max)
def test_modify_group_name_to(app, db, check_ui):
    if len(db.get_groups_list()) == 0:
        app.group.create(Group(name="TestName"))
    old_groups = db.get_groups_list()
    group = random.choice(old_groups)
    new_group = Group(name="NewName")
    new_group.id = group.id
    app.group.modify_group_by_id(new_group.id, new_group)
    assert len(old_groups) == app.group.count()
    new_groups = db.get_groups_list()
    index = old_groups.index(group)
    old_groups[index] = new_group
    assert old_groups == new_groups
    if check_ui:
        assert sorted(new_groups, key=Group.id_or_max) == sorted(app.group.get_groups_list(), key=Group.id_or_max)
def test_rename_first_group(app,db,check_ui):
    if app.group.count() == 0:
        app.group.create(Group(name="test"))
    old_groups = db.get_group_list()
    chosen_group = random.choice(old_groups)
    index = old_groups.index(chosen_group)
    group = Group(name="edited1", header="edited", footer="edited")
    group.id=chosen_group.id
    app.group.edit_group_by_id(group.id, group)
    new_groups = db.get_group_list()
    assert len(old_groups) == len(new_groups)
    old_groups[index]=group
    assert sorted(old_groups, key = Group.id_or_max) == sorted(new_groups,key = Group.id_or_max)
    if check_ui:
        assert sorted(new_groups, key = Group.id_or_max) == sorted(app.group.get_group_list(), key = Group.id_or_max)
Beispiel #60
0
def test_update_group_name(app, orm, check_ui):
    if len(orm.get_groups()) == 0:
        app.group.add(Group(name='first group'))
    old_groups = orm.get_groups()
    group = random.choice(old_groups)
    index = old_groups.index(group)
    new_data = Group(name='new name')
    new_data.id = group.id
    app.group.update_by_id(group.id, new_data)
    new_groups = orm.get_groups()
    assert len(old_groups) == len(new_groups)
    old_groups[index] = new_data
    assert sorted(old_groups, key=Group.id_or_max) == sorted(new_groups, key=Group.id_or_max)
    if check_ui:
        assert sorted(new_groups, key=Group.id_or_max) == sorted(app.group.get_groups(), key=Group.id_or_max)