def test_read_file(self): """Tests if the user is attempting to read content from already existing file """ test_user = CommandHandler() test_user.register("test10", "brsgvegveiotyq39ty") test_user.login("test10", "brsgvegveiotyq39ty") test_user.write_file("z.txt", "Hello World!n") expected = "\nReading file from 0 bytes to 100 bytes\nHello World!n" actual = test_user.read_file("z.txt") self.assertEqual(expected, actual) test_user.quit()
def test_write_file(self): """Tests if the user is attempting to create and write content into a file """ test_user = CommandHandler() test_user.register("test9", "nlndgsvns") test_user.login("test9", "nlndgsvns") expected = "\nCreated and written data to file k.txt successfully" actual = test_user.write_file("k.txt", "Hello World") self.assertEqual(expected, actual) # Check also if the user able to append new data to the # existing file expected = "\nSuccess Written data to file k.txt successfully" actual = test_user.write_file("k.txt", "Hello Second World") self.assertEqual(expected, actual) test_user.quit()