Developer Journal: 25 April 2020

Posted on Sat 25 April 2020 in dev-journal

Fixing a bug that was introduced when changing the create server view to no longer include a radio field for the server provider. The logic was changed to use request arguments to generate the correct form but the view was not updated to do the same as the form field was removed if there was only a single server provider.

The following test was written to confirm and help fix the bug. First the test fixture made sure both server providers existed which would trigger the conditions in which the bug was observed.

def test_generate_server_provider_sets_correct_server_provider(self):
    form = generate_provider_form("linode")
    self.assertEqual(form.provider.data, "linode")

    form = generate_provider_form("digital_ocean")
    self.assertEqual(form.provider.data, "digital_ocean")