Esempio n. 1
0
 def setUpTestData(cls):
     cls.project = ProjectFactory()
     cls.domain = HistoryFactory(project=cls.project)
     cls.server = ServerHistoryFactory(project=cls.project)
     cls.vps = TransientServerFactory(project=cls.project)
     cls.link = DomainServerConnectionFactory(
         project=cls.project,
         domain=cls.domain,
         static_server=cls.server,
         transient_server=None,
     )
     cls.link_dict = cls.link.__dict__
Esempio n. 2
0
    def test_selecting_two_servers(self):
        entry = DomainServerConnectionFactory()
        entry.static_server = ServerHistoryFactory()
        entry.transient_server = TransientServerFactory()

        with self.assertRaises(IntegrityError):
            entry.save()
Esempio n. 3
0
    def test_property_domain_name(self):
        entry = DomainServerConnectionFactory(domain=HistoryFactory(
            domain=DomainFactory(name="ghostwriter.wiki")))

        try:
            self.assertEqual(entry.domain_name, "ghostwriter.wiki")
            entry.domain.domain.name = "getghostwriter.io"
            entry.domain.domain.save()
            self.assertEqual(entry.domain_name, "getghostwriter.io")
        except Exception:
            self.fail(
                "DomainServerConnection model `domain_name` property failed unexpectedly!"
            )
Esempio n. 4
0
    def test_crud(self):
        # Create
        entry = DomainServerConnectionFactory(subdomain="wiki")

        # Read
        self.assertEqual(entry.subdomain, "wiki")
        self.assertEqual(entry.pk, entry.id)

        server = f"{entry.static_server}{entry.transient_server}"
        self.assertQuerysetEqual(
            self.DomainServerConnection.objects.all(),
            [
                f"<DomainServerConnection: {entry.subdomain}.{entry.domain} used with {server}>"
            ],
        )

        # Update
        entry.ip_address = "192.168.2.200"
        entry.save()
        self.assertEqual(entry.ip_address, "192.168.2.200")

        # Delete
        entry.delete()
        assert not self.DomainServerConnection.objects.all().exists()