예제 #1
0
 def test_seperate(self):
     testargs = ['Ex1', 'SEPERATE', r'files\itemsMerged.txt', r'output1.txt', 'output2.txt']
     capturedOutput = StringIO()
     sys.stdout = capturedOutput
     parse_args(testargs)
예제 #2
0
 def test_union_1_txt_2_no(self):
     testargs = ['Ex1', 'UNION', r'files\extrafiles\emptyfile.csv', r'files\extrafiles\noending', 'bla']
     capturedOutput = StringIO()
     sys.stdout = capturedOutput
     parse_args(testargs)
     assert capturedOutput.buflist[0] == 'input files in the wrong formats'
예제 #3
0
 def test_SEPERATE_bad_structure_3(self):
     testargs = ['Ex1', 'SEPERATE', r'files\extrafiles\bad_structure_3.txt', r'output1.txt', 'output2.txt']
     capturedOutput = StringIO()
     sys.stdout = capturedOutput
     parse_args(testargs)
     assert capturedOutput.buflist[0] == 'files\\extrafiles\\bad_structure_3.txt structure is not consistent, different number of attributes'
예제 #4
0
 def test_Like_1_bad_index_to_big(self):
     testargs = ['Ex1', 'LIKE', r'files\users.txt', 50,'*','output.txt']
     capturedOutput = StringIO()
     sys.stdout = capturedOutput
     parse_args(testargs)
     assert capturedOutput.buflist[0] == 'Error! Column does not exist in table'
예제 #5
0
 def test_Like_str(self):
     testargs = ['Ex1', 'LIKE', r'files\items.txt', 1,'Bowling','outputstrlike.txt']
     capturedOutput = StringIO()
     sys.stdout = capturedOutput
     parse_args(testargs)
예제 #6
0
 def test_Distinct_no_ending(self):
     testargs = ['Ex1', 'DISTINCT', r'files\\extrafiles\noending', -3, 'output.txt']
     capturedOutput = StringIO()
     sys.stdout = capturedOutput
     parse_args(testargs)
     assert capturedOutput.buflist[0] == 'Error! Illegal file extension'
예제 #7
0
 def test_Like_1_empty_2_null(self):
     testargs = ['Ex1', 'LIKE', r'blabla', 2,'*','output.txt']
     capturedOutput = StringIO()
     sys.stdout = capturedOutput
     parse_args(testargs)
     assert capturedOutput.buflist[0] == 'Input file not found'
예제 #8
0
 def test_union_bad_structure_3(self):
     testargs = ['Ex1', 'UNION', r'files\users.txt', r'files\extrafiles\bad_structure_3.txt', 'bla.txt']
     capturedOutput = StringIO()
     sys.stdout = capturedOutput
     parse_args(testargs)
     assert capturedOutput.buflist[0] == 'files\\extrafiles\\bad_structure_3.txt structure is not consistent, different number of attributes'
예제 #9
0
 def test_union_diffrent_types_int_iter(self):
     testargs = ['Ex1', 'UNION', r'files\extrafiles\intfile1.txt', r'files\extrafiles\strfile1.txt', 'bla.txt']
     capturedOutput = StringIO()
     sys.stdout = capturedOutput
     parse_args(testargs)
     assert capturedOutput.buflist[0] == 'Error! The table\'s format does not match'
예제 #10
0
 def test_bad_command(self):
     testargs = ['Ex1', 'blabla']
     capturedOutput = StringIO()
     sys.stdout = capturedOutput
     parse_args(testargs)
     assert capturedOutput.buflist[0] == 'unknown command'
예제 #11
0
 def test_union_users_ratings(self):
     testargs = ['Ex1', 'UNION', r'files\users.txt', r'files\ratings.txt', 'bla']
     capturedOutput = StringIO()
     sys.stdout = capturedOutput
     parse_args(testargs)
     assert capturedOutput.buflist[0] == 'Error! The table\'s format does not match'
예제 #12
0
 def test_union_1_csv_2_txt(self):
     testargs = ['Ex1', 'UNION', r'files\extrafiles\emptyfile.csv', r'files\extrafiles\emptyfile.txt', 'bla']
     capturedOutput = StringIO()
     sys.stdout = capturedOutput
     parse_args(testargs)
     assert capturedOutput.buflist[0] == 'files extensions should be the same'
예제 #13
0
 def test_union_1_empty_1_ok(self):
     testargs = ['Ex1', 'UNION', r'files\extrafiles\emptyfile.txt', r'files\ratings.txt', 'bla']
     capturedOutput = StringIO()
     sys.stdout = capturedOutput
     parse_args(testargs)
예제 #14
0
 def test_union_1_both_empty(self):
     testargs = ['Ex1', 'UNION', r'files\extrafiles\emptyfile.txt', r'files\extrafiles\emptyfile.txt', 'bla']
     capturedOutput = StringIO()
     sys.stdout = capturedOutput
     parse_args(testargs)
     assert capturedOutput.buflist[0] == 'both tables are empty'
예제 #15
0
 def test_union_bad_num_of_args_to_many(self):
     testargs = ['Ex1','UNION', 'bla', 'bla','bla','bla']
     capturedOutput = StringIO()
     sys.stdout = capturedOutput
     parse_args(testargs)
     assert capturedOutput.buflist[0] == 'number of parameters for command is wrong, should be 5'
예제 #16
0
 def test_union_3(self):
     testargs = ['Ex1', 'UNION', r'files\ratings.txt', r'files\ratings (2).txt', 'union3.txt']
     capturedOutput = StringIO()
     sys.stdout = capturedOutput
     parse_args(testargs)
예제 #17
0
 def test_Distinct_big_index(self):
     testargs = ['Ex1', 'DISTINCT', r'files\items.txt', 5, 'output.txt']
     capturedOutput = StringIO()
     sys.stdout = capturedOutput
     parse_args(testargs)
     assert capturedOutput.buflist[0] == 'Error! Column does not exist in table'
예제 #18
0
 def test_seperate_1_empty_2_null(self):
     testargs = ['Ex1', 'SEPERATE', r'blabla', r'files\extrafiles\emptyfile.txt', 'bla']
     capturedOutput = StringIO()
     sys.stdout = capturedOutput
     parse_args(testargs)
     assert capturedOutput.buflist[0] == 'Input file not found'
예제 #19
0
 def test_Distinct_by_itr(self):
     testargs = ['Ex1', 'DISTINCT', r'files\extrafiles\iterativefile2.txt', 1, 'outputdisitr.txt']
     capturedOutput = StringIO()
     sys.stdout = capturedOutput
     parse_args(testargs)
예제 #20
0
 def test_seperate_empty_output(self):
     testargs = ['Ex1', 'SEPERATE', r'files\extrafiles\emptyfile.txt', r'', 'bla']
     capturedOutput = StringIO()
     sys.stdout = capturedOutput
     parse_args(testargs)
     assert capturedOutput.buflist[0] == 'invalid output path'
예제 #21
0
 def test_like_bad_num_of_args(self):
     testargs = ['Ex1','LIKE', 'bla',]
     capturedOutput = StringIO()
     sys.stdout = capturedOutput
     parse_args(testargs)
     assert capturedOutput.buflist[0] == 'number of parameters for command is wrong, should be 4 or 5 or 6'
예제 #22
0
 def test_seperate_Bad_ending(self):
     testargs = ['Ex1', 'SEPERATE', r'files\extrafiles\noending', r'output1', 'output2']
     capturedOutput = StringIO()
     sys.stdout = capturedOutput
     parse_args(testargs)
     assert capturedOutput.buflist[0] == 'input file is in the wrong formats'
예제 #23
0
 def test_Like_1_bad_regular_expr(self):
     testargs = ['Ex1', 'LIKE', r'files\items.txt', 1,'!@#$%%^&*((','output.txt']
     capturedOutput = StringIO()
     sys.stdout = capturedOutput
     parse_args(testargs)
     assert capturedOutput.buflist[0] == 'Error! Invalid regular expression'
예제 #24
0
 def test_seperate_3_files(self):
     testargs = ['Ex1', 'SEPERATE', r'files\extrafiles\mergedwith3.txt', r'output1.txt', 'output2.txt']
     capturedOutput = StringIO()
     sys.stdout = capturedOutput
     parse_args(testargs)
     assert capturedOutput.buflist[0] == 'more than two values to split for in the merged file'
예제 #25
0
 def test_Like_int(self):
     testargs = ['Ex1', 'LIKE', r'files\ratings.txt', 1,'55','outputintlike.txt']
     capturedOutput = StringIO()
     sys.stdout = capturedOutput
     parse_args(testargs)
예제 #26
0
 def test_union_1_null_2_empty(self):
     testargs = ['Ex1', 'UNION', r'blabla', r'files\extrafiles\emptyfile.txt', 'bla']
     capturedOutput = StringIO()
     sys.stdout = capturedOutput
     parse_args(testargs)
     assert capturedOutput.buflist[0] == 'file 1 or file 2 does not exist'