Exemple #1
0
    def test_get_titles(self):
        colls = [
            {"collection_id": "1", "title": "title 1"},
            {"collection_id": "2", "title": "title 2"},
            {"collection_id": "3", "title": "title 3"}
        ]

        for collection_params in colls:
            new_collection = collection.Collection(**collection_params)
            self.db.session.add(new_collection)

        self.db.session.commit()
        titlesDict = collection.get_titles(["1", "2", "3"])
        assert_equals(titlesDict["1"], "title 1")
        assert_equals(titlesDict["3"], "title 3")
Exemple #2
0
    def test_init_collection(self):
        #make sure nothing there beforehand
        response = collection.Collection.query.filter_by(cid="socrates").first()
        assert_equals(response, None)

        new_collection = collection.Collection("socrates")
        new_cid = new_collection.cid        
        print new_collection

        # still not there
        response = collection.Collection.query.filter_by(cid="socrates").first()
        assert_equals(response, None)

        self.db.session.add(new_collection)
        self.db.session.commit()

        # and now poof there it is
        response = collection.Collection.query.filter_by(cid="socrates").first()
        assert_equals(response.cid, "socrates")
Exemple #3
0
    def test_collection_with_tiids(self):
        test_tiid = "123213213"
        new_collection_tiid = collection.CollectionTiid(tiid=test_tiid)

        new_collection = collection.Collection("socrates")
        new_cid = new_collection.cid        
        print new_collection

        new_collection.tiid_links = [new_collection_tiid]
        print new_collection.tiids
        assert_equals(new_collection.tiid_links, [new_collection_tiid])

        self.db.session.add(new_collection_tiid)
        self.db.session.add(new_collection)
        self.db.session.commit()

        # and now poof there it is
        response = collection.Collection.query.filter_by(cid="socrates").first()
        assert_equals(response.cid, "socrates")
        assert_equals(response.tiid_links, [new_collection_tiid])
        assert_equals(new_collection_tiid.collection.query.all(), [new_collection])
Exemple #4
0
    def test_make_creates_identifier(self):
        coll = collection.Collection()
        assert_equals(len(coll.cid), 6)

        coll = collection.Collection(cid="socrates")
        assert_equals(coll.cid, "socrates")