Esempio n. 1
0
    def test_add_interactions(self, first, last, attributes):
        # adding multiple interaction
        # must copy first, otherwise just testing against itself
        oldinteractions = copy.deepcopy(attributes.get('interaction', []))

        p = Person(first, last, attributes)
        v = ("talked shop over beers and sliders", "grabbed lunch")

        p.add_interactions(v)
        newinteractions = p.attributes['interaction']

        for i in v:
            oldinteractions.append(i)

        assert oldinteractions == newinteractions
Esempio n. 2
0
    def test_add_interaction(self, first, last, attributes):
        # adding single interaction
        # must copy first, otherwise just testing against itself
        # if end object doesn't already make a copy of attributes
        oldinteractions = copy.deepcopy(attributes.get('interaction', []))

        p = Person(first, last, attributes)
        v = "talked shop over beers and sliders"

        p.add_interactions(v)
        newinteractions = p.attributes['interaction']

        oldinteractions.append(v)

        assert oldinteractions == newinteractions
Esempio n. 3
0
    def get_people(self):
        """
        Returns all people in db as a list.  Init db if it doesn't exist
        XXX try making as a generator function in future?
        """
        people = []

        try:
            with open(self.path, newline='') as csvfile:
                person_reader = reader(csvfile, delimiter="|")
                for row in person_reader:
                    att = {k: v for k, v in zip(self.header(), row)}
                    person = Person(att['first_name'], att['last_name'], att)

                    # notes and attributes are lists of strings!
                    nts = person.get_notes()
                    person.replace_notes(string_to_list(nts))

                    intract = person.get_interactions()
                    person.replace_interactions(string_to_list(intract))

                    # people.append(person)
                    yield person

        except FileNotFoundError:
            self.init_db()
Esempio n. 4
0
def add_person_cli(args, db):
    """Creating/updating person and adding to db via CLI"""
    print("Adding/updating person...")
    first_name = args.first_name
    last_name = args.last_name

    p = Person(first_name, last_name, cli_att_to_dict(args.attributes))
    db.add_person(p, overwrite=True)
Esempio n. 5
0
    def test_get_interactions(self, first, last, attributes):
        p = Person(first, last, attributes)
        # must copy and occur first, otherwise just testing against itself
        oldinteractions = copy.deepcopy(attributes.get('interaction', []))

        # asserting that interations retrieved are right ones
        assert p.get_interactions() == oldinteractions

        v = ["talked shop over beers and sliders", "grabbed lunch"]
        p.add_interactions(v)

        for i in v:
            oldinteractions.append(i)
        assert p.get_interactions() == oldinteractions
Esempio n. 6
0
import copy
import pytest
from poundingpave.person import Person
from poundingpave.person_db_csv import Person_DB_CSV as DB

# XXX this is (semi-)faulty test input  because we are not resetting
# the test data
# all changes are being made inplace..
test_people_inputs = [
    Person("james", "dean", {}),  # no attributes
    Person(
        "billy",
        "joel",
        {  # full attributes, mult inter & notes
            'company':
            'piano man co',
            'email':
            '*****@*****.**',
            'mobile_phone':
            '925-414-8282',
            'work_phone':
            '415-777-6942',
            'role':
            'musician',
            'interaction':
            ["coffee, 5/12", "phone call, 5/14", "phone call, 6/30"],
            'notes': [
                'good person to know for music composition',
                'starting music production company'
            ]
        }),
Esempio n. 7
0
 def test_set_role(self, first, last, attributes):
     p = Person(first, last, attributes)
     v = "lazy bum"
     p.set_role(v)
     assert p.attributes['role'] == v
Esempio n. 8
0
 def test_set_work_phone(self, first, last, attributes):
     p = Person(first, last, attributes)
     v = '777-777-7777'
     p.set_work_phone(v)
     assert p.attributes['work_phone'] == v
Esempio n. 9
0
 def test_set_mobile_phone(self, first, last, attributes):
     p = Person(first, last, attributes)
     v = "555-555-5555"
     p.set_mobile_phone(v)
     assert p.attributes['mobile_phone'] == v
Esempio n. 10
0
 def test_set_email(self, first, last, attributes):
     p = Person(first, last, attributes)
     v = "different email"
     p.set_email(v)
     assert p.attributes['email'] == v
Esempio n. 11
0
 def test_set_company(self, first, last, attributes):
     p = Person(first, last, attributes)
     v = "different company"
     p.set_company(v)
     assert p.attributes['company'] == v
Esempio n. 12
0
 def test_name(self, first, last, attributes):
     # name test cases
     p = Person(first, last, attributes)
     n = p.get_name()
     assert isinstance(n, tuple)
     assert n == (first, last)
Esempio n. 13
0
    def test_replace_interactions(self, first, last, attributes):
        p = Person(first, last, attributes)
        v = ["talked shop over beers and sliders", "grabbed lunch"]

        p.replace_interactions(v)
        assert p.attributes["interaction"] == v