def test_add_client_in_group(app, db):
    with pytest.allure.step('Given a group list and a client list'):
        clients=db.get_client_list()
        groups=db.get_group_list()
    with pytest.allure.step('Choice a group from list'):
        group = random.choice(groups)
    with pytest.allure.step('If do not find group,add him'):
        if len(db.get_group_list())==0:
            app.group.create(Group(name="test"))
    with pytest.allure.step('If do not find client,add him'):
        if len(db.get_client_list())==0:
            app.client.create(Client(name="test"))
    with pytest.allure.step('If do not find client not in group,add him'):
        if len(orm.get_clients_not_in_group(group)) == 0:
            app.client.create(Client(name="test"))

    with pytest.allure.step('Add client to group'):
        while True:
            client_index=randrange(len(clients))
            group_index=randrange(len(groups))
            client_id=clients[client_index].id
            group_id=groups[group_index].id
            if clients[client_index] not in orm.get_clients_in_group(groups[group_index]):
                break
        app.client.add_client_to_group(client_id, group_id)

        assert clients[client_index] in orm.get_clients_in_group(groups[group_index])
 def registration_client(name, surname, patronymic, passport_id,
                         passport_seria, date_of_birth, login, password):
     dateall = date_of_birth.split('-')
     day = int(dateall[2])
     month = int(dateall[1])
     year = int(dateall[0])
     if ((passport_id > 1970) & (passport_id < 2030) &
         (passport_seria > 100000) & (passport_seria < 999999)):
         Client.create(name=name,
                       surname=surname,
                       patronymic=patronymic,
                       passport_id=passport_id,
                       passport_seria=passport_seria,
                       date_of_birth=date(year, month, day),
                       login=login,
                       password=password)
         sumR = random.randint(500, 5000)
         Account.create(
             sum=sumR,
             ID_offer=Offer.get(Offer.ID_offer == 1),
             ID_client=Client.get((Client.passport_seria == passport_seria)
                                  & (Client.passport_id == passport_id)),
             date_open=date.today())
         s = 1
         return s
     else:
         s = 2
         return s
Beispiel #3
0
 def testClient(self):
     '''
     Method to test the getter and the setter of the Client class
     '''
     client = Client(1960715060015, "Rusu Cosmin-Ionut")
     assert client.getCnp() == 1960715060015
     assert client.getName() == "Rusu Cosmin-Ionut"
     client.setCnp(2960715060015)
     assert client.getCnp() == 2960715060015
     client.setName("Rusu Cosmin")
     assert client.getName() == "Rusu Cosmin"
Beispiel #4
0
 def __init__(self):
     # 本地客户
     self.client = Client()
     # 接受信息线程
     self.receive = Receive(self.client)
     # qt应用
     self.app = QApplication(sys.argv)
     # 登陆界面
     self.login = Login()
     # 聊天界面
     self.weiliao = WeiLiao()
     # 登陆微聊
     self.login_weiliao()
Beispiel #5
0
    def all_client(self):
        sql = 'SELECT * FROM client'
        cursor = connection.cursor()
        cursor.execute(sql)
        records = cursor.fetchall()

        client_list = []
        for record in records:
            client = Client(record[0], record[1], record[2], record[3],
                            record[4], record[5])

            client_list.append(client.json())
        return client_list
Beispiel #6
0
 def testClient(self):
     '''
     Method to test the getter and the setter of the Client class
     '''
     client = Client(1960715060015, "Rusu Cosmin-Ionut")
     assert client.getCnp() == 1960715060015
     assert client.getName() == "Rusu Cosmin-Ionut"
     client.setCnp(2960715060015)
     assert client.getCnp() == 2960715060015
     client.setName("Rusu Cosmin")
     assert client.getName() == "Rusu Cosmin"
    def setUp(self):

        self.__id = 3
        self.__name = "Corina"
        self.__client = Client(self.__id, self.__name)

        self.__meanid = -5
        self.__meanname = ""
        self.__meanclient = Client(self.__meanid, self.__meanname)

        self.__validator = ClientValidator()

        self.__repo = ClientRepository()
        self.__newname = "Korina"
        self.__updateclient = Client(self.__id, self.__newname)
Beispiel #8
0
    def update_a_client(self, old_name, new_name, new_email, new_address,
                        new_phone, new_rfc):
        idx = self.search_client(old_name)
        if idx > -1:
            if self.clients[idx].name.lower() != new_name.lower():
                if new_name == '':
                    new_name = self.clients[idx].name
                if new_email == '':
                    new_email = self.clients[idx].email
                if new_address == '':
                    new_address = self.clients[idx].address
                if new_phone == '':
                    new_phone = self.clientss[idx].phone
                if new_rfc == '':
                    new_rfc = self.clients[idx].rfc
                new_client = Client(self.clients[idx].id_client, new_name,
                                    new_email, new_address, new_phone, new_rfc)
                old_client = self.clients[idx]
                self.clients[idx] = new_client

            else:
                raise m_e.item_already_stored(
                    'Can\'t update "{}" because it\'s already stored'.format(
                        new_name.upper()))
        else:
            raise m_e.item_not_stored(
                'Cant\'t update "{}" because it\'s not stored'.format(
                    old_name.upper()))
        return old_client, new_client
class ClientTests(unittest.TestCase):
    def setUp(self):
        self.test_client = Client(1, "Ivo", 200000.00,
                                  "Bitcoin mining makes me rich")

    def test_client_id(self):
        self.assertEqual(self.test_client.get_id(), 1)

    def test_client_name(self):
        self.assertEqual(self.test_client.get_username(), "Ivo")

    def test_client_balance(self):
        self.assertEqual(self.test_client.get_balance(), 200000.00)

    def test_client_message(self):
        self.assertEqual(self.test_client.get_message(),
                         "Bitcoin mining makes me rich")
Beispiel #10
0
def test_create_new_client(app):
    app.session.login(username="******", password="******")
    app.create_new_client(
        Client("'English'", "name_field", "Legal_name_field",
               "primary_email_field", "Secondary_email_field",
               "Primary_phone_field", "secondary_phone_field", "fax_field",
               "78748", "country_field", "TX", "city_field"))
    app.session.logout()
Beispiel #11
0
    def update_client(self, change):
        sql = 'UPDATE client SET first_name=%s WHERE id = %s RETURNING *'
        cursor = connection.cursor()
        cursor.execute(sql, (change.client_first_name, change.client_id))

        record = cursor.fetchone()
        new_client = Client(record[0], record[1], record[2], record[3],
                            record[4], record[5]).json()
        return new_client
Beispiel #12
0
async def update_client(client_id: ObjectId, client: Client):
    try:
        c = await database.engine.find_one(Client, Client.id == client_id)
        logger.info(client.dict(exclude={"id"}))
        c.update_fields(client)
        await database.engine.save(c)
    except Exception as e:
        logger.exception(e)
    return c
Beispiel #13
0
 def login(self, user_name, password):
     try:
         self.user = Client.show_info(user_name, password)
         print("You logged in successfully!")
         self.user.set_id(password)
         return True
     except MissingUserError:
         print("Invalid password or username, please try again!")
         return False
Beispiel #14
0
 def get_client_from_view_page(self, index):
     wd = self.app.wd
     self.open_client_to_view(index)
     text = wd.find_element_by_id("content").text
     homephone = re.search("H: (.*)", text).group(1)
     workphone = re.search("W: (.*)", text).group(1)
     mobilephone = re.search("M: (.*)", text).group(1)
     phone2 = re.search("P: (.*)", text).group(1)
     return Client(home=homephone, work=workphone,  mobile=mobilephone, phone2=phone2)
 def Get_client(id_client):
     result = []
     client = Client.get(Client.ID_client == id_client)
     result.append(client.surname)
     result.append(client.name)
     result.append(client.patronymic)
     result.append(client.passport_id)
     result.append(client.passport_seria)
     result.append(client.date_of_birth)
     return result
Beispiel #16
0
 def put_client(client_id):
     try:
         client = Client.json_parse_client(request.json)
         client.client_id = int(client_id)
         client = ClientService.update_client(client)
         return jsonify(client), 200
     except ValueError as e:
         return 'Not a valid ID', 400
     except ResourceNotFound as r:
         return r.message, 404
Beispiel #17
0
def _synchronize():
    """
        Reading file csv, for synchronizer emails
    """
    sender = Sender(config)

    name_file_data_email = config.name_file_data_email

    with open("../data/input/{}".format(name_file_data_email)) as csv_file:
        csv_reader = csv.reader(csv_file, delimiter=';')

        line_count = 0

        name_file_working = _create_name_file_working(name_file_data_email)

        regularExpressionHelper = RegularExpressionHelper()

        with open('../data/input/{}'.format(name_file_working),
                  mode='w',
                  newline='') as csv_file_writer:
            writer = csv.DictWriter(
                csv_file_writer,
                fieldnames=Client.columns_name_synchronizer(),
                delimiter=";")

            writer.writeheader()
            client_dict = {}
            numRows = _get_lines_csv_reader(name_file_data_email)
            for row in csv_reader:
                if line_count > 0:
                    client = _get_client(row)

                    state = ''
                    if (regularExpressionHelper.match('email', client.email)):
                        if (sender.verify_email(client.email)):
                            state = StateClient.ACTIVE.value
                        else:
                            state = StateClient.WRONG.value
                    else:
                        state = StateClient.CORRUPT.value

                    client_dict = client.to_dict()
                    client_dict['state'] = state
                    writer.writerow(client_dict)

                    p.calculateAndUpdate(line_count, numRows)
                line_count += 1

            logger.info(f'Processed {line_count - 1} mails.')

    shutil.move(
        '../data/input/{}'.format(name_file_data_email),
        '../data/input/{}'.format(name_file_working).replace(".tmp", ".bck"))
    shutil.move('../data/input/{}'.format(name_file_working),
                "../data/input/{}".format(name_file_data_email))
 def Log_in(login, password):
     try:
         my_client = Client.select().where(
             (Client.login == login) & (Client.password == password)).get()
         return [1, my_client.ID_client]
     except:
         my_operator = Operator.select().where((Operator.login == login) & (
             Operator.password == password)).get()
         return [2, my_operator.ID_operator]
     else:
         return [0, 0]
def test_edit_client(app, db, check_ui):
    client = Client(firstname="Ekaterina",
                    lastname="Bocharova",
                    address="Shumakova, 23a",
                    home="123456",
                    mobile="987654321",
                    work="456123",
                    email="*****@*****.**",
                    email2="*****@*****.**")
    if app.client.count() == 0:
        app.client.add_client(client)
    old_clients = db.get_client_list()
    client_random = random.choice(old_clients)
    app.client.edit_client_by_id(client_random.id, Client(firstname="Irina"))
    assert len(old_clients) == app.client.count()
    new_clients = db.get_client_list()
    #assert old_clients==new_clients
    if check_ui:
        assert sorted(new_clients, key=Client.id_or_max) == sorted(
            app.client.get_client_list(), key=Client.id_or_max)
Beispiel #20
0
    def __to_object(self, data, role):
        name = data[0]
        email = data[1]
        login = data[2]
        pwd = data[3]

        if role == 'Manager':
            return Manager(name=name, email=email, login=login, password=pwd)
        if role == 'Client':
            return Client(name=name, email=email, login=login, password=pwd)
        raise Exception('Invalid person role "{0}".'.format(role))
Beispiel #21
0
 def get_client_list(self):
     list2=[]
     cursor=self.connection.cursor()
     try:
         cursor.execute("select id, firstname, lastname, home, mobile, work, email, email2, email3, phone2 from addressbook where deprecated='0000-00-00 00:00:00'")
         for row in cursor:
             (id, firstname,lastname, home, mobile, work, email, email2, email3, phone2) = row
             list2.append(Client(id=str(id), name=firstname, lastname=lastname, home=home, mobile=mobile, work=work, email=email, email2=email2, email3=email3, phone2=phone2))
     finally:
         cursor.close()
     return list2
Beispiel #22
0
    def get_client(self, client_id):
        sql = 'SELECT * FROM client WHERE id = %s'
        cursor = connection.cursor()
        cursor.execute(sql, [client_id])

        record = cursor.fetchone()

        if record:
            return Client(record[0], record[1], record[2], record[3],
                          record[4], record[5]).json()
        else:
            raise ResourceNotFound(f'Client with id: {client_id} - Not Found')
Beispiel #23
0
    def post(self):
        user = users.get_current_user()

        if not user:
            self.redirect("/")
            return

        key_text = self.request.get("lookFor", None)
        dni_text = self.request.get("lookForDni", None)

        if not key_text and not dni_text:
            self.redirect("/main")
            return

        if dni_text:
            dni_text = dni_text.strip()
            try:
                dni = int(dni_text)
            except:
                dni = 0

            key_text = dni_text
            self.result_set = Client.query(Client.dni == dni).order(
                Client.surname)
        else:
            self.key_text = key_text.strip().lower()
            self.result_set = []
            Client.query().order(Client.surname).map(self.key_text)

        template_values = {
            "info": AppInfo,
            "user_name": user.nickname(),
            "access_link": users.create_logout_url("/"),
            "clients": self.result_set,
            "key_text": key_text
        }

        jinja = jinja2.get_jinja2(app=self.app)
        self.response.write(
            jinja.render_template("found.html", **template_values))
Beispiel #24
0
    def create_client(self, client):
        sql = 'INSERT INTO client VALUES (DEFAULT, %s, %s, %s, %s, %s) RETURNING *'
        cursor = connection.cursor()
        cursor.execute(
            sql,
            (client.client_first_name, client.client_last_name,
             client.client_email, client.client_mobile, client.client_ssn))

        connection.commit()
        record = cursor.fetchone()
        new_client = Client(record[0], record[1], record[2], record[3],
                            record[4], record[5])
        return new_client
def test_edit_first_client(app, db, check_ui):
    with pytest.allure.step('Given a client list'):
        old_clients=db.get_client_list()
    with pytest.allure.step('Choice a client from list'):
        client2=random.choice(old_clients)
    with pytest.allure.step('Edit a client from list'):
        client = Client(name="Lerry")
        old_client=app.client.get_client_list()
        indexs=old_clients.index(client2)
        index=old_client.index(client2)
        client.id = old_clients[indexs].id
    with pytest.allure.step('If do not find client,add him'):
        if app.client.count() == 0:
            app.client.create_new_client(Client(name="Daria"))
        app.client.edit_client_by_index(index, client)
    with pytest.allure.step('Then the new group list is equal to the old list with the adden group'):
        new_clients=db.get_client_list()
        assert len(old_clients) == len(new_clients)
        old_clients[indexs]=client
        assert sorted(old_clients, key=Client.id_or_max) == sorted(new_clients, key=Client.id_or_max)
    #if check_ui:
    #    assert sorted(new_clients, key=Client.id_or_max) == sorted(app.client.get_client_list(), key=Client.id_or_max)
Beispiel #26
0
 def __can_rent(self, bid, cid):
     """
     Verifies if the book and the client exist so that the rent makes sense
     Input: bid  - positive integer
            cid - positive integer
     Output: True if the book which identifies with bid and the client which identifies with cid exist
             False otherwise
     """
     book = Book(bid, None, None, None)
     client = Client(cid, None)
     if self.__book_repo.exists_book(book) and self.__client_repo.exists_client(client):
         return True
     return False
    def update_client(self, cid, name):
        """
        Creates a client with the given attributes and updates the client, from the repository, with the given id 
        Input: cid - positive integer
               name - string
        """
        client = Client(cid, name)
        self.__client_valid.valid_client(client)
        c = self.__client_repo.update(client)

        redo = FunctionCall(self.update_client, cid, name)
        undo = FunctionCall(self.update_client, c.get_id(), c.get_name())
        oper = Operations(undo, redo)

        self.__undo_service.add(oper)
Beispiel #28
0
def _get_client(row):
    """ 
        Creating Client with the row of the file csv 
    """

    id = row[0]
    ruc = row[1]
    enterprise = row[2]
    contact = row[3]
    phone = row[4]
    email = row[5]
    state = row[6]

    client = Client(id, ruc, enterprise, contact, phone, email, state)
    return client
Beispiel #29
0
 def get_client_list(self):
     if self.client_cache is None:
         wd = self.app.wd
         self.app.open_home_page()
         self.client_cache = []
         for row in wd.find_elements_by_css_selector("tr[name=entry]"):
             cells = row.find_elements_by_css_selector("td")
             id = cells[0].find_element_by_tag_name("input").get_attribute("value")
             lastname = cells[1].text
             firtname = cells[2].text
             all_phones=cells[5].text
             all_emails=cells[4].text
             address=cells[3].text
             self.client_cache.append(Client(id=id, firstname=firtname, lastname=lastname, address=address, all_phones_from_home_page=all_phones, all_emails_from_home_page=all_emails))
         return list(self.client_cache)
Beispiel #30
0
 def register(self, user_name, password):
     try:
         self.user = Client.add_client(user_name, password)
         print("Successful registration.\
             Now you can login with your username and password")
         return True
     except LessThan8SymbolsError:
         print("Your password must be at least 8 letters!")
         return False
     except MissingCapitalLetterError:
         print("Missing capital letter, at least one is required!")
     except MissingSpecialSymbolError:
         print("Missing special symbol, at least one is required!")
     except MissingNumberError:
         print("Missing number, at least one is required!")
    def _loadFile(self):
        try:
            f = open(self._fileName, "r")
            s = f.readline()

            while len(s) > 1:
                tok = s.split(",")
                tok[1] = tok[1].split("\n")
                client = Client(int(tok[0]), tok[1][0])
                ClientRepository.add(self, client)
                s = f.readline()
        except Exception as e:
            raise RepoError("Error reading input file: " + str(e))
        finally:
            f.close()
 def ajouter_client_parking(self, nom, adresse, abonnement):
     cli = Client(nom, adresse)
     contrat = Contrat(cli)
     
     if abonnement == "Abonne" : 
         cli.est_abonne = True
         self.abonner_un_client(cli, abonnement, contrat)
         
     if abonnement == "Super abonne" : 
         cli.est_super_abonne = True
         self.abonner_un_client(cli, abonnement, contrat)
     else : self.abonner_un_client(cli, abonnement, contrat)
     
     hauteur  = randint(MIN_HAUTEUR, MAX_HAUTEUR)
     longueur = randint(MIN_LONGUEUR, MAX_LONGUEUR)
     largeur  = randint(MIN_LARGEUR, MAX_LARGEUR)
     cli.nouvelle_voiture("", hauteur, longueur, largeur)
     return cli.entrer_parking(self.parking.mes_acces[0])
Beispiel #33
0
import sys, os

sys.path.append(os.path.abspath("../"))


from model.parking import Parking
from model.acces import Acces
from model.client import Client

nb_niveau = 4
nb_places_par_niveau = 10
prix = 10
parking = Parking(nb_niveau, nb_places_par_niveau, prix)
acces1 = Acces(parking)
acces2 = Acces(parking)
parking.addAcces(acces1)
parking.addAcces(acces2)
parking.init_places()


cli = Client("nom", "adresse", True, False, 0)
cli.nouvelle_voiture("1234567", 244, 500, 300)

cli.entrer_parking(acces1)

parking.sauvegarder()
print(parking.mes_placement)