Пример #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"]
Пример #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']}
Пример #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
Пример #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"]
Пример #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"]}
Пример #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'] == {}
Пример #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
Пример #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']
Пример #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
Пример #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'])
Пример #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
Пример #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'] == {}
Пример #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
Пример #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'])
Пример #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"]
Пример #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"]
Пример #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"]}
Пример #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"]}
Пример #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
Пример #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']
Пример #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
Пример #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
Пример #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']}
Пример #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"]}
Пример #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"]}
Пример #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"
Пример #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
Пример #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
Пример #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
Пример #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
Пример #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
Пример #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
Пример #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
Пример #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"
Пример #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"
Пример #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
Пример #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
Пример #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
Пример #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
Пример #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']}
Пример #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"])
Пример #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"])
Пример #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"]}
Пример #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
Пример #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"
Пример #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"
Пример #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
Пример #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"
Пример #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"
Пример #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']
     }
Пример #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"
Пример #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'