コード例 #1
0
ファイル: test_file.py プロジェクト: ghostsquad/assertpy
 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)
コード例 #2
0
ファイル: test_file.py プロジェクト: rodfersou/assertpy
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)
コード例 #3
0
 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)
コード例 #4
0
 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>')
コード例 #5
0
 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
コード例 #6
0
ファイル: test_app.py プロジェクト: cao5zy/code-engine
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(){}")
コード例 #7
0
ファイル: test_logger_level.py プロジェクト: cao5zy/slogger
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")
コード例 #8
0
ファイル: test_logger_level.py プロジェクト: cao5zy/slogger
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")
コード例 #9
0
ファイル: test_logger_level.py プロジェクト: cao5zy/slogger
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")
コード例 #10
0
ファイル: test_logger_handler.py プロジェクト: cao5zy/slogger
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")
コード例 #11
0
ファイル: build_test.py プロジェクト: cao5zy/Managed_Deploy
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")
コード例 #12
0
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')
コード例 #13
0
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")
コード例 #14
0
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/;')
コード例 #15
0
    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')
コード例 #16
0
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')
コード例 #17
0
ファイル: test_readme.py プロジェクト: zhaoxiaojun/assertpy
    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')
コード例 #18
0
    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')
コード例 #19
0
ファイル: test_readme.py プロジェクト: ninadmhatre/assertpy
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')
コード例 #20
0
 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')
コード例 #21
0
from assertpy import assert_that, contents_of

contents = contents_of('foo.txt', 'ascii')
assert_that(contents).starts_with('foo').ends_with('bar').contains('oob')
コード例 #22
0
 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')
コード例 #23
0
 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')
コード例 #24
0
ファイル: test_file.py プロジェクト: rodfersou/assertpy
def test_contents_of_file(tmpfile):
    contents = contents_of(tmpfile)
    assert_that(contents).is_equal_to('foobar').starts_with('foo').ends_with(
        'bar')
コード例 #25
0
ファイル: test_file.py プロジェクト: rodfersou/assertpy
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')
コード例 #26
0
ファイル: test_file.py プロジェクト: ghostsquad/assertpy
 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')
コード例 #27
0
ファイル: test_file.py プロジェクト: ghostsquad/assertpy
 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>')
コード例 #28
0
ファイル: test_file.py プロジェクト: ghostsquad/assertpy
 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')
コード例 #29
0
 def dumy(config_path):
     assert_that(config_path).exists()
     yml_content = contents_of(config_path)
     assert_that(yml_content).does_not_contain('"inventory_service"')
コード例 #30
0
ファイル: test_file.py プロジェクト: ghostsquad/assertpy
 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')