Ejemplo n.º 1
0
 def test__is_idempotent(self):
     path = self.set_bootresources_yaml(factory.make_string())
     upgrade_cluster.retire_bootresources_yaml()
     content_after_upgrade = read_text_file(path)
     upgrade_cluster.retire_bootresources_yaml()
     self.assertThat(path,
                     FileContains(content_after_upgrade, encoding="utf-8"))
Ejemplo n.º 2
0
 def test__prefixes_header_to_file_if_present(self):
     content = factory.make_string()
     path = self.set_bootresources_yaml(content)
     upgrade_cluster.retire_bootresources_yaml()
     self.assertThat(
         path,
         FileContains(upgrade_cluster.BOOTRESOURCES_WARNING + content,
                      encoding="utf-8"))
Ejemplo n.º 3
0
 def test__survives_encoding_problems(self):
     path = os.path.join(self.make_dir(), 'bootresources.yaml')
     content = b'[[%s]]' % sample_binary_data
     with open(path, 'wb') as config:
         config.write(content)
     self.patch(upgrade_cluster, 'BOOTRESOURCES_FILE', path)
     upgrade_cluster.retire_bootresources_yaml()
     self.assertThat(
         path, FileContains(
             upgrade_cluster.BOOTRESOURCES_WARNING.encode('ascii') +
             content))
Ejemplo n.º 4
0
 def test_survives_encoding_problems(self):
     path = os.path.join(self.make_dir(), "bootresources.yaml")
     content = b"[[%s]]" % sample_binary_data
     with open(path, "wb") as config:
         config.write(content)
     self.patch(upgrade_cluster, "BOOTRESOURCES_FILE", path)
     upgrade_cluster.retire_bootresources_yaml()
     self.assertThat(
         path,
         FileContains(
             upgrade_cluster.BOOTRESOURCES_WARNING.encode("ascii") + content
         ),
     )
Ejemplo n.º 5
0
 def test__does_nothing_if_file_not_present(self):
     path = self.set_bootresources_yaml('')
     os.remove(path)
     upgrade_cluster.retire_bootresources_yaml()
     self.assertThat(path, Not(FileExists()))