66
77from copr_common .enums import BuildSourceEnum
88
9+ from coprs .logic .builds_logic import BuildsLogic
910from tests .coprs_test_case import CoprsTestCase , TransactionDecorator
1011
1112class TestDistGitMethod (CoprsTestCase ):
@@ -28,11 +29,36 @@ def test_copr_user_can_add_distgit_build(self):
2829 assert build .source_type == BuildSourceEnum .distgit
2930 assert build .source_json == json .dumps ({
3031 "clone_url" : "https://src.fedoraproject.org/rpms/mock" ,
32+ "distgit" : "fedora" ,
3133 "committish" : "master" })
3234
3335 assert len (build .chroots ) == 1
3436 assert build .chroots [0 ].name == "fedora-18-x86_64"
3537
38+ @TransactionDecorator ("u1" )
39+ @pytest .mark .usefixtures ("f_users" , "f_coprs" , "f_mock_chroots" , "f_db" )
40+ def test_distgit_build_stores_namespace_distgit (self ):
41+ """
42+ Test that distgit_namespace and distgit source is stored in source_json when provided.
43+ """
44+ self .db .session .add_all ([self .u1 , self .c1 ])
45+ data = {
46+ "package_name" : "mock" ,
47+ "committish" : "master" ,
48+ "namespace" : "forks/testuser" ,
49+ "chroots" : ["fedora-18-x86_64" ],
50+ }
51+ endpoint = "/coprs/{0}/{1}/new_build_distgit/" .format (self .u1 .name ,
52+ self .c1 .name )
53+ self .test_client .post (endpoint , data = data , follow_redirects = True )
54+ build = self .models .Build .query .first ()
55+ assert build .source_type == BuildSourceEnum .distgit
56+ source_dict = json .loads (build .source_json )
57+ assert "namespace" in source_dict
58+ assert "distgit" in source_dict
59+ assert source_dict ["namespace" ] == "forks/testuser"
60+ assert source_dict ["distgit" ] == "fedora"
61+
3662 @TransactionDecorator ("u1" )
3763 @pytest .mark .usefixtures ("f_users" , "f_coprs" , "f_mock_chroots" , "f_db" )
3864 def test_copr_user_can_add_distgit_package (self ):
0 commit comments