def test_shows_only_versions_for_ref(self, session): p = Project('foobar') repo = Repo( p, "firefly", "ubuntu", "trusty", ) repo.path = "some_path" repo2 = Repo( p, "hammer", "ubuntu", "precise", ) repo2.path = "some_path" session.commit() result = session.app.get('/repos/foobar/firefly/ubuntu/') assert result.status_int == 200 assert len(result.json) == 1 assert result.json == ["trusty"]
def test_multiple_distros_with_built_repos(self, session): p = Project('foobar') repo = Repo( p, "firefly", "ubuntu", "trusty", ) repo2 = Repo( p, "firefly", "centos", "7", ) repo.path = "some_path" repo2.path = "some_path" session.commit() result = session.app.get('/repos/foobar/firefly/') assert result.status_int == 200 assert len(result.json) == 2 assert result.json == {"ubuntu": ["trusty"], "centos": ['7']}
def test_ref_does_not_exist(self, session): p = Project('foobar') repo = Repo( p, "firefly", "ubuntu", "trusty", ) repo.path = "some_path" session.commit() result = session.app.get('/repos/foobar/hammer/ubuntu/trusty/', expect_errors=True) assert result.status_int == 404
def test_does_not_show_duplicate_distro_versions(self, session): p = Project('foobar') repo = Repo( p, "firefly", "ubuntu", "trusty", ) repo.path = "some_path" repo2 = Repo( p, "firefly", "ubuntu", "trusty", ) repo2.path = "some_path" session.commit() result = session.app.get('/repos/foobar/firefly/ubuntu/') assert result.status_int == 200 assert len(result.json) == 1 assert result.json == ["trusty"]
def test_do_not_show_refs_without_built_repos(self, session): p = Project('foobar') repo = Repo( p, "firefly", "ubuntu", "trusty", ) repo2 = Repo( p, "hammer", "ubuntu", "trusty", ) repo.path = "some_path" repo2.path = "some_path" session.commit() result = session.app.get('/repos/foobar/') assert result.status_int == 200 assert len(result.json) == 2 assert result.json == {"firefly": ["ubuntu"], "hammer": ["ubuntu"]}
def test_extra_metadata_default(self, session, url): p = Project('foobar') repo = Repo( p, "firefly", "ubuntu", "trusty", sha1="head", ) repo.path = "some_path" session.commit() result = session.app.get(url) assert result.json['extra'] == {}
def test_sha1_does_not_exist(self, session, url): p = Project('foobar') repo = Repo( p, "firefly", "ubuntu", "trusty", sha1="head", ) repo.path = "some_path" session.commit() result = session.app.get(url, expect_errors=True) assert result.status_int == 404
def test_default_flavor(self, session): p = Project('foobar') repo = Repo( p, "firefly", "ubuntu", "trusty", sha1="head", ) repo.path = "some_path" session.commit() result = session.app.get('/repos/foobar/firefly/head/ubuntu/trusty/flavors/') assert result.json == ['default']
def test_recreate_head(self, session, tmpdir, url): p = Project('foobar') repo = Repo( p, "firefly", "ubuntu", "trusty", sha1="head", ) repo.path = "some_path" session.commit() result = session.app.head(url) assert result.status_int == 200
def test_multiple_flavors(self, session): p = Project('foobar') repo = Repo( p, "firefly", "ubuntu", "trusty", sha1="head", ) repo.path = "some_path" repo = Repo( p, "firefly", "ubuntu", "trusty", sha1="head", flavor="tcmalloc", ) repo.path = "some_path" session.commit() result = session.app.get('/repos/foobar/firefly/head/ubuntu/trusty/flavors/') assert sorted(result.json) == sorted(['default', 'tcmalloc'])
def test_sha1_does_not_exist(self, session): p = Project('foobar') repo = Repo( p, "firefly", "ubuntu", "trusty", sha1="head", ) repo.path = "some_path" session.commit() result = session.app.get('/repos/foobar/firefly/sha1/', expect_errors=True) assert result.status_int == 404
def test_multiple_flavors(self, session): p = Project('foobar') repo = Repo( p, "firefly", "ubuntu", "trusty", sha1="head", ) repo.path = "some_path" repo = Repo( p, "firefly", "ubuntu", "trusty", sha1="head", flavor="tcmalloc", ) repo.path = "some_path" session.commit() result = session.app.get( '/repos/foobar/firefly/head/ubuntu/trusty/flavors/') assert sorted(result.json) == sorted(['default', 'tcmalloc'])
def test_shows_only_versions_for_ref(self, session): p = Project('foobar') repo = Repo( p, "firefly", "ubuntu", "trusty", sha1="head", ) repo.path = "some_path" repo2 = Repo( p, "hammer", "ubuntu", "precise", sha1="head", ) repo2.path = "some_path" session.commit() result = session.app.get('/repos/foobar/firefly/head/ubuntu/') assert result.status_int == 200 assert len(result.json) == 1 assert result.json == ["trusty"]
def test_does_not_show_duplicate_distro_versions(self, session): p = Project('foobar') repo = Repo( p, "firefly", "ubuntu", "trusty", sha1="head", ) repo.path = "some_path" repo2 = Repo( p, "firefly", "ubuntu", "trusty", sha1="head", ) repo2.path = "some_path" session.commit() result = session.app.get('/repos/foobar/firefly/head/ubuntu/') assert result.status_int == 200 assert len(result.json) == 1 assert result.json == ["trusty"]
def test_show_multiple_refs_with_built_repos(self, session): p = Project('foobar') repo = Repo( p, "firefly", "ubuntu", "trusty", sha1="HEAD", ) repo2 = Repo( p, "hammer", "ubuntu", "trusty", sha1="HEAD", ) repo.path = "some_path" repo2.path = "some_path" session.commit() result = session.app.get('/repos/foobar/') assert result.status_int == 200 assert len(result.json) == 2 assert result.json == {"firefly": ["HEAD"], "hammer": ["HEAD"]}
def test_single_project_with_built_repos(self, session): p = Project('foobar') repo = Repo( p, "firefly", "ubuntu", "trusty", ) repo.path = "some_path" session.commit() result = session.app.get('/repos/') assert result.status_int == 200 assert len(result.json) == 1 assert result.json == {"foobar": ["firefly"]}
def test_repo_type(self, session, url): p = Project('foobar') repo = Repo( p, "firefly", "ubuntu", "trusty", sha1="head", ) repo.path = "some_path" session.commit() result = session.app.get(url) assert result.status_int == 200 assert result.json["type"] is None
def test_default_flavor(self, session): p = Project('foobar') repo = Repo( p, "firefly", "ubuntu", "trusty", sha1="head", ) repo.path = "some_path" session.commit() result = session.app.get( '/repos/foobar/firefly/head/ubuntu/trusty/flavors/') assert result.json == ['default']
def test_recreate_head(self, session, tmpdir): p = Project('foobar') repo = Repo( p, "firefly", "ubuntu", "trusty", ) repo.path = "some_path" session.commit() result = session.app.head( "/repos/foobar/firefly/ubuntu/trusty/recreate" ) assert result.status_int == 200
def test_multiple_distros_with_built_repos(self, session): p = Project('foobar') repo = Repo( p, "firefly", "ubuntu", "trusty", sha1="head", ) repo2 = Repo( p, "firefly", "centos", "7", sha1="head", ) repo.path = "some_path" repo2.path = "some_path" session.commit() result = session.app.get('/repos/foobar/firefly/head/') assert result.status_int == 200 assert len(result.json) == 2 assert result.json == {"ubuntu": ["trusty"], "centos": ['7']}
def test_get_single_project(self, session): p = Project('foobar') repo = Repo( p, "firefly", "ubuntu", "trusty", sha1="head", ) repo.path = "some_path" session.commit() result = session.app.get('/repos/foobar/firefly/head/') assert result.status_int == 200 assert len(result.json) == 1 assert result.json == {"ubuntu": ["trusty"]}
def test_repo_exists(self, session): p = Project('foobar') repo = Repo( p, "firefly", "ubuntu", "trusty", ) repo.path = "some_path" session.commit() result = session.app.get('/repos/foobar/firefly/ubuntu/trusty/') assert result.status_int == 200 assert result.json["distro_version"] == "trusty" assert result.json["distro"] == "ubuntu" assert result.json["ref"] == "firefly"
def test_recreate(self, session, tmpdir, url): path = str(tmpdir) p = Project('foobar') repo = Repo( p, "firefly", "ubuntu", "trusty", sha1="head", ) repo.path = path session.commit() result = session.app.post_json(url, params={}) assert os.path.exists(path) is False assert result.json['needs_update'] is True assert result.json['is_queued'] is False
def test_recreate_invalid_path(self, session, tmpdir, url): path = str(tmpdir) invalid_path = os.path.join(path, 'invalid_path') p = Project('foobar') repo = Repo( p, "firefly", "ubuntu", "trusty", sha1="head", ) repo.path = invalid_path session.commit() result = session.app.post_json(url) assert os.path.exists(path) is True assert result.json['needs_update'] is True
def test_update_empty_json(self, session): p = Project('foobar') repo = Repo( p, "firefly", "ubuntu", "trusty", ) repo.path = "some_path" session.commit() result = session.app.post_json( "/repos/foobar/firefly/ubuntu/trusty/", params=dict(), expect_errors=True, ) assert result.status_int == 400
def test_update_empty_json(self, session, url): p = Project('foobar') repo = Repo( p, "firefly", "ubuntu", "trusty", sha1="head", ) repo.path = "some_path" session.commit() result = session.app.post_json( url, params=dict(), expect_errors=True, ) assert result.status_int == 400
def test_update(self, session, tmpdir, url): p = Project('foobar') repo = Repo( p, "firefly", "ubuntu", "trusty", sha1="head", ) repo.path = "some_path" session.commit() repo.get(1) repo.needs_update = False session.commit() result = session.app.post_json(url, params={}) assert result.json['needs_update'] is True assert result.json['is_queued'] is False
def test_repo_exists(self, session, url): p = Project('foobar') repo = Repo( p, "firefly", "ubuntu", "trusty", sha1="head", ) repo.path = "some_path" session.commit() result = session.app.get(url) assert result.status_int == 200 assert result.json["distro_version"] == "trusty" assert result.json["distro"] == "ubuntu" assert result.json["ref"] == "firefly" assert result.json["sha1"] == "head"
def test_recreate(self, session, tmpdir): path = str(tmpdir) p = Project('foobar') repo = Repo( p, "firefly", "ubuntu", "trusty", ) repo.path = path session.commit() result = session.app.post_json( "/repos/foobar/firefly/ubuntu/trusty/recreate", params={} ) assert os.path.exists(path) is False assert result.json['needs_update'] is True
def test_update_invalid_field_value(self, session): p = Project('foobar') repo = Repo( p, "firefly", "ubuntu", "trusty", ) repo.path = "some_path" session.commit() data = {"distro": 123} result = session.app.post_json( "/repos/foobar/firefly/ubuntu/trusty/", params=data, expect_errors=True, ) assert result.status_int == 400
def test_update_invalid_field_value(self, session, url): p = Project('foobar') repo = Repo( p, "firefly", "ubuntu", "trusty", sha1="head", ) repo.path = "some_path" session.commit() data = {"distro": 123} result = session.app.post_json( url, params=data, expect_errors=True, ) assert result.status_int == 400
def test_update(self, session, tmpdir): p = Project('foobar') repo = Repo( p, "firefly", "ubuntu", "trusty", ) repo.path = "some_path" session.commit() repo.get(1) repo.needs_update = False session.commit() result = session.app.post_json( "/repos/foobar/firefly/ubuntu/trusty/update", params={} ) assert result.json['needs_update'] is True
def test_add_extra_metadata(self, session, url): p = Project('foobar') repo = Repo( p, "firefly", "ubuntu", "trusty", sha1="head", ) repo.path = "some_path" session.commit() repo_id = repo.id data = {'version': '0.94.8', 'distros': ['precise']} session.app.post_json( url, params=data, ) updated_repo = Repo.get(repo_id) assert updated_repo.extra == {"version": "0.94.8", 'distros': ['precise']}
def test_does_show_refs_without_built_repos(self, session): p = Project('foobar') repo = Repo( p, "firefly", "ubuntu", "trusty", ) Repo( p, "hammer", "ubuntu", "trusty", ) repo.path = "some_path" session.commit() result = session.app.get('/repos/') assert result.status_int == 200 assert len(result.json) == 1 assert sorted(result.json["foobar"]) == sorted(["firefly", "hammer"])
def test_do_not_show_distro_without_built_repos(self, session): p = Project('foobar') repo = Repo( p, "firefly", "ubuntu", "trusty", ) Repo( p, "firefly", "centos", "7", ) repo.path = "some_path" session.commit() result = session.app.get('/repos/foobar/firefly/') assert result.status_int == 200 assert len(result.json) == 1 assert result.json == {"ubuntu": ["trusty"]}
def test_update(self, session, tmpdir, url): p = Project('foobar') repo = Repo( p, "firefly", "ubuntu", "trusty", sha1="head", ) repo.path = "some_path" session.commit() repo.get(1) repo.needs_update = False session.commit() result = session.app.post_json( url, params={} ) assert result.json['needs_update'] is True assert result.json['is_queued'] is False
def test_update_invalid_fields(self, session): p = Project('foobar') repo = Repo( p, "firefly", "ubuntu", "trusty", ) repo.path = "some_path" session.commit() repo_id = repo.id data = {"bogus": "7", "distro": "centos"} result = session.app.post_json( "/repos/foobar/firefly/ubuntu/trusty/", params=data, expect_errors=True, ) assert result.status_int == 400 updated_repo = Repo.get(repo_id) assert updated_repo.distro == "ubuntu"
def test_update_single_field(self, session): p = Project('foobar') repo = Repo( p, "firefly", "ubuntu", "trusty", ) repo.path = "some_path" session.commit() repo_id = repo.id data = {"distro_version": "precise"} result = session.app.post_json( "/repos/foobar/firefly/ubuntu/trusty/", params=data, ) assert result.status_int == 200 updated_repo = Repo.get(repo_id) assert updated_repo.distro_version == "precise" assert result.json['distro_version'] == "precise"
def test_does_show_sha1_without_built_repos(self, session): p = Project('foobar') repo = Repo( p, "firefly", "ubuntu", "trusty", sha1="sha1", ) Repo( p, "firefly", "centos", "7", sha1="head", ) repo.path = "some_path" session.commit() result = session.app.get('/repos/foobar/firefly/') assert len(result.json) == 2 assert "sha1" in result.json
def test_update_single_field(self, session, url): p = Project('foobar') repo = Repo( p, "firefly", "ubuntu", "trusty", sha1="head", ) repo.path = "some_path" session.commit() repo_id = repo.id data = {"distro_version": "precise"} result = session.app.post_json( url, params=data, ) assert result.status_int == 200 updated_repo = Repo.get(repo_id) assert updated_repo.distro_version == "precise" assert result.json['distro_version'] == "precise"
def test_update_invalid_fields(self, session, url): p = Project('foobar') repo = Repo( p, "firefly", "ubuntu", "trusty", sha1="head", ) repo.path = "some_path" session.commit() repo_id = repo.id data = {"bogus": "7", "distro": "centos"} result = session.app.post_json( url, params=data, expect_errors=True, ) assert result.status_int == 400 updated_repo = Repo.get(repo_id) assert updated_repo.distro == "ubuntu"
def test_add_extra_metadata(self, session, url): p = Project('foobar') repo = Repo( p, "firefly", "ubuntu", "trusty", sha1="head", ) repo.path = "some_path" session.commit() repo_id = repo.id data = {'version': '0.94.8', 'distros': ['precise']} session.app.post_json( url, params=data, ) updated_repo = Repo.get(repo_id) assert updated_repo.extra == { "version": "0.94.8", 'distros': ['precise'] }
def test_update_multiple_fields(self, session, url): p = Project('foobar') repo = Repo( p, "firefly", "ubuntu", "trusty", sha1="head", ) repo.path = "some_path" session.commit() repo_id = repo.id data = {"distro_version": "7", "distro": "centos"} result = session.app.post_json( url, params=data, ) assert result.status_int == 200 updated_repo = Repo.get(repo_id) assert updated_repo.distro_version == "7" assert updated_repo.distro == "centos" assert result.json['distro_version'] == "7" assert result.json['distro'] == "centos"
def test_create(self, session, url): p = Project('foobar') repo = Repo( p, "firefly", "ubuntu", "trusty", sha1="head", ) repo.path = "some_path" session.commit() repo.get(1) repo.needs_update = False session.commit() # create a raw type repo result = session.app.post_json( url, params={'type': 'raw'}, ) assert result.json['type'] == 'raw' # adding an rpm doesn't change the type Binary( 'binary.rpm', p, repo, ref='firefly', sha1='head', flavor='default', distro='ubuntu', distro_version='trusty', arch='arm64', ) session.commit() result = session.app.get(url) assert result.json['type'] == 'raw'