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()
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
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
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
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)
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
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
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
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')
def check_check_ignore(ignores, path, ans): doc = LocalDoc('/mock/app', create=False) doc.ignores = ignores assert doc.check_ignore(path) is ans
def test_create(self): doc = LocalDoc(self.dir, create=True) assert self.exists('.couchapprc') assert self.exists('.couchappignore')
def test_load_ignores_non_exist(): doc = LocalDoc('/mock/app', create=False) assert doc.ignores == []