コード例 #1
0
 def test_all_contacts(self):
     contact1 = Contact("Some Body", "*****@*****.**")
     self.assertEqual(len(contact1.all_contacts), 1)
     contact2 = Contact("Sandor Brody", "*****@*****.**")
     self.assertEqual(len(Contact.all_contacts), 2)
     contact3 = Contact("Elek Benedek", "*****@*****.**")
     self.assertEqual(len(Contact.all_contacts), 3)
コード例 #2
0
 def test_contactlist_search(self):
     self.assertEqual(len(Contact.all_contacts.search('John')), 0)
     contact1 = Contact("Some Body", "*****@*****.**")
     contact2 = Contact("Sandor Brody", "*****@*****.**")
     contact3 = Contact("Elek Benedek", "*****@*****.**")
     self.assertEqual(len(Contact.all_contacts.search('John')), 0)
     self.assertEqual(len(Contact.all_contacts.search('Benedek')), 1)
コード例 #3
0
def get_entry(uuid):
    """Get person's details by person's uuid and return responce with
    all set fields on success, otherwise corresponding error code with
    description. Reply format:
    {"name": <name>, "surname": <surname>, "country": <country>, ...}
    """
    return Contact().get_contact(uuid)
コード例 #4
0
def update_entry(uuid):
    """Update contact information and return uuid of person
    on success, otherwise error code with description.
    Request format (first two fields are obligatory):
    {"name": <name>, "surname": <surname>, "country": <country>, ...}
    """
    return Contact().update_contact(uuid, **request.json)
コード例 #5
0
def main():
    # create list
    l = List()
    list_name = 'My First List'
    list_name = add_my_list(l, list_name)

    for resp_val in json.loads(l.list().text):
        if resp_val.isdigit():
            # print(json.loads(l.list().text)[resp_val]['name'], list_name)
            if json.loads(l.list().text)[resp_val]['name'] == list_name:
                new_list_id = json.loads(l.list().text)[resp_val]['id']
                # print(new_list_id)

    c = Contact()
    contacts_file = os.path.dirname(os.path.realpath(__file__)) + '/contacts.csv'
    with open(contacts_file, 'r') as f:
        for line in f.readlines():
                resp = c.add(line, new_list_id)
                if json.loads(resp.text)['result_code'] == 1:
                    print(line, 'successfully added!')
                else:
                    print(line, "didn't get added. Message was: ", json.loads(resp.text)['result_message'])


    addr = Address()
    resp = addr.add('Kevin Inc', new_list_id)
    print(json.loads(resp.text)['result_message'])

    camp = Campaign()
    resp = camp.add('My Campaign', new_list_id)
    print(json.loads(resp.text)['result_message'])
コード例 #6
0
ファイル: run.py プロジェクト: SamNgigi/Contact-List
def create(first_name, last_name, phone_number, email_address):
    """  
    Function to create new contact
  """

    new_contact = Contact(first_name, last_name, phone_number, email_address)
    return new_contact
コード例 #7
0
 def __init__(self, *args, **kwargs):
     super(MainWindow, self).__init__(*args, **kwargs)
     self.setupUi(self)
     self.pushButton_addCon.clicked.connect(self.setup_contact)
     self.contact = Contact(self)
     self.contacts = self.contact.query.all()
     self.populateList(self.contacts)
コード例 #8
0
    def testSaveLoad(self):
        contactsList = ContactList()

        self.assertEqual({}, contactsList.contacts)
        contactsList.addContact(Contact('name1', "1234"))
        contactsList.addContact(Contact('name2', "2345"))
        contactsList.addContact(Contact('name3', "3456"))

        contactsList.save('contactsTest.csv')

        contactListLoaded = ContactList()
        contactListLoaded.load('contactsTest.csv')

        self.assertEqual(3, len(contactListLoaded.contacts))
        self.assertEqual('1234', contactListLoaded.contacts['name1'])
        self.assertEqual('2345', contactListLoaded.contacts['name2'])
        self.assertEqual('3456', contactListLoaded.contacts['name3'])
コード例 #9
0
    def testMergeLists(self):
        contactList1 = ContactList()
        contactList1.addContact(Contact('name1', "1234"))
        contactList1.addContact(Contact('name2', "2345"))
        contactList1.addContact(Contact('name3', "3456"))

        contactList2 = ContactList()
        contactList2.addContact(Contact('name1', "6789"))
        contactList2.addContact(Contact('name2', "6789"))
        contactList2.addContact(Contact('name3', "6789"))

        contactList1.mergeContacts(contactList2)
        self.assertEqual(3, len(contactList1.contacts))
        self.assertEqual('1234', contactList1.contacts['name1'])
        self.assertEqual('2345', contactList1.contacts['name2'])
        self.assertEqual('3456', contactList1.contacts['name3'])

        contactList2.addContact(Contact('name4', "6789"))

        contactList1.mergeContacts(contactList2)
        self.assertEqual(4, len(contactList1.contacts))
        self.assertEqual('1234', contactList1.contacts['name1'])
        self.assertEqual('2345', contactList1.contacts['name2'])
        self.assertEqual('3456', contactList1.contacts['name3'])
        self.assertEqual('6789', contactList1.contacts['name4'])
コード例 #10
0
def create_entry():
    """Add person. Operation generates uuid for person and returns it
       on success, otherwise error code with description.
       Request format (first two fields are obligatory):
       {"name": <name>, "surname": <surname>, "country": <country>, ...}
    """
    uuid = helpers.getuuid(request.json['name'], request.json['surname'])

    return Contact().add_contact(uuid, **request.json)
コード例 #11
0
ファイル: contact_test.py プロジェクト: SamNgigi/Contact-List
 def test_save_multiple_contacts(self):
     # Saving our setUp contact
     self.new_contact.save_contact()
     # Adding another contact
     self.added_contact = Contact("Ethan", "Hunt", "0786474",
                                  "*****@*****.**")
     # Saving our new contact
     self.added_contact.save_contact()
     # Checking to see if the length of our array has increased.
     self.assertEqual(len(Contact.contact_list), 2)
コード例 #12
0
ファイル: contact_test.py プロジェクト: SamNgigi/Contact-List
    def setUp(self):
        """  
      Set up method to run before each test case.

      We create our contact object instance that we will use to conduct to test different aspects of our Contact class.
    """

        # Create an object instance new_contact of class Contact
        self.new_contact = Contact("James", "Bond", "007007007",
                                   "*****@*****.**")
コード例 #13
0
def get_entries():
    """Get list of persons with available information on success,
    otherwise corresponding error code with description. Reply format:
    {<uuid>: {"name": <name>, "surname": <surname>, "country": <country>,...}}.

    Request format:
    {"limit": <limit>, "offset": <offset>}
    Parameter "offset" is optional.
    """
    return Contact().get_contacts(**request.json)
コード例 #14
0
def parse_aliases(aliases_str, contacts):
  if not aliases_str:
    return
  for keyvalue in aliases_str.split(','):
    try:
      alias, name = keyvalue.split('=')
    except ValueError:
      continue
    if re.search(r'^\d{19,23}$', alias):
      contact = Contact(name=name, gaia_id=alias)
      contact['gaia_id'].indexable = True
    elif re.search(r'[0-9+() -]{7,25}', alias) and 7 <= len(re.sub(r'[^0-9]', '', alias)) <= 18:
      phone = Contact.normalize_phone(alias)
      contact = Contact(name=name, phone=phone)
    elif re.search(r'[^:/]+@[a-zA-Z0-9.-]+', alias):
      contact = Contact(name=name, email=alias)
    else:
      fail('Unrecognized alias type: {!r}'.format(alias))
    contacts.add_or_merge(contact)
コード例 #15
0
ファイル: contact_test.py プロジェクト: SamNgigi/Contact-List
 def test_delete_contact(self):
     #Saving our setUp contact
     self.new_contact.save_contact()
     # Adding another contact
     self.added_contact = Contact("Ethan", "Hunt", "0786474",
                                  "*****@*****.**")
     # Saving our new contact
     self.added_contact.save_contact()
     # Calling our delete_contact function
     self.new_contact.delete_contact()
     # Checking to see if the length of our array has reduced
     self.assertEqual(len(Contact.contact_list), 1)
コード例 #16
0
ファイル: contact_test.py プロジェクト: SamNgigi/Contact-List
    def test_contact_exists(self):
        """  
      Tests if the contact_exists will return a boolean depending on
      whether or not a contact is found when a number is passed.
    """
        self.new_contact.save_contact()

        self.added_contact = Contact("Ethan", "Hunt", "0786474",
                                     "*****@*****.**")
        self.added_contact.save_contact()
        existing_contact = Contact.contact_exists("007007007")
        """  
      Here we use the assertTrue method for a change. that should return a boolean
    """
        self.assertTrue(existing_contact)
コード例 #17
0
    def addContact(self):
        fName = self.lineEdit.text()
        lName = self.lineEdit_2.text()
        email = self.lineEdit_2.text()
        mobile = self.lineEdit_2.text()
        address = self.textEdit.toPlainText()
        # print(address)
        # print(type(address))
        # data_holder = Contact()
        cont = Contact(fName, lName, email, mobile, address)
        db_session.add(cont)
        db_session.commit()

        print("human contact added to db")
        self.close()
コード例 #18
0
    def testMergeListsWithCollisionsResolving(self):
        contactList1 = ContactList()
        contactList1.addContact(Contact('name1', "1234"))
        contactList1.addContact(Contact('name2', "2345"))
        contactList1.addContact(Contact('name3', "3456"))

        contactList2 = ContactList()
        contactList2.addContact(Contact('name1', "6789"))
        contactList2.addContact(Contact('name2', "6789"))
        contactList2.addContact(Contact('name3', "6789"))

        resolvedCollisions = ContactList()
        resolvedCollisions.addContact(Contact('name1', "1234"))
        resolvedCollisions.addContact(Contact('name2', "6789"))
        resolvedCollisions.addContact(Contact('name3', "6789"))

        contactList1.mergeContacts(contactList2, resolvedCollisions)
        self.assertEqual(3, len(contactList1.contacts))
        self.assertEqual('1234', contactList1.contacts['name1'])
        self.assertEqual('6789', contactList1.contacts['name2'])
        self.assertEqual('6789', contactList1.contacts['name3'])
コード例 #19
0
def participant_to_contact(participant, book):
  if participant is None:
    raise ValueError(f'No participant!')
  name = participant.name
  phone = Contact.normalize_phone(participant.phone)
  gaia_id = participant.gaia_id
  # Check if the contact already exists.
  # First, try looking it up by name:
  name_results = book.get_all('names', name)
  for result in name_results:
    # If we found results, add the phone number and gaia_id.
    if phone and phone not in result['phones']:
      result['phones'].add(phone)
    if gaia_id and gaia_id not in result['gaia_ids']:
      result['gaia_ids'].add(gaia_id)
  # Then try looking up by phone number:
  phone_results = book.get_all('phones', phone)
  for result in phone_results:
    # If we found results, add the name and gaia_id.
    if name and not result.name:
      result.name = name
    if gaia_id and gaia_id not in result['gaia_ids']:
      result['gaia_ids'].add(gaia_id)
  # Finally, try looking up by gaia_id:
  gaia_results = book.get_all('gaia_ids', gaia_id)
  for result in gaia_results:
    # If we found results, add the name and phone number.
    if name and not result.name:
      result.name = name
    if phone and phone not in result['phones']:
      result['phones'].add(phone)
  # Return the first name result, first gaia result, first phone result, or if no hits,
  # make and add a new Contact.
  if name_results:
    return name_results[0]
  elif gaia_results:
    return gaia_results[0]
  elif phone_results:
    return phone_results[0]
  else:
    contact = Contact(name=name, phone=phone, gaia_id=gaia_id)
    book.add(contact)
    return contact
コード例 #20
0
ファイル: contact_test.py プロジェクト: SamNgigi/Contact-List
    def test_find_contact_by_number(self):
        """ 
      Test find_contact by number method that is meant to return a
      contact when given a number.
    """

        self.new_contact.save_contact()

        self.added_contact = Contact("Ethan", "Hunt", "0786474",
                                     "*****@*****.**")

        self.added_contact.save_contact()

        found_contact = Contact.find_by_number("0786474")
        """  
      Since we know that add_contact number is 0786474 with email
      [email protected], found contact method should return the same email.
    """
        self.assertEqual(found_contact.email, self.added_contact.email)
コード例 #21
0
def get_contacts(csv_file):
    #TODO: Allow adding to existing ContactBook.
    book = ContactBook()
    #TODO: Some special handling for phone numbers, emails, addresses to put the preferred one first.
    for row in read_csv(csv_file):
        contact = Contact()
        # Name
        if row.get('Name'):
            contact.name = row['Name']
        elif row.get('Organization 1 - Name'):
            contact.name = row['Organization 1 - Name']
        # Phone numbers
        parse_values(row,
                     contact,
                     'phones',
                     'Phone',
                     converter=Contact.normalize_phone)
        # Emails
        parse_values(row, contact, 'emails', 'E-mail')
        # Addresses
        parse_values(row,
                     contact,
                     'addresses',
                     'Address',
                     value_label='Formatted')
        # Organization
        parse_values(row,
                     contact,
                     'organizations',
                     'Organization',
                     value_label='Name')
        # Relationship
        # Note: There are instances where there's no Type, but there is a Value.
        # But currently no instances where there's a Value but no Type.
        parse_values(row, contact, 'relations', 'Relation')
        # Note
        if row.get('Note'):
            contact['notes'].add(row['Notes'])
        book.add(contact)
    return book
コード例 #22
0
ファイル: skylibprotocol.py プロジェクト: sgricci/digsby
 def OnPropertyChange(self, prop):
     print self, prop, getattr(self.skyacct, prop)
     if prop == 'status' and self.skyacct.status in ('LOGGED_IN', 7):
         self.change_state(self.Statuses.LOADING_CONTACT_LIST)
         self.self_buddy = SkypeBuddy(
             self.skylib.GetContact(self.skyacct.skypename), self)
         d = {self.self_buddy.name: self.self_buddy}
         g = []
         for c in self.skylib.GetHardwiredContactGroup(
                 'SKYPE_BUDDIES').GetContacts():
             b = SkypeBuddy(c, self)
             d[b.name] = b
             g.append(Contact(b, b.name))
         self.buddies.update(d)
         with self.root_group.frozen():
             self.root_group[:] = g
         self.cs = []
         for c in self.skylib.GetConversationList('ALL_CONVERSATIONS'):
             c.OnMessage = self.a_message
             self.cs.append(c)
         self.change_state(self.Statuses.ONLINE)
     if prop == 'status' and self.skyacct.status == 'LOGGED_OUT':
         print self.skyacct.logoutreason
         self.set_offline(getattr(self.Reasons, self.skyacct.logoutreason))
コード例 #23
0
    def testFindCollisions(self):
        contactList1 = ContactList()
        contactList1.addContact(Contact('name1', "1234"))
        contactList1.addContact(Contact('name2', "2345"))
        contactList1.addContact(Contact('name3', "3456"))

        contactList2 = ContactList()

        self.assertEqual(0, len(contactList1.findCollisions(contactList2)))

        contactList2.addContact(Contact('name1', "6789"))
        contactList2.addContact(Contact('name2', "2345"))
        contactList2.addContact(Contact('name4', "1234"))

        collisions = contactList1.findCollisions(contactList2)
        self.assertEqual(1, len(collisions))
        self.assertEqual("name1", collisions[0].name)
        self.assertEqual("1234", collisions[0].phoneNumber1)
        self.assertEqual("6789", collisions[0].phoneNumber2)
コード例 #24
0
 def test_contact_entries(self):
     contact = Contact("Some Body", "*****@*****.**")
     self.assertEqual(hasattr(contact, 'name'), True)
     self.assertEqual(hasattr(contact, 'email'), True)
     self.assertEqual(contact.name, "Some Body")
     self.assertEqual(contact.email, "*****@*****.**")
コード例 #25
0
 def test_contactlist_longest_name(self):
     self.assertEqual(Contact.all_contacts.longest_name(), None)
     contact1 = Contact("Some", "*****@*****.**")
     contact2 = Contact("Sandor", "*****@*****.**")
     contact3 = Contact("Elek Benedek", "*****@*****.**")
     self.assertEqual(Contact.all_contacts.longest_name(), "Elek Benedek")
コード例 #26
0
 def test_all_contacts_with_suppliers(self):
     supplier1 = Supplier("Supp Lier", "*****@*****.**")
     contact1 = Contact("Some Body", "*****@*****.**")
     self.assertEqual(len(Contact.all_contacts), 2)
コード例 #27
0
ファイル: main.py プロジェクト: TyranR/ad-03-Function2
from contacts import Contact
from phonebook import PhoneBook

jhon = Contact('Jhon',
               'Smith',
               '+71234567809',
               telegram='@jhony',
               email='*****@*****.**',
               address='USA')
donald = Contact('Donald',
                 'Trump',
                 '+712134267809',
                 favorite=True,
                 address='White House')
george = Contact('George',
                 'Bush',
                 '+1232134267809',
                 True,
                 status='ExPresident')
bill = Contact('Bill', 'Clinton', '+7892134267809', instrument='Sax')
barack = Contact('Barack ', 'Obama', '+778934267809', born="Africa")

Mypb = PhoneBook('Mypb')
Mypb.add_new(jhon)
Mypb.add_new(donald)
Mypb.add_new(george)
Mypb.add_new(bill)
# Mypb.print_book()
# Mypb.remove('+71234567809')
# Mypb.print_book()
# Mypb.search_fav()
コード例 #28
0
ファイル: server.py プロジェクト: itucsdb1618/itucsdb1618
from hypeline import Hypeline
from picture import Picture
from rehype import Rehype
from role import Role
from trending import Trending
from user import User
from hypeblock import Hypeblock
from dislike import dislike
from hypes import Hype
from login import Login

app = Flask(__name__)
app.secret_key = 'A0Z//hdfg^+%j/3yX R~XHHsadfaf]LWX/,?RT'
app.attachment=Attachment(app)
app.block=block(app)
app.contacts=Contact(app)
app.favorite=Favorite(app)
app.followers=followers(app)
app.hypeline=Hypeline(app)
app.picture=Picture(app)
app.rehype=Rehype(app)
app.role=Role(app)
app.trending=Trending(app)
app.user=User(app)
app.hypeblock=Hypeblock(app)
app.dislike=dislike(app)
app.hype=Hype(app)
app.login=Login(app)


def get_elephantsql_dsn(vcap_services):
コード例 #29
0
def populate(total=10):
    for person in range(total):
        db.session.add(Contact(fname=fake.first_name(), lname=fake.last_name(), addr=fake.street_address(), email=fake.email(), phone=fake.phone_number()))
    db.session.commit()
コード例 #30
0
def delete_entry(uuid):
    """Delete person. Operation received uuid and returns it on
       success, otherwise corresponding error code with description.
    """
    return Contact().del_contact(uuid)