def test_person_location_out_of_order_priorities_are_correct():
    p = Person(Name='calvin')
    now_dt = arrow.get('2014-01-01T09:09:00.000-05:00')
    tw = PersonTimeWindow(LocationName='kitchen',
                          Priority=100,
                          ical=ical_event,
                          CompareDateTime=now_dt)
    p.add_window(tw)
    tw = PersonTimeWindow(LocationName='media_room',
                          Priority=300,
                          ical=ical_event,
                          CompareDateTime=now_dt)
    p.add_window(tw)
    tw = PersonTimeWindow(LocationName='bedroom',
                          Priority=200,
                          ical=ical_event,
                          CompareDateTime=now_dt)
    p.add_window(tw)
    pm = PersonManager()
    pm.update_window_set(p)
    with patch.object(Scheduler, 'get_messages', return_value=[mock_message1]):
        runner = CliRunner()
        result = runner.invoke(cli,
                               obj=Config(),
                               args=[
                                   '--location_name', 'test', '--simulate_dt',
                                   now_dt.isoformat(), 'queue'
                               ])
    if result.exit_code > 0:
        exc_type, exc_value, exc_traceback = result.exc_info
        logging.error(
            traceback.format_exception(exc_type, exc_value, exc_traceback))
    assert 'Publishing message for person calvin to location media_room' in \
           result.output
Beispiel #2
0
def test_person_req_phys_conf_sets_req_phys_conf_for_loc_verify(p_mock):
    pm = PersonManager()
    p = Person(Name='calvin')
    p.require_physical_confirmation = True
    pm.update_window_set(p)
    lv = LocationVerification(LocationName='room', PersonName='calvin')
    assert lv.person.require_physical_confirmation
Beispiel #3
0
def test_preference_is_sorted_correctly():
    pm = PersonManager()
    p = Person(Name='calvin')
    now_dt = arrow.get('2014-01-01T07:10:00.000-05:00')
    tw = PersonTimeWindow(LocationName='kitchen',
                          Priority=100,
                          ical=ical_event_before_school,
                          CompareDateTime=now_dt)
    p.add_window(tw)
    tw = PersonTimeWindow(LocationName='bedroom',
                          Priority=200,
                          ical=ical_event_before_school,
                          CompareDateTime=now_dt)
    p.add_window(tw)
    pm.update_window_set(p)
    assert p.all_available(now_dt)[0].priority == 200
    assert p.all_available(now_dt)[1].priority == 100
    tw = PersonTimeWindow(LocationName='mediaroom',
                          Priority=50,
                          ical=ical_event_before_school,
                          CompareDateTime=now_dt)
    p.add_window(tw)
    pm.update_window_set(p)
    p = pm.get_person('calvin')
    assert p.all_available(now_dt)[0].priority == 200
    assert p.all_available(now_dt)[1].priority == 100
    assert p.all_available(now_dt)[2].priority == 50
Beispiel #4
0
def test_can_save_physical_confirmation_false_preference():
    pm = PersonManager()
    p = Person(Name='calvin')
    p.require_physical_confirmation = False
    pm.update_window_set(p)
    p = pm.get_person('calvin')
    assert not p.require_physical_confirmation
Beispiel #5
0
def main():
    print("Welcome to Python's main function!")

    print("Starting our sample cafe...")
    cafe = Cafe()

    print("Fred's Turn")
    person = Person("Fred", 100)
    person.Buy(cafe.Drinks[0].getPrice(), cafe.Drinks[2].getPrice(),
               cafe.CafeFood[2].getPrice())
    print(person.getMoney())

    print("Jess' Turn")
    person = Person("Jess", 0)
    person.Buy(cafe.CafeFood[0].getPrice())
    print(person.getMoney())
Beispiel #6
0
    def __init__(self, paths):
        """Constructor."""

        # Paths needed.
        self.path_video = paths[0]

        self.path_dlib = paths[1]  # Face detection

        self.path_genre_model = paths[2]  # Genre of a person detection
        self.path_genre_txt = paths[3]

        self.path_skin_color = paths[4]  # Skin color
        self.path_skin_color_txt = paths[5]

        self.path_emotion1 = paths[6]  # Emotion detection
        self.path_emotion2 = paths[7]

        self.path_picture_face_recognition = paths[8]  # Recognition
        self.path_recognition_dlib = paths[9]

        self.path_eyes = paths[10]  # Eyes detection
        self.haar = paths[11]  # Face detection

        # CONSTRUCTOR: Hand
        self.hand_tracking = None
        self.hand_movements = None
        self.hand_position = None
        self.hand_sign = None

        # CONSTRUCTOR: Eyes
        self.eyes_tracking = None
        self.eye_sign = None

        # CONSTRUCTOR: Face
        self.face_tracking = None
        self.face_movements = None
        self.face_information = None

        # CONSTRUCTOR: Body
        self.body_distance = None

        # CONSTRUCTOR: Analyses
        self.eyes_analyse = None
        self.hand_analyse = None
        self.head_analyse = None
        self.body_analyse = None

        # CONSTRUCTOR: database
        self.person = Person(self.path_picture_face_recognition)

        # CONSTRUCTOR: Display
        self.displaying2 = Displaying2(self.path_video,
                                       self.path_picture_face_recognition)

        # Tresholds

        # Stop all operations (except detection of features (faces, hands ...))
        # if the last face was detected above 0.5 secs.
        self.treshold_face_detection_timer = 0.5
    def test_get_list_of_names(self):
        """Tests to see if it prints a list of people's names that are in a room
        """
        self.dojo.create_room("livingspace", "test")

        allan = Person("allan", "great")
        john = Person("john", "doe")
        mark = Person("mark", "alvin")

        people = [allan, john, mark]

        self.dojo.all_rooms[
            0].occupants = people  # assigned the people to the room's occupants

        self.assertListEqual(people,
                             self.dojo.print_room("test"),
                             msg="list of names found and printed")
Beispiel #8
0
def test_no_locations_returns_error(c_mock, l_mock):
    e = test_event()
    lm = LibraryManager()
    lm.update_message(Name='dinner', Message='time for dinner')
    pm = PersonManager()
    p = Person(Name='calvin')
    pm.update_window_set(p)
    c_mock.return_value = 0
    handler(e, {})
    l_mock.assert_called_with('No locations are available for calvin')
Beispiel #9
0
def lambda_handler(event, context):
    char = Person()
    char.gen_upp()
    char.set_name()
    response = char.supp_4()
    return {
        'statusCode': 200,
        'headers': {
            'Content-Type': "text/html"
        },
        'body': response
    }
Beispiel #10
0
def test_add_multiple_returns_correct_number():
    p = Person(Name='calvin')
    now_dt = arrow.get('2014-01-01T09:09:00.000-05:00')
    tw = PersonTimeWindow(LocationName='kitchen',
                          Priority=100,
                          ical=ical_event,
                          CompareDateTime=now_dt)
    p.add_window(tw)
    tw = PersonTimeWindow(LocationName='bedroom',
                          Priority=200,
                          ical=ical_event,
                          CompareDateTime=now_dt)
    p.add_window(tw)
    assert p.all_available_count(now_dt) == 2
Beispiel #11
0
def main():
    game = DrawGame()
    done = False
    attr_rects = []
    player = Person(Attributes)
    while not done:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                done = True
            if event.type == pygame.MOUSEBUTTONUP:
                pos = pygame.mouse.get_pos()
                clicked_attrs = [s for s in attr_rects if s.collidepoint(pos)]
                for cc in clicked_attrs:
                    player.apply_activity(activities()[cc.label]())
        attr_rects = game.draw_game(player)
        game.clock.tick(60)
Beispiel #12
0
def test_saving_person_with_available_windows_are_available():
    now_dt = arrow.get('2014-01-01T09:09:00.000-05:00')
    pm = PersonManager()
    p = Person(Name='calvin')
    now_dt = arrow.get('2014-01-01T09:09:00.000-05:00')
    tw = PersonTimeWindow(LocationName='kitchen',
                          Priority=100,
                          ical=ical_event,
                          CompareDateTime=now_dt)
    p.add_window(tw)
    tw = PersonTimeWindow(LocationName='bedroom',
                          Priority=200,
                          ical=ical_event,
                          CompareDateTime=now_dt)
    p.add_window(tw)

    pm.update_window_set(p)
    assert p.all_available_count(now_dt) == 2
Beispiel #13
0
def test_saving_person_window_set_saves_set():
    pm = PersonManager()
    p = Person(Name='calvin')
    now_dt = arrow.get('2014-01-01T09:09:00.000-05:00')
    tw = PersonTimeWindow(LocationName='kitchen',
                          Priority=100,
                          ical=ical_event,
                          CompareDateTime=now_dt)
    p.add_window(tw)
    tw = PersonTimeWindow(LocationName='bedroom',
                          Priority=200,
                          ical=ical_event,
                          CompareDateTime=now_dt)
    p.add_window(tw)

    pm.update_window_set(p)
    p = pm.get_person('calvin')
    assert p.time_windows.count() == 2
Beispiel #14
0
def test_verify_switch_with_press_returns_true():
    rpi_mock.GPIO.setmode.return_value = None
    rpi_mock.GPIO.setup.return_value = None
    rpi_mock.GPIO.input.return_value = False
    pm = PersonManager()
    p = Person(Name='calvin')
    p.require_physical_confirmation = True
    pm.update_window_set(p)
    l = LocationAvailability(LocationName='kitchen')
    id = 12
    l.with_switch(HardwareId=id, Color='Red', Name='Test', Style='Circle')
    lm = LocationManager()
    lm.update_input_capabilities(l)
    lv = LocationVerification(LocationName='kitchen', PersonName='calvin')

    done, count, timeout = lv.verify_person_at_location()
    print done, count, timeout
    assert done and count == 1 and timeout < 3
def calvin_three_rooms(now_dt):
    p = Person(Name='calvin')
    tw = PersonTimeWindow(LocationName='kitchen',
                          Priority=100,
                          ical=ical_event,
                          CompareDateTime=now_dt)
    p.add_window(tw)
    tw = PersonTimeWindow(LocationName='media_room',
                          Priority=300,
                          ical=ical_event,
                          CompareDateTime=now_dt)
    p.add_window(tw)
    tw = PersonTimeWindow(LocationName='bedroom',
                          Priority=200,
                          ical=ical_event,
                          CompareDateTime=now_dt)
    p.add_window(tw)
    pm = PersonManager()
    pm.update_window_set(p)
Beispiel #16
0
def test_create_person_with_name_sets_name():
    p = Person(Name='Calvin')
    assert p.name == 'Calvin'
Beispiel #17
0
def test_full_name_empty_middle() -> None:
    person: Person = Person("Curie", "Marie", "")

    result = person.full_name()

    assert result == "Marie Curie"
Beispiel #18
0
def test_full_name_null_middle() -> None:
    person: Person = Person("Curie", "Marie", None)

    assert person.full_name() == "Marie Curie"
Beispiel #19
0
def test_init_all_args_given() -> None:
    person: Person = Person("Curie", "Marie", "Skłodowska")

    assert person.given_name == "Marie"
    assert person.middle_name == "Skłodowska"
    assert person.family_name == "Curie"
Beispiel #20
0
def test_invalid_message_returns_error(l_mock, p_mock, m_mock):
    e = test_event()
    m_mock.return_value = None
    p_mock.return_value = Person()
    handler(e, {})
    l_mock.assert_called_with('There is no message named dinner')
Beispiel #21
0
 def test_creation(self):
   # Note that this also tests "creation_empty_data".  :)
   al = Person()
   self.assertIsInstance(al, Person)
Beispiel #22
0
def test_full_name_all_attributes_set() -> None:
    person: Person = Person("Curie", "Marie", "Skłodowska")

    result = person.full_name()

    assert result == "Marie Skłodowska Curie"
Beispiel #23
0
def test_full_name_first_only() -> None:
    person: Person = Person(None, "Aristotle", None)

    assert person.full_name() == "Aristotle"
Beispiel #24
0
def test_full_name_middle_only() -> None:
    person: Person = Person(None, None, "Skłodowska")

    assert person.full_name() == "Skłodowska"
Beispiel #25
0
from person.person import Person
from person.child import Child

person = Person("Peter", 25)
child = Child("Peter Junior", 5)
print(person.name)
print(person.age)
print(child.__class__.__bases__[0].__name__)
chat_data['Word count'] = chat_data['Content'].apply(count_words)

# list of names of people in the conversation
names = set(person)
names.remove('-')

# TO DO
# change file opening to more general
# make the requirement file
# make a better folder structure for the project
# write some unit tests, pylint, unittest

# This loop creates a person object for each person participating in the chat
for name in names:
    people.append(Person(name))

text_file = open('../Output.txt', 'w')

# This for loop calculates all the metrics for each person participating in the chat
# and creates the output text file and dataframes for the plots
for person in people:
    person.count_messages(chat_data)
    person.most_common_words(chat_data)
    person.count_total_words(chat_data)
    person.calculate_average()
    person.count_media(chat_data)
    person.count_words_by_month_day_hour(chat_data)

    print(person)
    text_file.write(str(person))
Beispiel #27
0
def test_location_verify_sets_person(p_mock):
    p = Person(Name='calvin')
    p.require_physical_confirmation = True
    p_mock.return_value = p
    lv = LocationVerification(LocationName='room', PersonName='calvin')
    assert p.name == lv.person_name
Beispiel #28
0
def test_full_name_last_only() -> None:
    person: Person = Person("Einstein", None, None)

    assert person.full_name() == "Einstein"
Beispiel #29
0
def test_repr() -> None:
    patient: Person = Person("Curie", "Marie", "Skłodowska")

    expected: str = f"given_name='Marie',middle_name='Skłodowska',family_name='Curie'"
    assert repr(patient) == expected