class MyTestCase ( unittest.TestCase ): def setUp(self): self.upl = YaUploader(token) def test_create_folder(self): self.assertEqual(self.upl.create_folder('test'), 201) def test_folder_found(self): self.assertEqual(self.upl.folder_info('test'), 'Folder found') def test_folder_not_found(self): self.assertEqual(self.upl.folder_info('Зasdf'), None)
def setUp(self): self.upl = YaUploader(token)
class TestYaD: def setup(self): self.token = TOKEN self.uploader = YaUploader(self.token) self.uploader.mkdir('some_random_dir') def teardown(self): """подчищаем созданные""" self.uploader.del_dir('some_random_dir') self.uploader.del_dir('new_shiny_dir') def test_get_dir(self): """проверка метода проверки папки""" code = self.uploader.get_dir('some_random_dir') assert rc(code) == 200 def test_mkdir(self): """проверка метода создания папки""" code = self.uploader.mkdir('new_shiny_dir') assert rc(code) == 201 def test_get_dir(self): """проверка что папка действительно создана""" code = self.uploader.get_dir('new_shiny_dir') assert rc(code) == 200 def test_mkdir(self): """проверка создания существующей папки""" code = self.uploader.mkdir('new_shiny_dir') assert rc(code) == 409 def test_mkdir(self): """проверка создания некорректной папки""" code = self.uploader.mkdir('') assert rc(code) == 400 def test_mkdir(self): """проверка создания папки без авторизации""" bad_uploader = YaUploader('bad_token') code = bad_uploader.mkdir('bad_dir') assert rc(code) == 401
def test_mkdir(self): """проверка создания папки без авторизации""" bad_uploader = YaUploader('bad_token') code = bad_uploader.mkdir('bad_dir') assert rc(code) == 401
def setup(self): self.token = TOKEN self.uploader = YaUploader(self.token) self.uploader.mkdir('some_random_dir')
def test_create_folder_not_authorized(): expected_result = 401 assert YaUploader(ytoken, path).create_folder() == expected_result print('Not authorized')
def test_create_folder_ok(): expected_result = 201 assert YaUploader(ytoken, path).create_folder() == expected_result print('Folder made successfully')
def test_create_folder_ok_path_aleady_exists(): expected_result = 409 assert YaUploader(ytoken, path).create_folder() == expected_result print('Folder already exists')