示例#1
0
 def test_set_distro_series_doesnt_allow_short_ubuntu_series(self):
     self.client_log_in()
     node = factory.make_Node(owner=self.logged_in_user)
     make_usable_osystem(self, osystem_name='ubuntu', releases=['trusty'])
     form = MachineForm(data={
         'hostname': factory.make_name('host'),
         'architecture': make_usable_architecture(self),
     },
                        instance=node)
     form.set_distro_series('trust')
     self.assertFalse(form.is_valid())
示例#2
0
 def test_set_distro_series_accepts_short_distro_series(self):
     self.client_log_in()
     node = factory.make_Node(owner=self.logged_in_user)
     release = factory.make_name('release')
     make_usable_osystem(
         self, releases=[release + '6', release + '0', release + '3'])
     form = MachineForm(data={
         'hostname': factory.make_name('host'),
         'architecture': make_usable_architecture(self),
     },
                        instance=node)
     form.set_distro_series(release)
     form.save()
     self.assertEqual(release + '6', node.distro_series)
示例#3
0
 def test__returns_osystem_and_release_with_license_key_stripped(self):
     factory.make_Node()
     osystem = make_usable_osystem(self)
     release = osystem['default_release']
     self.assertEqual(
         (osystem['name'], release),
         validate_osystem_and_distro_series(osystem['name'], release + '*'))
示例#4
0
    def test_settings_deploy_POST(self):
        self.client.login(user=factory.make_admin())
        osystem = make_usable_osystem(self)
        osystem_name = osystem["name"]
        release_name = osystem["default_release"]
        response = self.client.post(
            reverse("settings_general"),
            get_prefixed_form_data(
                prefix="deploy",
                data={
                    "default_osystem":
                    osystem_name,
                    "default_distro_series":
                    "%s/%s" % (osystem_name, release_name),
                },
            ),
        )

        self.assertEqual(http.client.FOUND, response.status_code,
                         response.content)
        self.assertEqual(
            (osystem_name, release_name),
            (
                Config.objects.get_config("default_osystem"),
                Config.objects.get_config("default_distro_series"),
            ),
        )
示例#5
0
 def test__raises_error_if_not_supported_release(self):
     osystem = make_usable_osystem(self)
     release = factory.make_name("release")
     error = self.assertRaises(ValidationError,
                               validate_osystem_and_distro_series,
                               osystem['name'], release)
     self.assertEqual(
         "%s/%s is not a support operating system and release "
         "combination." % (osystem['name'], release), error.message)
示例#6
0
 def test_accepts_osystem(self):
     self.client_log_in()
     node = factory.make_Node(owner=self.logged_in_user)
     osystem = make_usable_osystem(self)
     form = MachineForm(data={
         'hostname': factory.make_name('host'),
         'architecture': make_usable_architecture(self),
         'osystem': osystem['name'],
     },
                        instance=node)
     self.assertTrue(form.is_valid(), form._errors)
示例#7
0
 def test_accepts_osystem_distro_series(self):
     user = factory.make_User()
     self.client.login(user=user)
     node = factory.make_Node(owner=user)
     osystem = make_usable_osystem(self)
     release = osystem['default_release']
     form = MachineForm(data={
         'hostname': factory.make_name('host'),
         'architecture': make_usable_architecture(self),
         'osystem': osystem['name'],
         'distro_series': '%s/%s' % (osystem['name'], release),
         },
         instance=node)
     self.assertTrue(form.is_valid(), form._errors)
示例#8
0
 def test_rejects_invalid_osystem_distro_series(self):
     user = factory.make_User()
     self.client.login(user=user)
     node = factory.make_Node(owner=user)
     osystem = make_usable_osystem(self)
     release = factory.make_name('release')
     form = MachineForm(data={
         'hostname': factory.make_name('host'),
         'architecture': make_usable_architecture(self),
         'osystem': osystem['name'],
         'distro_series': '%s/%s' % (osystem['name'], release),
         },
         instance=node)
     self.assertFalse(form.is_valid())
     self.assertItemsEqual(['distro_series'], form._errors.keys())
示例#9
0
 def test_POST_power_on_returns_machine(self):
     self.patch(node_module.Machine, "_start")
     machine = factory.make_Node(
         owner=self.user,
         interface=True,
         power_type="manual",
         architecture=make_usable_architecture(self),
     )
     osystem = make_usable_osystem(self)
     distro_series = osystem["default_release"]
     response = self.client.post(
         self.get_node_uri(machine),
         {"op": "power_on", "distro_series": distro_series},
     )
     self.assertEqual(http.client.OK, response.status_code)
     self.assertEqual(
         machine.system_id, json_load_bytes(response.content)["system_id"]
     )