def test_last_by_email_that_contains(self): my_file = "test_data.csv" expected = [ 'Diana Harris', 'lime', 'Martin-Barnes', '*****@*****.**', '1-860-251-9980x6941', '5354' ] self.assertEqual(last(my_file, email__contains="@gmail"), expected)
def test_last_by_salary_gt_1000_and_lt_3000(self): my_file = "test_data.csv" expected = [ 'Julie Byrd', 'lime', 'Johnson-Reynolds', '*****@*****.**', '(664)760-9409', '1995' ] self.assertListEqual(last(my_file, salary__gt=1000, salary__lt=3000), expected)
def test_last_by_first_name_that_startswith(self): my_file = "test_data.csv" expected = [ 'Diana Harris', 'lime', 'Martin-Barnes', '*****@*****.**', '1-860-251-9980x6941', '5354' ] self.assertEqual(last(my_file, full_name__startswith="Diana Harris"), expected)
def test_last_by_salary_gt_1000_and_lt_3000_order_by_salary(self): my_file = "test_data.csv" expected = [ 'Michael Olson', 'olive', 'Scott, Young and King', '*****@*****.**', '114-116-1124x315', '2151' ] self.assertListEqual( last(my_file, salary__gt=1000, salary__lt=3000, order_by='salary'), expected)
def test_last_by_first_name_and_favourite_color(self): my_file = "test_data.csv" expected = [ 'Diana Harris', 'lime', 'Martin-Barnes', '*****@*****.**', '1-860-251-9980x6941', '5354' ] self.assertEqual( last(my_file, full_name="Diana Harris", favourite_color="lime"), expected)
def test_function_last_that_behaves_the_exact_same_way_as_filter_but_returns_only_last_element_of_result( self): expr = 'Diana' file = 'example_data.csv' expected_result = [ 'Diana May', '8587', '659-155-8389x092', 'Hart, Ray and Wagner', '*****@*****.**', 'olive' ] self.assertEqual((queries.last(file, full_name_startswith=expr)).sort(), expected_result.sort())