How to use not_expect method in tox

Best Python code snippet using tox_python

test_downloader.py

Source:test_downloader.py Github

copy

Full Screen

1import pytest2import os3import shutil4from src.synapse_downloader.download.downloader import Downloader5import synapseclient as syn6@pytest.fixture(scope='module')7def syn_data(syn_test_helper_class, mk_tempdir, mk_tempfile):8 download_dir = mk_tempdir()9 project = syn_test_helper_class.create_project(prefix='Project-')10 file0 = mk_tempfile()11 syn_file0 = syn_test_helper_class.create_file(prefix='file0-', path=file0, parent=project)12 syn_folder1 = syn_test_helper_class.create_folder(prefix='folder1-', parent=project)13 file1 = mk_tempfile()14 syn_file1 = syn_test_helper_class.create_file(prefix='file1-', path=file1, parent=syn_folder1)15 syn_folder2 = syn_test_helper_class.create_folder(prefix='folder2-', parent=syn_folder1)16 file2 = mk_tempfile()17 syn_file2 = syn_test_helper_class.create_file(prefix='file2-', path=file2, parent=syn_folder2)18 syn_file0_download_path = os.path.join(download_dir, syn_file0._file_handle.fileName)19 syn_folder1_download_path = os.path.join(download_dir, syn_folder1.name)20 syn_file1_download_path = os.path.join(syn_folder1_download_path, syn_file1._file_handle.fileName)21 syn_folder2_download_path = os.path.join(syn_folder1_download_path, syn_folder2.name)22 syn_file2_download_path = os.path.join(syn_folder2_download_path, syn_file2._file_handle.fileName)23 result = {24 'download_dir': download_dir,25 'project': project,26 'file0': file0,27 'syn_file0': syn_file0,28 'syn_file0_download_path': syn_file0_download_path,29 'syn_folder1': syn_folder1,30 'syn_folder1_download_path': syn_folder1_download_path,31 'file1': file1,32 'syn_file1': syn_file1,33 'syn_file1_download_path': syn_file1_download_path,34 'syn_folder2': syn_folder2,35 'syn_folder2_download_path': syn_folder2_download_path,36 'file2': file2,37 'syn_file2': syn_file2,38 'syn_file2_download_path': syn_file2_download_path,39 'all_syn_entities': [syn_folder1, syn_folder2, syn_file0, syn_file1, syn_file2],40 'all_syn_folders': [syn_folder1, syn_folder2],41 'all_syn_files': [syn_file0, syn_file1, syn_file2]42 }43 result['{0}_download_path'.format(syn_folder1.name)] = syn_folder1_download_path44 result['{0}_download_path'.format(syn_folder2.name)] = syn_folder2_download_path45 result['{0}_download_path'.format(syn_file0._file_handle.fileName)] = syn_file0_download_path46 result['{0}_download_path'.format(syn_file1._file_handle.fileName)] = syn_file1_download_path47 result['{0}_download_path'.format(syn_file2._file_handle.fileName)] = syn_file2_download_path48 return result49@pytest.fixture50def reset_download_dir():51 def _reset(syn_data):52 download_dir = syn_data['download_dir']53 if os.path.exists(download_dir):54 shutil.rmtree(download_dir)55 yield _reset56def assert_local_download_data(syn_data, expect=[], not_expect=[]):57 if not expect and not not_expect:58 raise Exception('must specify one: expect or not_expect')59 for syn_entity in expect:60 if isinstance(syn_entity, syn.File):61 assert os.path.isfile(syn_data.get('{0}_download_path'.format(syn_entity._file_handle.fileName)))62 else:63 assert os.path.isdir(syn_data.get('{0}_download_path'.format(syn_entity.name)))64 for syn_entity in not_expect:65 if isinstance(syn_entity, syn.File):66 assert not os.path.isfile(syn_data.get('{0}_download_path'.format(syn_entity._file_handle.fileName)))67 else:68 assert not os.path.isdir(syn_data.get('{0}_download_path'.format(syn_entity.name)))69def test_it_downloads_everything(syn_data, reset_download_dir):70 reset_download_dir(syn_data)71 download_dir = syn_data['download_dir']72 project = syn_data['project']73 all_syn_entities = syn_data['all_syn_entities']74 downloader = Downloader(project.id, download_dir)75 downloader.start()76 assert len(downloader.errors) == 077 assert_local_download_data(syn_data, expect=all_syn_entities)78def test_it_downloads_everything_with_entity_view(syn_data, reset_download_dir):79 reset_download_dir(syn_data)80 download_dir = syn_data['download_dir']81 project = syn_data['project']82 all_syn_entities = syn_data['all_syn_entities']83 downloader = Downloader(project.id, download_dir, with_view=True)84 downloader.start()85 assert len(downloader.errors) == 086 # TODO: Figure out how to test the view was used.87 assert_local_download_data(syn_data, expect=all_syn_entities)88def test_it_excludes_folders_by_id(syn_data, reset_download_dir):89 download_dir = syn_data['download_dir']90 project = syn_data['project']91 syn_file0 = syn_data['syn_file0']92 syn_folder1 = syn_data['syn_folder1']93 syn_file1 = syn_data['syn_file1']94 syn_folder2 = syn_data['syn_folder2']95 syn_file2 = syn_data['syn_file2']96 for with_view in [False, True]:97 reset_download_dir(syn_data)98 downloader = Downloader(project.id, download_dir, with_view=with_view, excludes=[syn_folder1.id])99 downloader.start()100 assert len(downloader.errors) == 0101 assert_local_download_data(syn_data,102 expect=[syn_file0],103 not_expect=[syn_folder1, syn_file1, syn_folder2, syn_file2])104 reset_download_dir(syn_data)105 downloader = Downloader(project.id, download_dir, with_view=with_view, excludes=[syn_folder2.id])106 downloader.start()107 assert len(downloader.errors) == 0108 assert_local_download_data(syn_data,109 expect=[syn_file0, syn_folder1, syn_file1],110 not_expect=[syn_folder2, syn_file2])111def test_it_excludes_folders_by_name(syn_data, reset_download_dir):112 download_dir = syn_data['download_dir']113 project = syn_data['project']114 syn_file0 = syn_data['syn_file0']115 syn_folder1 = syn_data['syn_folder1']116 syn_file1 = syn_data['syn_file1']117 syn_folder2 = syn_data['syn_folder2']118 syn_file2 = syn_data['syn_file2']119 for with_view in [False, True]:120 reset_download_dir(syn_data)121 downloader = Downloader(project.id, download_dir, with_view=with_view, excludes=[syn_folder1.name])122 downloader.start()123 assert len(downloader.errors) == 0124 assert_local_download_data(syn_data,125 expect=[syn_file0],126 not_expect=[syn_folder1, syn_file1, syn_folder2, syn_file2])127 reset_download_dir(syn_data)128 downloader = Downloader(project.id, download_dir, with_view=with_view, excludes=[syn_folder2.name])129 downloader.start()130 assert len(downloader.errors) == 0131 assert_local_download_data(syn_data,132 expect=[syn_file0, syn_folder1, syn_file1],133 not_expect=[syn_folder2, syn_file2])134def test_it_excludes_files_by_id(syn_data, reset_download_dir):135 download_dir = syn_data['download_dir']136 project = syn_data['project']137 all_syn_entities = syn_data['all_syn_entities']138 all_syn_folders = syn_data['all_syn_folders']139 all_syn_files = syn_data['all_syn_files']140 for with_view in [False, True]:141 # Exclude each file142 for syn_file in all_syn_files:143 reset_download_dir(syn_data)144 downloader = Downloader(project.id, download_dir, with_view=with_view, excludes=[syn_file.id])145 downloader.start()146 expected = all_syn_entities.copy()147 expected.remove(syn_file)148 assert len(downloader.errors) == 0149 assert_local_download_data(syn_data,150 expect=expected,151 not_expect=[syn_file])152 # Exclude all files153 reset_download_dir(syn_data)154 downloader = Downloader(project.id, download_dir, with_view=with_view, excludes=[f.id for f in all_syn_files])155 downloader.start()156 assert len(downloader.errors) == 0157 assert_local_download_data(syn_data,158 expect=all_syn_folders,159 not_expect=all_syn_files)160def test_it_excludes_files_by_name(syn_data, reset_download_dir):161 download_dir = syn_data['download_dir']162 project = syn_data['project']163 all_syn_entities = syn_data['all_syn_entities']164 all_syn_folders = syn_data['all_syn_folders']165 all_syn_files = syn_data['all_syn_files']166 for with_view in [False, True]:167 # Exclude each file168 for syn_file in all_syn_files:169 reset_download_dir(syn_data)170 downloader = Downloader(project.id, download_dir, with_view=with_view, excludes=[syn_file.name])171 downloader.start()172 expected = all_syn_entities.copy()173 expected.remove(syn_file)174 assert len(downloader.errors) == 0175 assert_local_download_data(syn_data,176 expect=expected,177 not_expect=[syn_file])178 # Exclude all files179 reset_download_dir(syn_data)180 downloader = Downloader(project.id, download_dir, with_view=with_view, excludes=[f.name for f in all_syn_files])181 downloader.start()182 assert len(downloader.errors) == 0183 assert_local_download_data(syn_data,184 expect=all_syn_folders,185 not_expect=all_syn_files)186def test_it_excludes_files_by_filename(syn_data, reset_download_dir):187 download_dir = syn_data['download_dir']188 project = syn_data['project']189 all_syn_entities = syn_data['all_syn_entities']190 all_syn_folders = syn_data['all_syn_folders']191 all_syn_files = syn_data['all_syn_files']192 for with_view in [False, True]:193 # Exclude each file194 for syn_file in all_syn_files:195 reset_download_dir(syn_data)196 downloader = Downloader(project.id, download_dir, with_view=with_view,197 excludes=[syn_file._file_handle.fileName])198 downloader.start()199 expected = all_syn_entities.copy()200 expected.remove(syn_file)201 assert len(downloader.errors) == 0202 assert_local_download_data(syn_data,203 expect=expected,204 not_expect=[syn_file])205 # Exclude all files206 reset_download_dir(syn_data)207 downloader = Downloader(project.id, download_dir, with_view=with_view,208 excludes=[f._file_handle.fileName for f in all_syn_files])209 downloader.start()210 assert len(downloader.errors) == 0211 assert_local_download_data(syn_data,212 expect=all_syn_folders,213 not_expect=all_syn_files)214# TODO: test downloading files of: 'concreteType': 'org.sagebionetworks.repo.model.file.ExternalFileHandle'...

Full Screen

Full Screen

test_stat.py

Source:test_stat.py Github

copy

Full Screen

1#!/usr/bin/python2.72# -*- coding: utf-8 -*-3#/**************************************************************************4# *5# * This file is part of the OSC(Open Source Community).6# * Copyright (C) by SanPolo Co.Ltd. 7# * All rights reserved.8# *9# * See http://osc.spolo.org/ for more information.10# *11# * SanPolo Co.Ltd12# * http://www.spolo.org/ spolo@spolo.org sales@spolo.org13# *14#**************************************************************************/15import unittest16from spolo.stat import get_file_list17from spolo.stat import get_user_list18#reload(sys)19#sys.setdefaultencoding('utf8') 20class parse_Tests(unittest.TestCase):21 def test1(self):22 expect = [23 '/home/chenyang/source/performance/testdata/test1.odt',24 '/home/chenyang/source/performance/testdata/test2.odt',25 ]26 filelist = get_file_list()27 print filelist28 #log = "\nExpect : %s\nBut return : %s" % (expect, filelist)29 #self.assertTrue(nl == expect, msg = log)30class get_user_list_Tests(unittest.TestCase):31 def test1(self):32 not_expect = []33 userlist = get_user_list()34 log = "\nNot Expect : %s\nBut return : %s" % (not_expect, userlist)35 self.assertFalse(userlist == not_expect, msg = log)36 def test2(self):37 not_expect = "masol"38 userlist = get_user_list()39 log = "\nNot Expect : %s\nBut return : %s" % (not_expect, userlist)40 self.assertFalse((not_expect in userlist), msg = log)41def main():42 unittest.main()43if __name__ == '__main__':44 main()...

Full Screen

Full Screen

test_xxutils.py

Source:test_xxutils.py Github

copy

Full Screen

1#!/usr/bin/python2.72# -*- coding: utf-8 -*-3#/**************************************************************************4# *5# * This file is part of the OSC(Open Source Community).6# * Copyright (C) by SanPolo Co.Ltd. 7# * All rights reserved.8# *9# * See http://osc.spolo.org/ for more information.10# *11# * SanPolo Co.Ltd12# * http://www.spolo.org/ spolo@spolo.org sales@spolo.org13# *14#**************************************************************************/15import os16import unittest17import datetime18from xxutils import get_user_list_from_trac19#reload(sys)20#sys.setdefaultencoding('utf8')21class get_user_list_from_trac_Tests(unittest.TestCase):22 def test1(self):23 """Test get_user_list_from_trac function24 must include people25 """26 expect = "chenzhongming"27 ul = get_user_list_from_trac()28 log = "\nExpect : %s in user list array.\nBut list is %s" % (expect, ul)29 self.assertTrue(expect in ul, msg = log)30 def test2(self):31 """Test get_user_list_from_trac function32 must not include people33 """34 not_expect = "chenyang"35 ul = get_user_list_from_trac()36 log = "\nExpect : %s not in user list array.\nBut list is %s" % (not_expect, ul)37 self.assertTrue(not_expect not in ul, msg = log)38def main():39 unittest.main()40if __name__ == '__main__':41 main()...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tox automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful