This is a simple address book python implementation.
- Install dependencies
pip install -r requirements_dev.txt
. - Run
nosetests
or runnosetests --with-coverag
to run test with coverage report.
Package is 100% test Coverage
Name | Stmts | Miss | Cover |
---|---|---|---|
address_book/__init__.py |
0 | 0 | 100% |
address_book/base.py |
6 | 0 | 100% |
address_book/models.py |
46 | 0 | 100% |
TOTAL | 163 | 0 | 100% |
from address_book import models
address_book = models.AddressBook()
person = models.Person('Jack', 'Scoot')
person.add_email = '[email protected]'
person.add_address = 'Alex Company, Random Street'
person.add_phone_number = '999-999-9999'
address_book.add_person(person)
from address_book import models
address_book = models.AddressBook()
person = models.Person('Jack', 'Scoot')
person.add_email = '[email protected]'
person.add_address = 'Alex Company, Random Street'
person.add_phone_number = '999-999-9999'
group = models.Group('Friends')
group.add_member(person)
address_book.add_person(person)
address_book.add_group(group)
from address_book import models
address_book = models.AddressBook()
group = models.Group('Friends')
address_book.add_group(group)
from address_book import models
address_book = models.AddressBook()
person = address_book.find_person_by_name('Jack')
print(person.get_full_name())
>>> Jack Scott
from address_book import models
address_book = models.AddressBook()
person = address_book.find_person_by_email('[email protected]')
print(person.get_full_name())
>>> Jack Scott
Phone address book is a collection of persons and groups. It's implemented as Singleton, so you will have one instance of address book in package
Add person to address book
- person: person object
Add group to address book
- group: group object
Find person by email address (can supply either the exact string or a prefix string) ie. both "[email protected]" and "alex" should work. group
- email: person's email an supply either the exact string or a prefix string
- First person found
Find person by name (can supply either first name, last name, or both)
- search_term: either person's first name, last name, or both
- First person found
--
Person contact information
- A person has a first name and a last name.
- A person has one or more street addresses.
- A person has one or more email addresses.
- A person has one or more phone numbers.
- A person can be a member of one or more groups.
Add address to person information
- address: person's address to be added
Add email to person information
- email: person's email to be added
Add phone number to person information
- phone_number: person's phone number to be added
Return person's full name
- person's full name
--
Persons Group
Add member to the group
- person: person who will be a member in group
--
Find person by email address (can supply any substring, ie. "comp" should work assuming "[email protected]" is an email address in the address book)
If we aggregate the persons's contact information regardless of the type of information like this:
{'contact_info': ['[email protected]'
'Alex Company, Random Street',
...
]
}
We can search for comp in the contact_info, or more better is creating a method that aggregate the contact information and return it as on string and search for comp in it, but these soltion will have big time complexity for that we can gather all of these information in text file or json file and update the file everytime user add a conntact informtaiont to the person object.