Beispiel #1
0
 def test_tag(self):
     path = os.path.realpath(__file__)
     self.call('tag', 'cohort', 'testing', path)
     fi = coda.find_one({'cohort': 'testing'})
     self.assertEqual(fi.path, path)
     coda.delete(fi)
     return
Beispiel #2
0
 def test_add(self):
     path = os.path.realpath(__file__)
     self.call('add', path)
     fi = coda.find_one({'path': path})
     self.assertEqual(fi.path, path)
     coda.delete(fi)
     return
Beispiel #3
0
def bootstrap():
    global __user_config__
    cwd = os.path.dirname(os.path.realpath(__file__))
    coda.db.__user_config__ = os.path.join(cwd, 'resources', '.coda')
    coda.db.options()
    coda.db.session.db.files.drop()
    coda.add(cl)
    yield
    coda.delete(cl)
    return
Beispiel #4
0
 def test_find(self):
     path = os.path.realpath(__file__)
     fi = coda.File(path=path,
                    metadata={
                        'cohort': 'testing',
                        'ext': 'py',
                        'type': 'source'
                    })
     coda.add(fi)
     res = self.call('find', 'cohort', 'testing')
     self.assertTrue('tests/test_coda.py' in res)
     coda.delete(fi)
     return
Beispiel #5
0
    def test_metadata(self):
        # test metadata setting
        one = os.path.join(__resources__, 'simple', 'one.txt')
        fi = coda.File(one, metadata={'one': 1})
        self.assertEqual(fi.one, 1)
        fi.two = 2
        self.assertEqual(fi.metadata.two, 2)

        # test implicit querying for files already in the database
        coda.add(fi)
        fi2 = coda.File(one)
        self.assertEqual(fi.one, 1)
        self.assertEqual(fi.metadata.one, 1)
        coda.delete(fi)
        return
Beispiel #6
0
 def test_list(self):
     path = os.path.realpath(__file__)
     fi = coda.File(path=path,
                    metadata={
                        'cohort': 'testing',
                        'ext': 'py',
                        'type': 'source'
                    })
     coda.add(fi)
     res = self.call('list')
     self.assertTrue('tests/test_coda.py' in res)
     res = self.call('list', path)
     self.assertTrue('"cohort": "testing"' in res)
     self.assertTrue('"ext": "py"' in res)
     self.assertTrue('"type": "source"' in res)
     coda.delete(fi)
     return
Beispiel #7
0
 def test_add_delete(self, path):
     # add
     fi = coda.File(path=path,
                    metadata={
                        'cohort': 'testing',
                        'ext': 'py',
                        'type': 'source'
                    })
     coda.add(fi)
     cl = coda.find({'cohort': 'testing'})
     self.assertEqual(len(cl), 1)
     self.assertEqual(cl[0].type, 'source')
     # update
     fi.metadata.type = 'newtype'
     fi.metadata.keep = True
     coda.add(fi)
     cl = coda.find({'cohort': 'testing'})
     self.assertEqual(cl[0].type, 'newtype')
     self.assertEqual(cl[0].keep, True)
     # delete
     coda.delete(fi)
     cl = coda.find({'cohort': 'testing'})
     self.assertEqual(cl, None)
     return
Beispiel #8
0
def tearDown():
    coda.delete(cl)
    return
Beispiel #9
0
def delete(args):
    """
    Delete file from internal database for tracking.
    """
    coda.delete(args.collection)
    return