Example #1
0
 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"]
Example #2
0
 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']}
Example #3
0
 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
Example #4
0
 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"]
Example #5
0
 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"]}
Example #6
0
 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'] == {}
Example #7
0
 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
Example #8
0
 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']
Example #9
0
 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
Example #10
0
 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'])
Example #11
0
 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
Example #12
0
 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'] == {}
Example #13
0
 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
Example #14
0
 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'])
Example #15
0
 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"]
Example #16
0
 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"]
Example #17
0
 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"]}
Example #18
0
 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"]}
Example #19
0
 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
Example #20
0
 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']
Example #21
0
 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
Example #22
0
 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
Example #23
0
 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']}
Example #24
0
 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"]}
Example #25
0
 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"]}
Example #26
0
 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"
Example #27
0
 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
Example #28
0
 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
Example #29
0
 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
Example #30
0
 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
Example #31
0
 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
Example #32
0
 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
Example #33
0
 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
Example #34
0
 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"
Example #35
0
 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"
Example #36
0
 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
Example #37
0
 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
Example #38
0
 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
Example #39
0
 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
Example #40
0
 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']}
Example #41
0
 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"])
Example #42
0
 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"])
Example #43
0
 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"]}
Example #44
0
 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
Example #45
0
 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"
Example #46
0
 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"
Example #47
0
 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
Example #48
0
 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"
Example #49
0
 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"
Example #50
0
 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']
     }
Example #51
0
 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"
Example #52
0
    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'