예제 #1
0
 def test_create_empty(self):
     pub = DNSPublication()
     pub.save()
     self.assertThat(
         pub,
         MatchesStructure(
             serial=IsInstance(int),
             created=IsInstance(datetime),
             source=Equals(""),
         ))
예제 #2
0
 def test_create_with_values(self):
     serial = randint(1, 5000)
     created = datetime.now() - timedelta(minutes=1098)
     source = factory.make_name("source")
     pub = DNSPublication(serial=serial, created=created, source=source)
     pub.save()
     self.assertThat(
         pub,
         MatchesStructure(
             serial=Equals(serial),
             created=MatchesAll(
                 IsInstance(datetime),
                 # `created` is always set; given values are ignored.
                 Not(Equals(created)),
                 first_only=True,
             ),
             source=Equals(source),
         ))
예제 #3
0
 def test_current_zone_serial_returns_serial_of_latest_publication(self):
     publication = DNSPublication(source=factory.make_name("source"))
     publication.save()
     self.assertThat(int(current_zone_serial()), Equals(publication.serial))