예제 #1
0
def test_edit_group(app, db, check_ui):
    if app.group.count() == 0:
        app.group.create_group(
            Group(name="username", header="testheader", footer="testfooter"))
    old_group = db.get_group_list()
    group = Group(name="_test_to_check_edit222",
                  header="_test_to_check_edit222",
                  footer="_test_to_check_edit222")
    group_random = random.choice(old_group)
    app.group.edit_group_by_id(group, group_random.id)
    assert len(old_group) == app.group.count()
    new_group = db.get_group_list()
    if (check_ui):
        assert sorted(new_group, key=Group.id_or_max) == sorted(
            app.group.get_group_list(), key=Group.id_or_max)
def loginRobot():

    logger.info("Robot login")
    if not settings.IS_TEST_ENV:
        Slack.sendLoginNotice("Robot *{}* had login.".format(
            robotName, robotId))

    robot.releaseLoginRobot(robotId)
    robot.updateHeartBeat(robotId)

    try:
        _thread.start_new_thread(robot.online, (robotId, ))
    except:
        logger.error("Error: unable to start thread")
        sys.exit(0)

    group = Group(newInstance, robotId)

    try:
        _thread.start_new_thread(group.fetechAndAddGroupRepeat, ())
    except:
        logger.error("Error: unable to start thread")
        sys.exit(0)

    try:
        _thread.start_new_thread(group.fetechAndInvitRequestRepeat, ())
    except:
        logger.error("Error: unable to start thread")
        sys.exit(0)
예제 #3
0
 def get_not_related_group_contact(self):
     for y in self.get_all_group_id():
         l = self.get_contacts_not_in_group(Group(id=y))
         if len(l) > 0:
             return l[0].id, y
         else:
             return False
예제 #4
0
 def get_related_group_contact(self):
     for yx in self.get_all_group_id():
         li = self.get_contacts_in_group(Group(id=yx))
         if len(li) > 0:
             return li[0].id, yx
         else:
             return False
예제 #5
0
def get_output_data(unc_gr):
    output_list = []
    for group in unc_gr:
        try:
            group = Group(group)
            output_list.append(group.get_group_data())
        except Exception as e:
            pass
    return output_list
예제 #6
0
 def get_group_list(self):
     if self.cache_group is None:
         wd = self.app.wd
         self.open_groups_page()
         self.cache_group = []
         for element in wd.find_elements_by_xpath("//body//span"):
             text = element.text
             id = element.find_element_by_name("selected[]").get_attribute("value")
             self.cache_group.append(Group(name = text, id = id))
     return list(self.cache_group)
def test_add_contact_to_group(app):
    if (len(db.get_contact_list()) == 0):
        app.contact.new_contact_creation(
            Contact(firstname="Test_Firstname", middlename="Test_Middlename", lastname="Test_lastname",
                    nickname="Test_Nickname", title="Test_title", company="Company", address="Test_adress", home="Home",
                    mobile="mobile",
                    work="Test_work", fax="Test_fax", email="Test_email", email1="Test_email1", email2="Test_email2",
                    email3="Test_email3", address2="Test_adress2", homepage="Test_homepage", bday="5", bmounth="July",
                    byear="1982", aday="2", amonth="July", ayear="2003", phone2="Test_phone2", notes="Test_notes"))
    if app.group.count() == 0:
        app.group.create_group(Group(name="username", header="testheader", footer="testfooter"))

    if db.get_related_group_contact() == False:
        free_contact, free_group = db.get_not_related_group_contact()
        app.contact.add_contact_to_group(free_contact, str(free_group))

    related_contact, related_group = db.get_related_group_contact()
    app.contact.delete_contact_from_group(related_contact, str(related_group))
    assert str(related_contact) not in db.get_list_id_contact_in_group(Group(id=related_group))
 def __get_group(self, group_type_desc, group_label: Optional[str],
                 part_of_label) -> Optional[Group]:
     if not group_label:
         return None
     group_type_label = group_label
     group_type = _group_types[group_type_desc]
     part_of_group = (self.__get_group(part_of_label, (),
                                       ()) if part_of_label else None)
     group = Group(self._graph, group_label, group_type)
     if part_of_group:
         group.add_relationship(Nampi_type.Core.is_part_of, part_of_group)
     return group
예제 #9
0
def createGroupAuth():
	email = session['email']
	groupName = request.form['GroupName']
	if not Group.checkIfGroupExists(groupName, conn):
		Group.insertGroupDetails(email, groupName, conn)
		newGroup = Group(groupName, User.fetchUsername(session['email'], conn))
		activeGroups.append(newGroup)
		session['group'] = newGroup.name
		newGroup.startDJRotateThread()
		return redirect('/group')
	else:
		error = 'A group with this name already exists! Please try again.'
		return render_template('createGroup.html', error=error)
예제 #10
0
def test_delete_some_group(app, db, check_ui):
    if len(db.get_group_list()) == 0:
        app.group.create_group(
            Group(name="username", header="testheader", footer="testfooter"))
    old_group = db.get_group_list()
    group = random.choice(old_group)
    app.group.delete_group_by_id(group.id)
    new_group = db.get_group_list()
    old_group.remove(group)
    assert old_group == new_group
    if (check_ui):
        assert sorted(new_group, key=Group.id_or_max) == sorted(
            app.group.get_group_list(), key=Group.id_or_max)
예제 #11
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), name=name, header=header, footer=footer))
     finally:
         cursor.close()
     return list
예제 #12
0
 def __get_group(self, group_label: Optional[str]) -> Optional[Group]:
     if not group_label:
         return None
     group_type_label = self.__sheet.get_from_table(Table.GROUPS,
                                                    Column.name,
                                                    group_label,
                                                    Column.type)
     part_of_label = self.__sheet.get_from_table(Table.GROUPS, Column.name,
                                                 group_label,
                                                 Column.part_of)
     group_type = (_group_types[group_type_label]
                   if group_type_label else Nampi_type.Core.group)
     part_of_group = self.__get_group(
         part_of_label) if part_of_label else None
     group = Group(self._graph, group_label, group_type)
     if part_of_group:
         group.add_relationship(Nampi_type.Core.is_part_of, part_of_group)
     return group
예제 #13
0
from modules.group import Group
import random
import string

testdata = [
    Group(name="testname1569",
          header="testheader15478",
          footer="testfooter101478")
]
'''
def random_string(prefix, maxlen):
    symbols = string.ascii_letters + string.digits + string.punctuation + " "*10
    return prefix + '_'.join([random.choice(symbols) for i in range(random.randrange(maxlen))])

test_data = [Group(name="testname", header="testheader", footer="testfooter")] + [
             Group(name = random_string("name", 10), header= random_string("header", 20), footer = random_string("footer", 15)) for i in range(2)]

'''
예제 #14
0
if not os.path.exists(LOG_PATH):
    os.makedirs(LOG_PATH)

logging.basicConfig(format=u'%(levelname)-8s [%(asctime)s] %(message)s',
                    level=logging.INFO,
                    filename=u'{}{}.log'.format(LOG_PATH, LOG_NAME))
logging.info('\n')  # Отделять логи пустой строкой

REMOTE_FTP_SERVER_HOSTNAME = CONFIG['ftp_server']
REMOTE_FTP_SERVER_USERNAME = CONFIG['ftp_username']
REMOTE_FTP_SERVER_PASSWORD = CONFIG['ftp_password']

SWDB = DB()
ZABBIX_HOST = Host()
ZABBIX_GROUP = Group()
ZABBIX_HOSTINTERFACE = Hostinterface()

ABK_PROXY_ID = CONFIG['abk_proxyid']
BRK_PROXY_ID = CONFIG['brk_proxyid']
# irk_proxyid = config['irk_proxyid']
KNS_PROXY_ID = CONFIG['kns_proxyid']
KRK_PROXY_ID = CONFIG['krk_proxyid']


def download_file():
    # Загрузка файла выгрузки СВДБ с удаленного фтп сервера
    ssh = paramiko.SSHClient()
    ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    try:
        ssh.connect(REMOTE_FTP_SERVER_HOSTNAME,
예제 #15
0
 def convert(group):
     return Group(id=str(group.id),
                  name=group.name,
                  header=group.header,
                  footer=group.footer)
예제 #16
0
 def clean(group):
     return Group(id=group.id, name=group.name.strip())