Esempio n. 1
0
    def test_update_requirements(self, get_all_names):
        get_all_names.return_value = {'a': 'a', 'b': 'b'}

        u = User('t')
        u.email = 'test@test'
        r = Repo(2, u)
        db.session.add(r)
        db.session.commit()

        with patch.object(Repo, 'fetch_requirements') as fetch_requirements:
            fetch_requirements.return_value = "a==1.0\nb==2.1"
            r.update_requirements()
            db.session.commit()

        reqs = Requirement.query.all()
        assert len(reqs) == 2, reqs
        assert (reqs[0].package.name, reqs[0].required_version) == ('a', '1.0')
        assert (reqs[1].package.name, reqs[1].required_version) == ('b', '2.1')
Esempio n. 2
0
    def test_update_requirements(self, get_all_names):
        get_all_names.return_value = {'a': 'a', 'b': 'b'}

        u = User('t')
        u.email = 'test@test'
        r = Repo(2, u)
        db.session.add(r)
        db.session.commit()

        with patch.object(Repo, 'fetch_requirements') as fetch_requirements:
            fetch_requirements.return_value = "a==1.0\nb==2.1"
            r.update_requirements()
            db.session.commit()

        reqs = Requirement.query.all()
        assert len(reqs) == 2, reqs
        assert (reqs[0].package.name, reqs[0].required_version) == ('a', '1.0')
        assert (reqs[1].package.name, reqs[1].required_version) == ('b', '2.1')
Esempio n. 3
0
 def fixture(self):
     u1 = User('u1')
     u1.email = 'test@test'
     u2 = User('u2')
     u2.email = 'test@test'
     r1 = Repo('r1', u1)
     r2 = Repo('r2', u2)
     p1 = Package('p1')
     p2 = Package('p2')
     req1 = Requirement(r1, p1)
     req2 = Requirement(r2, p1)
     req3 = Requirement(r2, p2)
     db.session.add(u1)
     db.session.add(u2)
     db.session.add(req1)
     db.session.add(req2)
     db.session.add(req3)
     db.session.commit()
     return locals()
Esempio n. 4
0
    def post_repos():
        # Add selected repos
        for name, github_id in request.form.iteritems():
            github_id = int(github_id)
            repo = Repo.query.filter(Repo.github_id == github_id,
                                     Repo.user_id == g.user.id).first()
            if repo is None:
                repo = Repo(github_id, g.user)
            repo.name = name
            db.session.add(repo)

        # Remove unselected repos
        ids = map(int, request.form.itervalues())
        for repo in g.user.repos:
            if repo.github_id not in ids:
                db.session.delete(repo)

        db.session.commit()
        return redirect(url_for('done'))
Esempio n. 5
0
    def post_repos():
        # Add selected repos
        for name, github_id in request.form.items():
            github_id = int(github_id)
            repo = Repo.query.filter(
                Repo.github_id == github_id,
                Repo.user_id == g.user.id).first()
            if repo is None:
                repo = Repo(github_id, g.user)
            repo.name = name
            db.session.add(repo)

        # Remove unselected repos
        ids = set(map(int, request.form.values()))
        for repo in g.user.repos:
            if repo.github_id not in ids:
                db.session.delete(repo)

        db.session.commit()
        return redirect(url_for('done'))