Пример #1
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
Пример #2
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
Пример #3
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()
Пример #4
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)
Пример #5
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')
Пример #6
0
def check_check_ignore(ignores, path, ans):
    doc = LocalDoc('/mock/app', create=False)
    doc.ignores = ignores
    assert doc.check_ignore(path) is ans
Пример #7
0
    def test_create(self):
        doc = LocalDoc(self.dir, create=True)

        assert self.exists('.couchapprc')
        assert self.exists('.couchappignore')
Пример #8
0
def test_load_ignores_non_exist():
    doc = LocalDoc('/mock/app', create=False)
    assert doc.ignores == []