Esempio n. 1
0
    def test___nq__description(self):
        artifact1 = StepResultArtifact(name='foo',
                                       value='hello',
                                       description='test description')

        artifact2 = StepResultArtifact(name='foo',
                                       value='hello',
                                       description='bad')

        self.assertNotEqual(artifact1, artifact2)
Esempio n. 2
0
    def test_as_dict_with_description(self):
        artifact = StepResultArtifact(name='foo',
                                      value='hello',
                                      description='test description')

        expected = {
            'description': 'test description',
            'name': 'foo',
            'value': 'hello'
        }
        self.assertEqual(expected, artifact.as_dict())
    def test_get_artifacts_property(self):
        step_result = StepResult('step1', 'sub1', 'implementer1')
        step_result.add_artifact('artifact1', 'value1', 'description1')
        step_result.add_artifact('artifact2', 'value2')

        expected_artifacts = {
            'artifact1':
            StepResultArtifact(name='artifact1',
                               value='value1',
                               description='description1'),
            'artifact2':
            StepResultArtifact(name='artifact2', value='value2')
        }

        self.assertEqual(step_result.artifacts, expected_artifacts)
    def test_add_duplicate_artifact(self):
        expected_artifacts = {
            'artifact1':
            StepResultArtifact(name='artifact1',
                               value='value1',
                               description='description1'),
            'artifact2':
            StepResultArtifact(name='artifact2', value='lastonewins')
        }

        step_result = StepResult('step1', 'sub1', 'implementer1')
        step_result.add_artifact('artifact1', 'value1', 'description1')
        step_result.add_artifact('artifact2', 'here')
        step_result.add_artifact('artifact2', 'andhere')
        step_result.add_artifact('artifact2', 'lastonewins')
        self.assertEqual(step_result.artifacts, expected_artifacts)
Esempio n. 5
0
    def test_add_artifact_with_npm_output(self, os_path_exists_mock,
                                          npm_shell_command_mock):

        # Given a working directory
        with TempDirectory() as temp_dir:
            working_dir_path = os.path.join(temp_dir.path, 'working')

            # Given an NpmPackage step implementer
            npm_test = self.create_given_step_implementer(
                NpmPackage, parent_work_dir_path=working_dir_path)

            # When I run the step
            step_result = npm_test.run_step()

            # Then the StepResult should have an artifact with the npm output:
            artifact = step_result.get_artifact('npm-output')
            output_file_path = os.path.join(working_dir_path,
                                            'npm_package_output.txt')
            self.assertEqual(
                artifact,
                StepResultArtifact(
                    name='npm-output',
                    value=output_file_path,
                    description=
                    "Standard out and standard error from 'npm install'."))
Esempio n. 6
0
    def test___repr__(self):
        artifact = StepResultArtifact(name='foo',
                                      value='hello',
                                      description='test description')

        expected = "StepResultArtifact(name=foo, value=hello, description=test description)"
        self.assertEqual(expected, repr(artifact))
Esempio n. 7
0
    def test___str__(self):
        artifact = StepResultArtifact(name='foo',
                                      value='hello',
                                      description='test description')

        expected = "{'name': 'foo', 'value': 'hello', 'description': 'test description'}"
        self.assertEqual(expected, str(artifact))
Esempio n. 8
0
    def test_add_artifact_with_tox_output(self, os_path_exists_mock,
                                          tox_shell_command_mock):

        # Given a working directory
        with TempDirectory() as temp_dir:
            working_dir_path = os.path.join(temp_dir.path, 'working')

            # Given an ToxLint step implementer
            tox_test = self.create_given_step_implementer(
                ToxLint, parent_work_dir_path=working_dir_path)

            # When I run the step
            step_result = tox_test.run_step()

            # Then the StepResult should have an artifact with the tox output:
            artifact = step_result.get_artifact('tox-output')
            output_file_path = os.path.join(working_dir_path,
                                            'tox_lint_output.txt')
            self.assertEqual(
                artifact,
                StepResultArtifact(
                    name='tox-output',
                    value=output_file_path,
                    description=
                    "Standard out and standard error from 'tox lint'."))
    def test_add_artifact(self):
        step_result = StepResult('step1', 'sub1', 'implementer1')
        step_result.add_artifact('artifact1', 'value1', 'description1')
        step_result.add_artifact('artifact2', 'value2', 'description2')
        step_result.add_artifact('artifact3', 'value3')

        self.assertEqual(
            step_result.get_artifact('artifact1'),
            StepResultArtifact(name='artifact1',
                               value='value1',
                               description='description1'))
        self.assertEqual(
            step_result.get_artifact('artifact2'),
            StepResultArtifact(name='artifact2',
                               value='value2',
                               description='description2'))
        self.assertEqual(step_result.get_artifact('artifact3'),
                         StepResultArtifact(name='artifact3', value='value3'))
    def test_get_artifact(self):
        expected_artifact = StepResultArtifact(name='artifact1',
                                               value='value1',
                                               description='description1')

        step_result = StepResult('step1', 'sub1', 'implementer1')
        step_result.add_artifact('artifact1', 'value1', 'description1')
        self.assertEqual(step_result.get_artifact('artifact1'),
                         expected_artifact)
Esempio n. 11
0
    def test_description(self):
        artifact = StepResultArtifact(name='foo',
                                      value='hello',
                                      description='test description')

        self.assertEqual("test description", artifact.description)
Esempio n. 12
0
    def test_description_empty(self):
        artifact = StepResultArtifact(name='foo', value='hello')

        self.assertEqual("", artifact.description)
Esempio n. 13
0
    def test_value(self):
        artifact = StepResultArtifact(name='foo', value='hello')

        self.assertEqual('hello', artifact.value)