Пример #1
0
 def test_set_None_does_nothing_if_maas_id_file_does_not_exist(self):
     self.assertThat(self.maas_id_path, Not(FileExists()))
     env.set_maas_id(None)
Пример #2
0
 def test_compose_config_path_does_not_include_tftp_root(self):
     tftproot = self.make_tftp_root().asBytesMode()
     mac = factory.make_mac_address("-")
     self.assertThat(compose_config_path(mac),
                     Not(StartsWith(tftproot.path)))
Пример #3
0
 def test_make_name_does_not_include_weird_characters(self):
     self.assertThat(
         factory.make_name(size=100),
         MatchesAll(*[Not(Contains(char)) for char in "/ \t\n\r\\"]),
     )
Пример #4
0
 def assertIsNot(self, expected, observed, message=''):
     """Assert that 'expected' is not 'observed'."""
     matcher = Not(Is(expected))
     self.assertThat(observed, matcher, message)
Пример #5
0
 def test_get_maas_user_agent_without_uuid(self):
     user_agent = get_maas_user_agent()
     uuid = Config.objects.get_config('uuid')
     self.assertEqual(uuid, None)
     self.assertThat(user_agent, IsNonEmptyString)
     self.assertThat(user_agent, Not(Contains(uuid)))
Пример #6
0
 def test_includes_no_system_information_if_no_default_user(self):
     node = factory.make_Node(owner=factory.make_User())
     vendor_data = get_vendor_data(node)
     self.assertThat(vendor_data, Not(Contains('system_info')))
Пример #7
0
    def test_core_setup_skipped_if_not_classic(self):
        lifecycle.init()
        lifecycle.execute('pull', self.project_options)

        self.assertThat(self.witness_path, Not(FileExists()))
Пример #8
0
    def test_snap(self):
        self.copy_project_to_cwd('assemble')
        self.run_snapcraft('snap')

        snap_file_path = 'assemble_1.0_{}.snap'.format(self.deb_arch)
        self.assertThat(snap_file_path, FileExists())

        binary1_wrapper_path = os.path.join(self.prime_dir,
                                            'command-assemble-bin.wrapper')
        with open('binary1.after', 'r') as file_:
            expected_binary1_wrapper = file_.read()
        self.assertThat(binary1_wrapper_path,
                        FileContains(expected_binary1_wrapper))

        self.useFixture(
            fixtures.EnvironmentVariable(
                'SNAP', os.path.join(os.getcwd(), self.prime_dir)))
        binary_scenarios = (
            ('command-assemble-service.wrapper', 'service-start\n'),
            ('stop-command-assemble-service.wrapper', 'service-stop\n'),
            ('command-assemble-bin.wrapper', 'binary1\n'),
            ('command-binary2.wrapper', 'binary2\n'),
        )
        for binary, expected_output in binary_scenarios:
            output = subprocess.check_output(os.path.join(
                self.prime_dir, binary),
                                             universal_newlines=True)
            self.assertThat(output, Equals(expected_output))

        with testtools.ExpectedException(subprocess.CalledProcessError):
            subprocess.check_output(os.path.join(self.prime_dir, 'bin',
                                                 'not-wrapped'),
                                    stderr=subprocess.STDOUT)

        self.assertThat(
            os.path.join(self.prime_dir, 'bin', 'not-wrapped.wrapper'),
            Not(FileExists()))

        self.assertThat(
            os.path.join(self.prime_dir, 'bin',
                         'command-binary-wrapper-none.wrapper.wrapper'),
            Not(FileExists()))

        # LP: #1750658
        self.assertThat(
            os.path.join(self.prime_dir, 'meta', 'snap.yaml'),
            FileContains(
                dedent("""\
                name: assemble
                version: 1.0
                summary: one line summary
                description: a longer description
                architectures:
                - amd64
                confinement: strict
                grade: stable
                apps:
                  assemble-bin:
                    command: command-assemble-bin.wrapper
                  assemble-service:
                    command: command-assemble-service.wrapper
                    daemon: simple
                    stop-command: stop-command-assemble-service.wrapper
                  binary-wrapper-none:
                    command: subdir/binary3
                  binary2:
                    command: command-binary2.wrapper
            """)))
Пример #9
0
    def test_unsupported_base_using_snap(self):
        plugin = godeps.GodepsPlugin("test-part", self.options, self.project)

        self.assertThat(plugin.build_packages, Not(Contains("golang-go")))
        self.assertThat(plugin.build_snaps, Contains("go/latest/stable"))
Пример #10
0
 def test__decodes_byte_strings(self):
     string = factory.make_string().encode("utf-8")
     self.expectThat(
         describe_canonical(string),
         MatchesAll(IsInstance(str), Not(Is(string)),
                    Equals(string.decode("utf-8"))))
Пример #11
0
    def test_snap_from_snapcraft_init(self):
        self.assertThat('snapcraft.yaml', Not(FileExists()))
        self.run_snapcraft('init')
        self.assertThat(os.path.join('snap', 'snapcraft.yaml'), FileExists())

        self.run_snapcraft('snap')
Пример #12
0
 def test_debugging_logger_does_not_log_request_if_info_level(self):
     logger = self.useFixture(FakeLogger('maasserver', logging.INFO))
     request = factory.make_fake_request("/api/2.0/nodes/")
     DebuggingLoggerMiddleware().process_request(request)
     debug_output = DebuggingLoggerMiddleware._build_request_repr(request)
     self.assertThat(logger.output, Not(Contains(debug_output)))
Пример #13
0
    def test_can_select_checkbox(self):
        """Must be able to select the Qml CheckBox component."""

        obj = self.app.select_single('CheckBox')
        self.assertThat(obj, Not(Is(None)))
Пример #14
0
 def test_get_returns_None_if_maas_id_file_does_not_exist(self):
     self.assertThat(self.maas_id_path, Not(FileExists()))
     self.assertThat(env.get_maas_id(), Is(None))
Пример #15
0
 def test_list_databases(self, list_databases_mock):
     databases = self.manager.list_databases(self.context)
     self.assertThat(databases, Not(Is(None)))
     self.assertThat(databases, Equals(list_databases_mock.return_value))
     list_databases_mock.assert_any_call(None, None, False)
Пример #16
0
 def test_stopService_deletes_socket(self):
     socket_path = self.patch_socket_path()
     service = LeaseSocketService(sentinel.service, reactor)
     service.startService()
     yield service.stopService()
     self.assertThat(socket_path, Not(PathExists()))
Пример #17
0
 def test_io_bytesio(self):
     # io.BytesIO only accepts bytes so should be wrapped.
     bytes_io = io.BytesIO()
     self.assertThat(bytes_io, Not(Is(unicode_output_stream(bytes_io))))
     # Will error if s was not wrapped properly.
     unicode_output_stream(bytes_io).write(_u('foo'))
Пример #18
0
 def test_compose_kernel_command_line_not_inc_arm_specific_option(self):
     params = self.make_kernel_parameters(arch="i386")
     self.assertThat(
         compose_kernel_command_line(params),
         Not(Contains("console=ttyAMA0")),
     )
Пример #19
0
 def test_clean_pull_removes_dotnet_dir(self):
     dotnet_dir = os.path.join("parts", "test-part", "dotnet", "sdk")
     os.makedirs(dotnet_dir)
     plugin = dotnet.DotNetPlugin("test-part", self.options, self.project)
     plugin.clean_pull()
     self.assertThat(dotnet_dir, Not(DirExists()))
Пример #20
0
 def test_gen_configuration_options_for_setting(self):
     self.assertThat(
         config.gen_configuration_options_for_setting(),
         AllMatch(MatchesListwise([Not(Contains("_")),
                                   IsInstance(dict)])),
     )
Пример #21
0
 def test_prime_invalid_part_no_traceback_without_debug(self):
     self.assertThat(
         self._prime_invalid_part(False), Not(Contains("Traceback")))
Пример #22
0
 def check_a_does_not_exist():
     self.assertThat(thread_local.visiting, Not(Contains("a")))
Пример #23
0
 def assertNotIn(self, needle, haystack, message=''):
     """Assert that needle is not in haystack."""
     matcher = Not(Contains(needle))
     self.assertThat(haystack, matcher, message)
Пример #24
0
 def test_missingTac(self):
     """TacTestFixture raises TacException if the tacfile doesn't exist"""
     fixture = SimpleTac("missing", "/file/does/not/exist", 0)
     self.assertRaises(TacException, self.useFixture, fixture)
     self.assertThat(fixture, Not(IsRunning()))
Пример #25
0
 def test_bootloader_path_does_not_include_tftp_root(self):
     tftproot = self.make_tftp_root()
     method = PXEBootMethod()
     self.assertThat(method.bootloader_path, Not(StartsWith(tftproot.path)))
Пример #26
0
    def test_snap(self):
        plugin = godeps.GodepsPlugin("test-part", self.options, self.project)

        self.assertThat(plugin.build_packages, Not(Contains("golang-go")))
        self.assertThat(plugin.build_snaps, Contains("go/1.15/stable"))
Пример #27
0
 def test_make_name_does_not_require_prefix(self):
     size = randint(1, 99)
     unprefixed_name = factory.make_name(sep="-", size=size)
     self.assertEqual(size, len(unprefixed_name))
     self.assertThat(unprefixed_name, Not(StartsWith("-")))
Пример #28
0
 def test_conflicts_no_traceback_without_debug(self):
     self.assertThat(self._stage_conflicts(False),
                     Not(Contains("Traceback")))
Пример #29
0
 def test_creates_maas_id_file(self):
     self.assertThat(get_maas_id(), Is(None))
     with post_commit_hooks:
         start_up.inner_start_up(master=False)
     self.assertThat(get_maas_id(), Not(Is(None)))
Пример #30
0
 def test_set_deletes_maas_id_file_if_argument_is_whitespace(self):
     with open(self.maas_id_path, "w") as fd:
         fd.write("This file will be deleted.")
     env.set_maas_id(string.whitespace)
     self.assertThat(self.maas_id_path, Not(FileExists()))
     self.assertIsNone(env.get_maas_id())