@@ -1890,6 +1890,130 @@ def test_port_list_security_group(self):
18901890 self .assertEqual (self .columns , columns )
18911891 self .assertCountEqual (self .data , list (data ))
18921892
1893+ def test_port_list_pvlan_type (self ):
1894+ arglist = [
1895+ '--pvlan-type' ,
1896+ 'community' ,
1897+ ]
1898+ verifylist = [
1899+ ('pvlan_type' , 'community' ),
1900+ ]
1901+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
1902+
1903+ columns , _data = self .cmd .take_action (parsed_args )
1904+ expected_fields = [
1905+ * LIST_FIELDS_TO_RETRIEVE ,
1906+ 'pvlan_type' ,
1907+ 'pvlan_community' ,
1908+ ]
1909+ filters = {
1910+ 'pvlan_type' : 'community' ,
1911+ 'fields' : expected_fields ,
1912+ }
1913+
1914+ self .network_client .ports .assert_called_once_with (** filters )
1915+ expected_columns = [* self .columns , 'PVLAN Type' , 'PVLAN Community' ]
1916+ self .assertEqual (expected_columns , columns )
1917+
1918+ def test_port_list_pvlan_community (self ):
1919+ arglist = [
1920+ '--pvlan-community' ,
1921+ 'community_1' ,
1922+ ]
1923+ verifylist = [
1924+ ('pvlan_community' , 'community_1' ),
1925+ ]
1926+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
1927+
1928+ columns , _data = self .cmd .take_action (parsed_args )
1929+ expected_fields = [
1930+ * LIST_FIELDS_TO_RETRIEVE ,
1931+ 'pvlan_type' ,
1932+ 'pvlan_community' ,
1933+ ]
1934+ filters = {
1935+ 'pvlan_community' : 'community_1' ,
1936+ 'fields' : expected_fields ,
1937+ }
1938+
1939+ self .network_client .ports .assert_called_once_with (** filters )
1940+ expected_columns = [* self .columns , 'PVLAN Type' , 'PVLAN Community' ]
1941+ self .assertEqual (expected_columns , columns )
1942+
1943+ def test_port_list_pvlan (self ):
1944+ port_pvlan = network_fakes .create_one_port (
1945+ attrs = {
1946+ 'pvlan_type' : 'community' ,
1947+ 'pvlan_community' : 'community_1' ,
1948+ }
1949+ )
1950+ port_no_pvlan = network_fakes .create_one_port (
1951+ attrs = {'pvlan_type' : None , 'pvlan_community' : None }
1952+ )
1953+ self .network_client .ports .return_value = [port_pvlan , port_no_pvlan ]
1954+
1955+ arglist = [
1956+ '--pvlan' ,
1957+ ]
1958+ verifylist = [
1959+ ('pvlan' , True ),
1960+ ]
1961+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
1962+
1963+ columns , data = self .cmd .take_action (parsed_args )
1964+ expected_fields = [
1965+ * LIST_FIELDS_TO_RETRIEVE ,
1966+ 'pvlan_type' ,
1967+ 'pvlan_community' ,
1968+ ]
1969+
1970+ self .network_client .ports .assert_called_once_with (
1971+ fields = expected_fields
1972+ )
1973+ expected_columns = [* self .columns , 'PVLAN Type' , 'PVLAN Community' ]
1974+ self .assertEqual (expected_columns , columns )
1975+ result = list (data )
1976+ self .assertEqual (1 , len (result ))
1977+ # First column is the port ID
1978+ self .assertEqual (port_pvlan .id , result [0 ][0 ])
1979+
1980+ def test_port_list_no_pvlan (self ):
1981+ port_pvlan = network_fakes .create_one_port (
1982+ attrs = {
1983+ 'pvlan_type' : 'community' ,
1984+ 'pvlan_community' : 'community_1' ,
1985+ }
1986+ )
1987+ port_no_pvlan = network_fakes .create_one_port (
1988+ attrs = {'pvlan_type' : None , 'pvlan_community' : None }
1989+ )
1990+ self .network_client .ports .return_value = [port_pvlan , port_no_pvlan ]
1991+
1992+ arglist = [
1993+ '--no-pvlan' ,
1994+ ]
1995+ verifylist = [
1996+ ('no_pvlan' , True ),
1997+ ]
1998+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
1999+
2000+ columns , data = self .cmd .take_action (parsed_args )
2001+ expected_fields = [
2002+ * LIST_FIELDS_TO_RETRIEVE ,
2003+ 'pvlan_type' ,
2004+ 'pvlan_community' ,
2005+ ]
2006+
2007+ self .network_client .ports .assert_called_once_with (
2008+ fields = expected_fields
2009+ )
2010+ expected_columns = [* self .columns , 'PVLAN Type' , 'PVLAN Community' ]
2011+ self .assertEqual (expected_columns , columns )
2012+ result = list (data )
2013+ self .assertEqual (1 , len (result ))
2014+ # First column is the port ID
2015+ self .assertEqual (port_no_pvlan .id , result [0 ][0 ])
2016+
18932017 def test_port_list_status (self ):
18942018 arglist = [
18952019 '--status' ,
0 commit comments