def test_contents_of_return_type_ascii(self): if sys.version_info[0] == 3: contents = contents_of(self.tmp.name, 'ascii') assert_that(contents).is_type_of(str) else: contents = contents_of(self.tmp.name, 'ascii') assert_that(contents).is_type_of(str)
def test_contents_of_return_type(tmpfile): if sys.version_info[0] == 3: contents = contents_of(tmpfile.name) assert_that(contents).is_type_of(str) else: contents = contents_of(tmpfile.name) assert_that(contents).is_type_of(unicode)
def test_contains_of_bad_type_failure(self): try: contents_of(123) fail('should have raised error') except ValueError as ex: assert_that(str(ex)).is_equal_to( 'val must be file or path, but was type <int>')
def test_contains_of_bad_type_failure(self): try: contents_of(123) except ValueError, ex: assert_that(ex.message).is_equal_to( 'val must be file or path, but was type <int>') return
def test_app(): data = {"name": "main", "age": 38} app.publish(template_path, data, outputpath) content = contents_of(os.path.join(outputpath, "my.py")) assert_that(content).contains("def main(){}")
def test_level_with_complex_file_name(): logger = Logger.getLogger("test_level_with_complex_name") logger.debug("debug for test_level_with_complex_name" ) # the content should be output to all.log content = contents_of("app_x1.log") assert_that(content).contains("debug for test_level_with_complex_name")
def test_level_info(): logger = Logger.getLogger("test_level_info") logger.debug("debug for test_level_info" ) # the content should not be output to all.log content = contents_of("all.log") assert_that(content).does_not_contain("debug for test_level_info")
def test_level_all(): logger = Logger.getLogger("test_level_all") logger.debug( 'debug for test_level_all') # the content should be output to all.log content = contents_of("all.log") assert_that(content).contains("debug for test_level_all")
def test_handler(): logger = Logger.getLogger('test_module1') logger.debug('debug for test_module1') assert_that('all.log').exists() content = contents_of('all.log') assert_that(content).contains("debug for test_module1")
def test_build_remote(): build_deploy_script("project1", "dev", remote_dict={ "key": "./remote_key", "remote_user": "******", "remote_addr": "10.0.0.9" }) assert_that(contents_of(get_deploy_host("project1", "dev"))).contains("[remote]\n") \ .contains("10.0.0.9") assert_that(contents_of(get_deploy_yml("project1", "dev"))).contains("hosts: remote") assert_that(get_deploy_ansible_cfg_path("project1", "dev")).exists() assert_that(contents_of(get_deploy_ansible_cfg_path("project1", "dev")))\ .contains("[defaults]\n") \ .contains("remote_user=alan") \ .contains("private_key_file=./remote_key") \ .contains("host_key_checking=False")
def test_build_gate_with_no_auth(): try: init_root(test_root()) build_gate(project_name, config_name, True, "inventory_service:/", "inventory_service") finally: init_root(os.getcwd()) yml_content = contents_of(os.path.join(test_root(), project_name, "deploy", "roles", "microservice_gate", "templates", "login.conf.template")) assert_that(yml_content.replace(os.linesep, '')).does_not_contain('location / {\tresolver {{auth_db_ip}} valid=30s')
def test_category(): logger = Logger.getLogger("test_module2") logger.debug('debug for test_module2' ) # the content should not be output to all.log logger1 = Logger.getLogger("test1") logger1.debug('debug for test1') # the content should be output to all.log content = contents_of("all.log") assert_that(content).does_not_contain("debug for test_module2")
def test_build_gate_with_proxy_mapping(): try: init_root(test_root()) build_gate(project_name, config_name, True, "inventory_service:/") finally: init_root(os.getcwd()) yml_content = contents_of(os.path.join(test_root(), project_name, "deploy", "roles", "microservice_gate", "templates", "login.conf.template")) assert_that(yml_content).contains('location / {') \ .contains('http://inventory_service/;')
def test_files(self): assert_that('foo.txt').exists() assert_that('foo.txt').is_file() #assert_that('mydir').exists() #assert_that('mydir').is_directory() assert_that('foo.txt').is_named('foo.txt') #assert_that('foo.txt').is_child_of('mydir') assert_that(contents_of('foo.txt')).starts_with('foo').ends_with('bar').contains('oob')
def test_config(): project_path = "project1" config_name = "dev" deploy_config(project_path, config_name) assert_that(contents_of(os.path.join(test_root(), project_path, "deploy", "." + config_name, "main.host"))) \ .contains("[all:vars]") \ .contains('name1 = aa bb') \ .contains('name2 = bb') \ .contains('name3 = c') \ .contains('1.1.1.1')
def test_files(self): assert_that('foo.txt').exists() assert_that('foo.txt').is_file() #assert_that('mydir').exists() #assert_that('mydir').is_directory() assert_that('foo.txt').is_named('foo.txt') #assert_that('foo.txt').is_child_of('mydir') contents = contents_of('foo.txt', 'ascii') assert_that(contents).starts_with('foo').ends_with('bar').contains('oob')
def test_files(self): assert_that('foo.txt').exists() assert_that('missing.txt').does_not_exist() assert_that('foo.txt').is_file() #assert_that('mydir').exists() assert_that('missing_dir').does_not_exist() #assert_that('mydir').is_directory() assert_that('foo.txt').is_named('foo.txt') #assert_that('foo.txt').is_child_of('mydir') contents = contents_of('foo.txt', 'ascii') assert_that(contents).starts_with('foo').ends_with('bar').contains('oob')
def test_files(): # setup with open('foo.txt', 'w') as fp: fp.write('foobar') assert_that('foo.txt').exists() assert_that('missing.txt').does_not_exist() assert_that('foo.txt').is_file() # assert_that('mydir').exists() assert_that('missing_dir').does_not_exist() # assert_that('mydir').is_directory() assert_that('foo.txt').is_named('foo.txt') # assert_that('foo.txt').is_child_of('mydir') contents = contents_of('foo.txt', 'ascii') assert_that(contents).starts_with('foo').ends_with('bar').contains('oob') # teardown os.remove('foo.txt')
def test_contains_of_missing_file_failure(self): try: contents_of('missing.txt') fail('should have raised error') except IOError as ex: assert_that(str(ex)).contains_ignoring_case('no such file')
from assertpy import assert_that, contents_of contents = contents_of('foo.txt', 'ascii') assert_that(contents).starts_with('foo').ends_with('bar').contains('oob')
def test_contents_of_file_ascii(self): contents = contents_of(self.tmp.file, 'ascii') assert_that(contents).is_equal_to('foobar').starts_with( 'foo').ends_with('bar')
def test_contents_of_path(self): contents = contents_of(self.tmp.name) assert_that(contents).is_equal_to('foobar').starts_with( 'foo').ends_with('bar')
def test_contents_of_file(tmpfile): contents = contents_of(tmpfile) assert_that(contents).is_equal_to('foobar').starts_with('foo').ends_with( 'bar')
def test_contents_of_path_ascii(tmpfile): contents = contents_of(tmpfile.name, 'ascii') assert_that(contents).is_equal_to('foobar').starts_with('foo').ends_with( 'bar')
def test_contains_of_bad_type_failure(self): try: contents_of(123) fail('should have raised error') except ValueError as ex: assert_that(str(ex)).is_equal_to('val must be file or path, but was type <int>')
def test_contents_of_file_ascii(self): contents = contents_of(self.tmp.file, 'ascii') assert_that(contents).is_equal_to('foobar').starts_with('foo').ends_with('bar')
def dumy(config_path): assert_that(config_path).exists() yml_content = contents_of(config_path) assert_that(yml_content).does_not_contain('"inventory_service"')
def test_contents_of_path(self): contents = contents_of(self.tmp.name) assert_that(contents).is_equal_to('foobar').starts_with('foo').ends_with('bar')