<s> from mock import patch , MagicMock <EOL> from unittest import TestCase <EOL> import pandas as pd <EOL> from pandashells . bin . p_merge import ( <EOL> main , <EOL> validate_args , <EOL> ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> class ValidateArgsTests ( TestCase ) : <EOL> def test_no_left ( self , stderr_mock ) : <EOL> args = MagicMock ( left_on = None , right_on = '<STR_LIT:test>' ) <EOL> with self . assertRaises ( SystemExit ) : <EOL> validate_args ( args ) <EOL> def test_no_right ( self , stderr_mock ) : <EOL> args = MagicMock ( left_on = '<STR_LIT:test>' , right_on = None ) <EOL> with self . assertRaises ( SystemExit ) : <EOL> validate_args ( args ) <EOL> def test_no_join ( self , stderr_mock ) : <EOL> args = MagicMock ( left_on = None , right_on = None , on = None ) <EOL> with self . assertRaises ( SystemExit ) : <EOL> validate_args ( args ) <EOL> class MainTests ( TestCase ) : <EOL> @ patch ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' . split ( ) ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> def test_cli ( self , df_from_input_mock , df_to_output_mock ) : <EOL> df_left = pd . DataFrame ( [ <EOL> { '<STR_LIT:a>' : <NUM_LIT:1> , '<STR_LIT:b>' : <NUM_LIT:1> , '<STR_LIT:c>' : <NUM_LIT:10> } , <EOL> { '<STR_LIT:a>' : <NUM_LIT:1> , '<STR_LIT:b>' : <NUM_LIT:2> , '<STR_LIT:c>' : <NUM_LIT:20> } , <EOL> { '<STR_LIT:a>' : <NUM_LIT:2> , '<STR_LIT:b>' : <NUM_LIT:1> , '<STR_LIT:c>' : <NUM_LIT:30> } , <EOL> { '<STR_LIT:a>' : <NUM_LIT:2> , '<STR_LIT:b>' : <NUM_LIT:2> , '<STR_LIT:c>' : <NUM_LIT> } , <EOL> ] ) <EOL> df_right = pd . DataFrame ( [ <EOL> { '<STR_LIT:d>' : <NUM_LIT:1> , '<STR_LIT:e>' : <NUM_LIT:1> , '<STR_LIT:f>' : <NUM_LIT:50> } , <EOL> { '<STR_LIT:d>' : <NUM_LIT:1> , '<STR_LIT:e>' : <NUM_LIT:2> , '<STR_LIT:f>' : <NUM_LIT> } , <EOL> { '<STR_LIT:d>' : <NUM_LIT:2> , '<STR_LIT:e>' : <NUM_LIT:1> , '<STR_LIT:f>' : <NUM_LIT> } , <EOL> { '<STR_LIT:d>' : <NUM_LIT:2> , '<STR_LIT:e>' : <NUM_LIT:2> , '<STR_LIT:f>' : <NUM_LIT> } , <EOL> ] ) <EOL> df_from_input_mock . side_effect = [ df_left , df_right ] <EOL> main ( ) <EOL> dfj = df_to_output_mock . call_args_list [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] <EOL> self . assertEqual ( list ( dfj . c ) , [ <NUM_LIT:10> , <NUM_LIT:20> , <NUM_LIT:30> , <NUM_LIT> ] ) <EOL> self . assertEqual ( list ( dfj . f ) , [ <NUM_LIT:50> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ) </s>
