Beispiel #1
0
    def get_group_list(self):
        if self.group_cache is None:

            wd = self.app.wd
            self.open_groups_page()
            self.group_chache = []
            for element in wd.find_elements_by_css_selector("span.group"):
                text = element.text
                id = element.find_element_by_name("selected[]").get_attribute("value")
                self.group_chache.append(Group(name=text, id=id))

        return list(self.group_chache)
Beispiel #2
0
def test_modify_group_name(app, db, json_groups):
    if app.group.count() == 0:
        app.group.create(Group(name="test"))
    old_groups = db.get_group_list()
    group = json_groups
    old_group = random.choice(old_groups)
    group.id = old_group.id
    app.group.modify_group_by_id(old_group.id, group)
    new_groups = db.get_group_list()
    assert sorted(old_groups,
                  key=Group.id_or_max) == sorted(new_groups,
                                                 key=Group.id_or_max)
Beispiel #3
0
 def get_group_list(self):
     list = []
     cursor = self.connection.cursor()
     try:
         cursor.execute(
             "select group_id, group_name, group_header, group_footer from group_list"
         )
         for row in cursor:
             (id, name, header, footer) = row
             list.append(
                 Group(id=str(id), header=header, name=name, footer=footer))
     finally:
         cursor.close()
     return list
Beispiel #4
0
def test_add_contact_to_group(app):
    if len(db.get_group_list()) == 0:
        app.group.create(Group(name="test"))
    contact_list = db.get_contact_list()
    contact = random.choice(contact_list)
    old_groups = db.get_group_list()
    group = random.choice(old_groups)
    contacts_in_groups = db.get_contacts_in_group(group)
    if contact in contacts_in_groups:
        contact is None
        group is None
        contact = random.choice(contact_list)
        old_groups = db.get_group_list()
        group = random.choice(old_groups)

    old_contacts = db.get_contacts_in_group(group)
    app.contact.add_contact_to_group_by_id(contact.id, group)
    new_contacts = db.get_contacts_in_group(group)
    old_contacts.append(contact)
    assert sorted(old_contacts,
                  key=Contact.id_or_max) == sorted(new_contacts,
                                                   key=Contact.id_or_max)
Beispiel #5
0
def test_delete_random_contact(app):

    if len(db.get_group_list()) == 0:
        app.group.create(Group(name="test"))
    old_groups = db.get_group_list()
    group = random.choice(old_groups)
    if len(db.get_contacts_in_group(group)) == 0:
        app.contact.add_contact_to_group(
            Contact(firstname="tester", lastname="tester"), group)
    old_contacts = db.get_contacts_in_group(group)
    removed_contacts = db.get_contacts_not_in_group(group)

    def rem_con(old_contacts):
        if old_contacts in removed_contacts:
            return True
        else:
            return False

    filter(rem_con, old_contacts)
    contact = random.choice(old_contacts)
    app.contact.delete_contact_by_id(contact.id)
    new_contacts = old_contacts.remove(contact)
    assert old_contacts == new_contacts
Beispiel #6
0
except getopt.GetoptError as err:
    getopt.usage()
    sys.exit(2)

n = 5
f = "data/groups.json"

for o, a in opts:
    if o == "-n":
        n = int(a)
    elif o == "-f":
        f = a


def random_string(prefix, maxlen):
    symbols = string.ascii_letters + string.digits + " " * 10
    return prefix + "".join(
        [random.choice(symbols) for i in range(random.randrange(maxlen))])


testdata = [Group(name="", header="", footer="")] + [
    Group(name=random_string("name", 10),
          header=random_string("header", 20),
          footer=random_string("footer", 20)) for i in range(n)
]

file = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", f)

with open(file, "w") as out:
    jsonpickle.set_encoder_options("json", indent=2)
    out.write(jsonpickle.encode(testdata))
Beispiel #7
0
def new_group(name, header, footer):
    return Group(name=name, header=header, footer=footer)
Beispiel #8
0
def non_empty_group_list(db, app):
    if len(db.get_group_list()) == 0:
        app.group.create(Group(name="some name"))
    return db.get_group_list()
Beispiel #9
0
 def clean(group):
     return Group(id=group.id, name=group.name.strip())
Beispiel #10
0
from model.formfiller import Group

testdata = [
    Group(name="name1", header="header1", footer="footer1"),
    Group(name="name2", header="header2", footer="footer2"),
]
Beispiel #11
0
 def convert(group):
     return Group(id=str(group.id), name=group.name, header=group.header, footer=group.footer)
from fixture.orm import ORMfixture
from model.formfiller import Group

db = ORMfixture(host="127.0.0.1", name="addressbook", user="******", password="")

try:
    l = db.get_contacts_in_group(Group(id="12"))
    for item in l:
        print(item)
    print(len(l))
finally:
    pass  #db.destroy()
Beispiel #13
0
 def new_group(self, name, header, footer):
     return (Group(name=name, header=header, footer=footer))