@@ -1805,208 +1805,3 @@ async def test_automerge_label_triggered_by_added_to_pr():
1805
1805
}
1806
1806
1807
1807
1808
- async def test_automerge_label_removed_by_core_dev ():
1809
- sha = "f2393593c99dd2d3ab8bfab6fcc5ddee540518a9"
1810
- data = {
1811
- "action" : "unlabeled" ,
1812
- "pull_request" : {
1813
- "user" : {"login" : "miss-islington" },
1814
- "labels" : [{"name" : "awaiting merge" }, {"name" : "CLA signed" }],
1815
- "head" : {"sha" : sha },
1816
- "number" : 5547 ,
1817
- "title" : "bpo-32720: Fixed the replacement field grammar documentation." ,
1818
- "body" : "\n \n `arg_name` and `element_index` are defined as `digit`+ instead of `integer`.\n \n Automerge-Triggered-By: GH:miss-islington\n \n Automerge-Triggered-By: @miss-islington" ,
1819
- "url" : "https://api.github.com/repos/python/cpython/pulls/5547" ,
1820
- "issue_url" : "https://api.github.com/repos/python/cpython/issues/5547" ,
1821
- },
1822
- "sender" : {"login" : "miss-islington" },
1823
- "label" : {"name" : AUTOMERGE_LABEL },
1824
- }
1825
-
1826
- event = sansio .Event (data , event = "pull_request" , delivery_id = "1" )
1827
-
1828
- getitem = {
1829
- f"/repos/python/cpython/commits/{ sha } /status" : {
1830
- "state" : "success" ,
1831
- "statuses" : [
1832
- {
1833
- "state" : "success" ,
1834
- "description" : "Issue report skipped" ,
1835
- "context" : "bedevere/issue-number" ,
1836
- },
1837
- {
1838
- "state" : "success" ,
1839
- "description" : "The Travis CI build passed" ,
1840
- "target_url" : "https://travis-ci.org/python/cpython/builds/340259685?utm_source=github_status&utm_medium=notification" ,
1841
- "context" : "continuous-integration/travis-ci/pr" ,
1842
- },
1843
- ],
1844
- },
1845
- "/teams/42/memberships/miss-islington" : True ,
1846
- }
1847
-
1848
- getiter = {
1849
- "/repos/python/cpython/pulls/5547/commits" : [{"sha" : sha }],
1850
- "/orgs/python/teams" : [{"name" : "python core" , "id" : 42 }],
1851
- }
1852
-
1853
- gh = FakeGH (getitem = getitem , getiter = getiter )
1854
- await status_change .router .dispatch (event , gh )
1855
- assert "body" in gh .patch_data
1856
- assert "Automerge-Triggered-By: @miss-islington" not in gh .patch_data ["body" ]
1857
- assert "Automerge-Triggered-By: GH:miss-islington" not in gh .patch_data ["body" ]
1858
- assert gh .patch_data ["body" ].endswith ("`integer`." )
1859
-
1860
-
1861
- async def test_automerge_label_removed_by_non_core_dev ():
1862
- sha = "f2393593c99dd2d3ab8bfab6fcc5ddee540518a9"
1863
- data = {
1864
- "action" : "unlabeled" ,
1865
- "pull_request" : {
1866
- "user" : {"login" : "miss-islington" },
1867
- "labels" : [{"name" : "awaiting merge" }, {"name" : "CLA signed" }],
1868
- "head" : {"sha" : sha },
1869
- "number" : 5547 ,
1870
- "title" : "bpo-32720: Fixed the replacement field grammar documentation." ,
1871
- "body" : "\n \n `arg_name` and `element_index` are defined as `digit`+ instead of `integer`.\n \n Automerge-Triggered-By: @miss-islington" ,
1872
- "url" : "https://api.github.com/repos/python/cpython/pulls/5547" ,
1873
- "issue_url" : "https://api.github.com/repos/python/cpython/issues/5547" ,
1874
- },
1875
- "sender" : {"login" : "miss-islington" },
1876
- "label" : {"name" : AUTOMERGE_LABEL },
1877
- }
1878
-
1879
- event = sansio .Event (data , event = "pull_request" , delivery_id = "1" )
1880
-
1881
- getitem = {
1882
- f"/repos/python/cpython/commits/{ sha } /status" : {
1883
- "state" : "success" ,
1884
- "statuses" : [
1885
- {
1886
- "state" : "success" ,
1887
- "description" : "Issue report skipped" ,
1888
- "context" : "bedevere/issue-number" ,
1889
- },
1890
- {
1891
- "state" : "success" ,
1892
- "description" : "The Travis CI build passed" ,
1893
- "target_url" : "https://travis-ci.org/python/cpython/builds/340259685?utm_source=github_status&utm_medium=notification" ,
1894
- "context" : "continuous-integration/travis-ci/pr" ,
1895
- },
1896
- ],
1897
- },
1898
- "/teams/42/memberships/miss-islington" : gidgethub .BadRequest (
1899
- status_code = http .HTTPStatus (404 )
1900
- ),
1901
- }
1902
-
1903
- getiter = {
1904
- "/repos/python/cpython/pulls/5547/commits" : [{"sha" : sha }],
1905
- "/orgs/python/teams" : [{"name" : "python core" , "id" : 42 }],
1906
- }
1907
-
1908
- gh = FakeGH (getitem = getitem , getiter = getiter )
1909
- await status_change .router .dispatch (event , gh )
1910
- assert "labels" in gh .post_data
1911
- assert AUTOMERGE_LABEL in gh .post_data ["labels" ]
1912
-
1913
-
1914
- async def test_label_other_than_automerge_removed ():
1915
- sha = "f2393593c99dd2d3ab8bfab6fcc5ddee540518a9"
1916
- data = {
1917
- "action" : "unlabeled" ,
1918
- "pull_request" : {
1919
- "user" : {"login" : "miss-islington" },
1920
- "labels" : [{"name" : "awaiting merge" }, {"name" : "CLA signed" }],
1921
- "head" : {"sha" : sha },
1922
- "number" : 5547 ,
1923
- "title" : "bpo-32720: Fixed the replacement field grammar documentation." ,
1924
- "body" : "\n \n `arg_name` and `element_index` are defined as `digit`+ instead of `integer`.\n \n Automerge-Triggered-By: @miss-islington" ,
1925
- "url" : "https://api.github.com/repos/python/cpython/pulls/5547" ,
1926
- "issue_url" : "https://api.github.com/repos/python/cpython/issues/5547" ,
1927
- },
1928
- "sender" : {"login" : "miss-islington" },
1929
- "label" : {"name" : "needs backport to 3.9" },
1930
- }
1931
-
1932
- event = sansio .Event (data , event = "pull_request" , delivery_id = "1" )
1933
-
1934
- getitem = {
1935
- f"/repos/python/cpython/commits/{ sha } /status" : {
1936
- "state" : "success" ,
1937
- "statuses" : [
1938
- {
1939
- "state" : "success" ,
1940
- "description" : "Issue report skipped" ,
1941
- "context" : "bedevere/issue-number" ,
1942
- },
1943
- {
1944
- "state" : "success" ,
1945
- "description" : "The Travis CI build passed" ,
1946
- "target_url" : "https://travis-ci.org/python/cpython/builds/340259685?utm_source=github_status&utm_medium=notification" ,
1947
- "context" : "continuous-integration/travis-ci/pr" ,
1948
- },
1949
- ],
1950
- },
1951
- "/teams/42/memberships/miss-islington" : True ,
1952
- }
1953
-
1954
- getiter = {
1955
- "/repos/python/cpython/pulls/5547/commits" : [{"sha" : sha }],
1956
- "/orgs/python/teams" : [{"name" : "python core" , "id" : 42 }],
1957
- }
1958
-
1959
- gh = FakeGH (getitem = getitem , getiter = getiter )
1960
- await status_change .router .dispatch (event , gh )
1961
- assert not hasattr (gh , "put_data" )
1962
- assert not hasattr (gh , "post_data" )
1963
-
1964
-
1965
- async def test_automerge_removed_but_trailer_text_edited_out ():
1966
- sha = "f2393593c99dd2d3ab8bfab6fcc5ddee540518a9"
1967
- data = {
1968
- "action" : "unlabeled" ,
1969
- "pull_request" : {
1970
- "user" : {"login" : "miss-islington" },
1971
- "labels" : [{"name" : "awaiting merge" }, {"name" : "CLA signed" }],
1972
- "head" : {"sha" : sha },
1973
- "number" : 5547 ,
1974
- "title" : "bpo-32720: Fixed the replacement field grammar documentation." ,
1975
- "body" : "\n \n `arg_name` and `element_index` are defined as `digit`+ instead of `integer`." ,
1976
- "url" : "https://api.github.com/repos/python/cpython/pulls/5547" ,
1977
- "issue_url" : "https://api.github.com/repos/python/cpython/issues/5547" ,
1978
- },
1979
- "sender" : {"login" : "miss-islington" },
1980
- "label" : {"name" : AUTOMERGE_LABEL },
1981
- }
1982
-
1983
- event = sansio .Event (data , event = "pull_request" , delivery_id = "1" )
1984
-
1985
- getitem = {
1986
- f"/repos/python/cpython/commits/{ sha } /status" : {
1987
- "state" : "success" ,
1988
- "statuses" : [
1989
- {
1990
- "state" : "success" ,
1991
- "description" : "Issue report skipped" ,
1992
- "context" : "bedevere/issue-number" ,
1993
- },
1994
- {
1995
- "state" : "success" ,
1996
- "description" : "The Travis CI build passed" ,
1997
- "target_url" : "https://travis-ci.org/python/cpython/builds/340259685?utm_source=github_status&utm_medium=notification" ,
1998
- "context" : "continuous-integration/travis-ci/pr" ,
1999
- },
2000
- ],
2001
- },
2002
- "/teams/42/memberships/miss-islington" : True ,
2003
- }
2004
-
2005
- getiter = {
2006
- "/repos/python/cpython/pulls/5547/commits" : [{"sha" : sha }],
2007
- "/orgs/python/teams" : [{"name" : "python core" , "id" : 42 }],
2008
- }
2009
-
2010
- gh = FakeGH (getitem = getitem , getiter = getiter )
2011
- await status_change .router .dispatch (event , gh )
2012
- assert gh .patch_data ["body" ] == data ["pull_request" ]["body" ]
0 commit comments