コード例 #1
0
    def check_not_idfile(self, content, ans, mode='w'):
        # create ``_id`` file
        p = os.path.join(self.dir, '_id')
        with open(p, mode) as idfile:
            idfile.write(content)

        doc = LocalDoc(self.dir, create=False)
        assert doc.get_id() != ans, doc.get_id()
コード例 #2
0
ファイル: test_localdoc.py プロジェクト: couchapp/couchapp
    def check_not_idfile(self, content, ans, mode='w'):
        # create ``_id`` file
        p = os.path.join(self.dir, '_id')
        with open(p, mode) as idfile:
            idfile.write(content)

        doc = LocalDoc(self.dir, create=False)
        assert doc.get_id() != ans, doc.get_id()
コード例 #3
0
ファイル: test_localdoc.py プロジェクト: couchapp/couchapp
    def test_dirname(self):
        '''
        If the ``_id`` file does not eixsts
        '''
        dirname = os.path.split(self.dir)[-1]
        doc = LocalDoc(self.dir, is_ddoc=False)
        assert doc.get_id() == dirname

        doc = LocalDoc(self.dir, is_ddoc=True)
        ans = '_design/{0}'.format(dirname)
        assert doc.get_id() == ans
コード例 #4
0
ファイル: test_localdoc.py プロジェクト: couchapp/couchapp
def check_meta_to_fields(input, ans):
    output = LocalDoc._meta_to_fields(*input)

    assert ans == output
    # check the is a copy of dict
    for i, o in zip(input, output):
        assert i is not o
コード例 #5
0
def check_meta_to_fields(input, ans):
    output = LocalDoc._meta_to_fields(*input)

    assert ans == output
    # check the is a copy of dict
    for i, o in zip(input, output):
        assert i is not o
コード例 #6
0
    def check_ignore(self, content, ans):
        # prepare ignore file
        path = os.path.join(self.dir, '.couchappignore')
        with open(path, 'w') as f:
            f.write(content)

        doc = LocalDoc(self.dir, create=False)
        assert doc.ignores == ans
コード例 #7
0
    def check(self, dirs, files, fields, manifest):
        [os.makedirs(os.path.join(self.dir, d)) for d in dirs]
        [open(os.path.join(self.dir, f), 'a').close() for f in files]

        out_m = []
        out_f = LocalDoc(self.dir).dir_to_fields(self.dir, manifest=out_m)

        assert out_f == fields
        assert set(out_m) == set(manifest)
コード例 #8
0
    def check_text_file(self, ans):
        name = 'README.rst'
        p = os.path.join(self.dir, name)

        with open(p, 'wb') as f:
            f.write(ans)

        content = LocalDoc._encode_content(name, p)
        assert content == ans.decode('utf8'), content
コード例 #9
0
    def check_bin_file(self, bits, ans):
        name = 'a.out'
        p = os.path.join(self.dir, name)

        with open(p, 'wb') as f:
            f.write(bits)

        content = LocalDoc._encode_content(name, p)
        assert content == 'base64-encoded;' + ans
コード例 #10
0
ファイル: test_localdoc.py プロジェクト: couchapp/couchapp
    def check_json_suffix(self, content, ans):
        name = 'magic.json'
        p = os.path.join(self.dir, name)

        with open(p, 'w') as f:
            f.write(content)

        content = LocalDoc._encode_content(name, p)
        assert content == ans
コード例 #11
0
    def check_json_suffix(self, content, ans):
        name = 'magic.json'
        p = os.path.join(self.dir, name)

        with open(p, 'w') as f:
            f.write(content)

        content = LocalDoc._encode_content(name, p)
        assert content == ans
コード例 #12
0
ファイル: test_localdoc.py プロジェクト: couchapp/couchapp
    def check_text_file(self, ans):
        name = 'README.rst'
        p = os.path.join(self.dir, name)

        with open(p, 'wb') as f:
            f.write(ans)

        content = LocalDoc._encode_content(name, p)
        assert content == ans.decode('utf8'), content
コード例 #13
0
ファイル: test_localdoc.py プロジェクト: couchapp/couchapp
    def check_bin_file(self, bits, ans):
        name = 'a.out'
        p = os.path.join(self.dir, name)

        with open(p, 'wb') as f:
            f.write(bits)

        content = LocalDoc._encode_content(name, p)
        assert content == 'base64-encoded;' + ans
コード例 #14
0
    def test_create_nothing(self):
        # .couchapprc already exists
        path = os.path.join(self.dir, '.couchapprc')
        with open(path, 'w') as f:
            f.write('{}')

        doc = LocalDoc(self.dir, create=True)

        assert self.exists('.couchapprc')
        assert not self.exists('.couchappignore')
コード例 #15
0
    def test_dirname(self):
        '''
        If the ``_id`` file does not eixsts
        '''
        dirname = os.path.split(self.dir)[-1]
        doc = LocalDoc(self.dir, is_ddoc=False)
        assert doc.get_id() == dirname

        doc = LocalDoc(self.dir, is_ddoc=True)
        ans = '_design/{0}'.format(dirname)
        assert doc.get_id() == ans
コード例 #16
0
ファイル: test_localdoc.py プロジェクト: couchapp/couchapp
def check_check_ignore(ignores, path, ans):
    doc = LocalDoc('/mock/app', create=False)
    doc.ignores = ignores
    assert doc.check_ignore(path) is ans
コード例 #17
0
def check_check_ignore(ignores, path, ans):
    doc = LocalDoc('/mock/app', create=False)
    doc.ignores = ignores
    assert doc.check_ignore(path) is ans
コード例 #18
0
    def test_create(self):
        doc = LocalDoc(self.dir, create=True)

        assert self.exists('.couchapprc')
        assert self.exists('.couchappignore')
コード例 #19
0
def test_load_ignores_non_exist():
    doc = LocalDoc('/mock/app', create=False)
    assert doc.ignores == []