def test_group_search2(self):
        """Returns 'name' when name does exist. We start with a new
        collection of people so we know what we start with."""

        group = d.Group(self.__class__.driver)
        result = group.search('Shane')  # Shane is in database
        self.assertEqual(result, 'Shane')
def letters_for_all():
    driver = login_database.login_neo4j_cloud()
    mail = d.Group(driver)
    path_letters = os.getcwd()
    print(f"You chose to send letters for everyone. "
          f"The letters have been completed and you "
          f"can find them here: {path_letters}")
    mail.letters()
def more_choices():
    driver = login_database.login_neo4j_cloud()
    mail = d.Group(driver)
    individual = d.Individual(driver)
    r = login_database.login_redis_cloud()

    while True:
        name = input('\nChoose an Option: \n'
                     'e - to exit\n'
                     'list - To see a list of names, or\n'
                     'Type a name to start your thank you letter >>')
        if name == 'e':
            return
        if name == 'list':
            mail.print_donors()
        else:
            print('\n''Ok, you want to write a letter for {}, '
                  'lets see what we can do.'.format(name))

            if mail.search(name) is None:
                yes_no = input('The name you entered is not in the database.'
                               'Would you like to add this name? y or n >>\n')
                if yes_no == 'n':
                    return

                if yes_no == 'y':
                    last_name = input(f"What is {name}'s last name?\n")
                    email = input(f"What is {name}'s email?\n")
                    telephone = input(f"What is {name}'s telephone #?\n")
                    d.Individual.redis_add_new(r,
                                               name,
                                               last_name,
                                               telephone,
                                               email)
                else:
                    return
            print(f"First confirm {name}'s information")
            individual.donor_verification(r, name)
            confirm_info = input("Does the donor info look ok? y or n >>\n")
            if confirm_info == 'n':
                update_redis(r, name)
            amount = input('\n''What is the donation amount? or '
                           '\'e\' to exit >')
            if amount == 'e':
                return
            try:
                if int(amount) <= 0:
                    print('\nYou entered an invalid amount!!\n')
                    return
            except ValueError:
                print('\nYou entered an invalid amount!!\n')
                return ValueError
            else:
                individual.add_donation(name, float(amount))
                print(individual.thank_you(name, float(amount)))
    def test_print_donors(self):
        """Prints all the people in the database"""

        # Delete existing collection of people first to start fresh. This
        # is handled in the Load_Tables.py script.
        log.info('First delete the test_collection so we can start over.')
        Load_Tables.load_neo4j(self.__class__.driver)

        # Start the test routine
        group = d.Group(self.__class__.driver)
        result = collections.Counter(group.print_donors())
        expected = collections.Counter(
            ['Shane', 'Zach', 'Joe', 'Pete', 'Fitz'])
        self.assertEqual(result, expected)
    def test_summary(self):
        """Test dictionary set with {Donor: Total, number of donations,
        and average donation amount}"""
        # Delete existing collection of people first to start fresh. This
        # is handled in the Load_Tables.py script.
        log.info('First delete the test_collection so we can start over.')
        Load_Tables.load_neo4j(self.__class__.driver)

        # Start the test routine
        group = d.Group(self.__class__.driver)
        result = group.summary()
        test_against = {
            'Shane': [21, 3, 7.0],
            'Joe': [15, 5, 3.0],
            'Zach': [10, 1, 10.0],
            'Pete': [15, 2, 7.5],
            'Fitz': [1, 1, 1.0]
        }
        self.assertDictEqual(result, test_against)
def delete_donor():
    driver = login_database.login_neo4j_cloud()
    mail = d.Group(driver)
    individual = d.Individual(driver)
    while True:
        name = input('\nWhich donor would you like to delete? \n'
                     'e - to exit\n'
                     'list To see a list of names, or\n'
                     'Type the name of the donor to delete.>>')
        if name == 'e':
            return
        if name == 'list':
            mail.print_donors()
        else:
            print('\n''Ok, you want to delete {}, '
                  'lets see what we can do.'.format(name))

            if mail.search(name) is None:
                print('The name you entered is not in the database.')
                return
            else:
                individual.delete_donor(name)
 def test_group_search1(self):
     """Returns None when name does not exist"""
     group = d.Group(self.__class__.driver)
     result = group.search('Bob')  # Bob is not in database
     self.assertEqual(result, None)
def print_report():
    driver = login_database.login_neo4j_cloud()
    mail = d.Group(driver)
    print(mail.report())