Exemplo n.º 1
0
 def test_with_invalid_type_ip(self):
     with self.assertRaises(Exception):
         ordinateur = models.Ordinateur(123456)
     with self.assertRaises(Exception):
         ordinateur = models.Ordinateur([])
     with self.assertRaises(Exception):
         ordinateur = models.Ordinateur(10.20)
Exemplo n.º 2
0
    def test_optional_params_are_set(self):
        params = { "ip" : "1.2.3.4", "user" : "abc", "name" : "xyz" }

        ordinateur = models.Ordinateur(params["ip"], params["user"], params["name"])
        
        self.assertEqual(ordinateur.ip,   params["ip"])
        self.assertEqual(ordinateur.user, params["user"])
        self.assertEqual(ordinateur.name, params["name"])
Exemplo n.º 3
0
 def load_from_mocks(self):
     return [
         # VM Linuxlocal
         models.Ordinateur("192.168.1.156", "linuxlocal"),
         # VM Linuxlocal
         models.Ordinateur("192.168.1.157", "linuxlocal"),
         # IP valide, non joignable (Timeout)
         models.Ordinateur("1.2.3.4"),
         # IP invalide
         models.Ordinateur("192.168.1.300", name="Test"),
         # IP invalide
         models.Ordinateur("192.168.1.400"),
         # IP invalide
         models.Ordinateur("192.168.1.500"),
     ]
Exemplo n.º 4
0
    def to_ordinateur(self):
        ordinateur = models.Ordinateur(self.edit_ip.text(), self.edit_user.text(), self.edit_name.text())

        return ordinateur
Exemplo n.º 5
0
 def test_empty_params_replaced_by_defaults(self):
     ordinateur = models.Ordinateur("1.2.3.4", "", "")
     self.assertEqual(ordinateur.user, models.Ordinateur.DEFAULT_USER)
     self.assertEqual(ordinateur.name, models.Ordinateur.DEFAULT_NAME)
Exemplo n.º 6
0
 def test_ip_is_stripped(self):
     expected_ip = "1.2.3.4"
     self.assertEqual(models.Ordinateur("1.2.3.4").ip,  expected_ip)
     self.assertEqual(models.Ordinateur(" 1.2.3.4").ip, expected_ip)
     self.assertEqual(models.Ordinateur("1.2.3.4 ").ip, expected_ip)
Exemplo n.º 7
0
 def test_with_only_ip(self):
     ordinateur = models.Ordinateur("1.2.3.4")
     self.assertEqual(ordinateur.ip, "1.2.3.4")
Exemplo n.º 8
0
 def test_with_empty_ip(self):
     with self.assertRaises(Exception):
         ordinateur = models.Ordinateur("")
     with self.assertRaises(Exception):
         ordinateur = models.Ordinateur("   ")
Exemplo n.º 9
0
 def test_without_params(self):
     with self.assertRaises(Exception):
         ordinateur = models.Ordinateur()