Example #1
0
 def test_is_valid_order_fails_wrong_order(self):
     tickets_data = main.load_tickets_data(self.ticket_lines)
     valid_tickets = main.get_valid_tickets(tickets_data)
     guess_order = ['class', 'row', 'seat']
     actual = main.is_valid_order(guess_order, tickets_data['rules'],
                                  valid_tickets)
     self.assertFalse(actual)
Example #2
0
 def test_guess_order_returns_correct_order(self):
     tickets_data = main.load_tickets_data(self.ticket_lines)
     valid_tickets = main.get_valid_tickets(tickets_data)
     fields = list(tickets_data['rules'].keys())
     actual = main.guess_order([], fields, tickets_data['rules'],
                               valid_tickets)
     self.assertEqual(actual, ['row', 'class', 'seat'])
Example #3
0
 def test_is_valid_order_validates_correct_order(self):
     tickets_data = main.load_tickets_data(self.ticket_lines)
     valid_tickets = main.get_valid_tickets(tickets_data)
     guess_order = ['row', 'class', 'seat']
     actual = main.is_valid_order(guess_order, tickets_data['rules'],
                                  valid_tickets)
     self.assertTrue(actual)
Example #4
0
 def test_load_ticket_data_returns_correct_data(self):
     actual = main.load_tickets_data(self.ticket_lines)
     self.assertIn(1, actual['rules']['class'])
     self.assertIn(7, actual['rules']['row'])
     self.assertNotIn(4, actual['rules']['seat'])
     self.assertEqual(actual['my_ticket'], [7, 1, 14])
     self.assertIn([7, 3, 47], actual['near_tickets'])
Example #5
0
 def test_get_ticket_field_by_name_returns_correct_field(self):
     tickets_data = main.load_tickets_data(self.ticket_lines)
     order = ['row', 'class', 'seat']
     actual = main.get_ticket_field_by_name(tickets_data['my_ticket'],
                                            'class', order)
     self.assertEqual(actual, 1)
Example #6
0
 def test_get_valid_tickets_returns_correct_tickets(self):
     tickets_data = main.load_tickets_data(self.ticket_lines)
     actual = main.get_valid_tickets(tickets_data)
     self.assertEqual(actual, [[7, 3, 47]])
Example #7
0
 def test_get_tickets_error_rate_returns_correct_count(self):
     tickets_data = main.load_tickets_data(self.ticket_lines)
     actual = main.get_tickets_error_rate(tickets_data)
     self.assertEqual(actual, 71)
Example #8
0
 def test_get_invalid_fields_validates_incorrect_ticket3(self):
     tickets_data = main.load_tickets_data(self.ticket_lines)
     actual = main.get_invalid_fields(tickets_data['rules'],
                                      tickets_data['near_tickets'][3])
     self.assertEqual(actual, [12])