#122 Make orphan reason optional
Merged 3 years ago by pingou. Opened 3 years ago by zlopez.
zlopez/pagure-dist-git orphan  into  master

file modified
+1 -1
@@ -35,7 +35,7 @@ 

  

      orphan_reason = wtforms.SelectField(

          "Reason for orphaning package",

-         [wtforms.validators.DataRequired()],

+         [wtforms.validators.optional(strip_whitespace=True)],

          choices=[

              ("Lack of time", "Lack of time"),

              ("Do not use it anymore", "Do not use it anymore"),

file modified
+9 -9
@@ -234,15 +234,15 @@ 

      Input

      ^^^^^

  

-     +-----------------------+---------+--------------+---------------------------+

-     | Key                   | Type    | Optionality  | Description               |

-     +=======================+=========+==============+===========================+

-     | ``orphan_reason``     | string  | Mandatory    | | The reason to orphan    |

-     |                       |         |              |   the package.            |

-     +-----------------------+---------+--------------+---------------------------+

-     | ``orphan_reason_info``| string  | Optional     | | Additional info for     |

-     |                       |         |              |   provided reason.        |

-     +-----------------------+---------+--------------+---------------------------+

+     +-----------------------+---------+--------------+------------------------+

+     | Key                   | Type    | Optionality  | Description            |

+     +=======================+=========+==============+========================+

+     | ``orphan_reason``     | string  | Optional     | | The reason to orphan |

+     |                       |         |              |   the package.         |

+     +-----------------------+---------+--------------+------------------------+

+     | ``orphan_reason_info``| string  | Optional     | | Additional info for  |

+     |                       |         |              |   provided reason.     |

+     +-----------------------+---------+--------------+------------------------+

  

      Sample response

      ^^^^^^^^^^^^^^^

@@ -53,11 +53,21 @@ 

          )

          assert output.status_code == 401

  

+     def test_empty_form(self):

+         """Assert that empty form is accepted.

+         """

+         headers = {"Authorization": "token aaabbbcccddd"}

+         datainput = {}

+         output = self.app.post(

+             "/_dg/orphan/somenamespace/test3", data=datainput, headers=headers,

+         )

+         assert output.status_code == 200

+ 

      def test_invalid_form(self):

          """Assert that invalid form is not accepted.

          """

          headers = {"Authorization": "token aaabbbcccddd"}

-         datainput = {}

+         datainput = {"orphan_reason": "bar"}

What's wrong with this input?

The "bar" is not an available choice. I only accept predefined choices.

          output = self.app.post(

              "/_dg/orphan/somenamespace/test3", data=datainput, headers=headers,

          )

Cool, does that change anything in the tests?

rebased onto f64cd49

3 years ago

Fixed the tests. The one test was failing and style test also failed.

The "bar" is not an available choice. I only accept predefined choices.

Pull-Request has been merged by pingou

3 years ago