Ejemplo n.º 1
0
    def test_edit_developers_must_return_new_developers(self):
        developers_from_assertion = [
            {
                'developer-id': 'test-dev-id1',
                'since': '2017-02-10T08:35:00.000000Z',
                'until': '2018-02-10T08:35:00.000000Z'
            },
        ]

        new_developers = ("developers:\n"
                          "- developer-id: test-dev-id1\n"
                          "  since: '2017-02-10 08:35:00'\n"
                          "  until: '2018-02-10 08:35:00'\n"
                          "- developer-id: test-dev-id2\n"
                          "  since: '2016-02-10 08:35:00'\n"
                          "  until: '2019-02-10 08:35:00'\n")

        with mock.patch('builtins.open',
                        new_callable=mock.mock_open,
                        read_data=new_developers):
            developers_for_assertion = assertions._update_developers(
                developers_from_assertion)

        expected_developers = developers_from_assertion + [
            {
                'developer-id': 'test-dev-id2',
                'since': '2016-02-10T08:35:00.000000Z',
                'until': '2019-02-10T08:35:00.000000Z',
            }
        ]
        self.assertThat(developers_for_assertion, Equals(expected_developers))
Ejemplo n.º 2
0
    def test_edit_developers_must_write_header_and_developers(self):
        developers_from_assertion = [
            {
                "developer-id": "test-dev-id1",
                "since": "2017-02-10T08:35:00.000000Z",
                "until": "2018-02-10T08:35:00.000000Z",
            },
            {
                "developer-id": "test-dev-id2",
                "since": "2016-02-10T08:35:00.000000Z",
                "until": "2019-02-10T08:35:00.000000Z",
            },
        ]

        existing_developers = ("developers:\n"
                               "- developer-id: test-dev-id1\n"
                               "  since: '2017-02-10 08:35:00'\n"
                               "  until: '2018-02-10 08:35:00'\n"
                               "- developer-id: test-dev-id2\n"
                               "  since: '2016-02-10 08:35:00'\n"
                               "  until: '2019-02-10 08:35:00'\n")
        expected_written = assertions._COLLABORATION_HEADER + "\n" + existing_developers

        with mock.patch("builtins.open",
                        new_callable=mock.mock_open,
                        read_data=expected_written) as mock_open:
            developers_for_assertion = assertions._update_developers(
                developers_from_assertion)

        written = ""
        for call in mock_open().write.call_args_list:
            written += str(call.call_list()[0][0][0])
        self.assertThat(written, Equals(expected_written))
        self.assertThat(developers_for_assertion,
                        Equals(developers_from_assertion))
Ejemplo n.º 3
0
    def test_edit_developers_must_return_new_developers(self):
        developers_from_assertion = [
            {
                "developer-id": "test-dev-id1",
                "since": "2017-02-10T08:35:00.000000Z",
                "until": "2018-02-10T08:35:00.000000Z",
            }
        ]

        new_developers = (
            "developers:\n"
            "- developer-id: test-dev-id1\n"
            "  since: '2017-02-10 08:35:00'\n"
            "  until: '2018-02-10 08:35:00'\n"
            "- developer-id: test-dev-id2\n"
            "  since: '2016-02-10 08:35:00'\n"
            "  until: '2019-02-10 08:35:00'\n"
        )

        with mock.patch(
            "builtins.open", new_callable=mock.mock_open, read_data=new_developers
        ):
            developers_for_assertion = assertions._update_developers(
                developers_from_assertion
            )

        expected_developers = developers_from_assertion + [
            {
                "developer-id": "test-dev-id2",
                "since": "2016-02-10T08:35:00.000000Z",
                "until": "2019-02-10T08:35:00.000000Z",
            }
        ]
        self.assertThat(developers_for_assertion, Equals(expected_developers))
Ejemplo n.º 4
0
    def test_edit_developers_must_write_header_and_developers(self):
        developers_from_assertion = [
            {'developer-id': 'test-dev-id1',
             'since': '2017-02-10T08:35:00.000000Z',
             'until': '2018-02-10T08:35:00.000000Z'},
            {'developer-id': 'test-dev-id2',
             'since': '2016-02-10T08:35:00.000000Z',
             'until': '2019-02-10T08:35:00.000000Z'},
        ]

        existing_developers = ("developers:\n"
                               "- developer-id: test-dev-id1\n"
                               "  since: '2017-02-10 08:35:00'\n"
                               "  until: '2018-02-10 08:35:00'\n"
                               "- developer-id: test-dev-id2\n"
                               "  since: '2016-02-10 08:35:00'\n"
                               "  until: '2019-02-10 08:35:00'\n")
        expected_written = (assertions._COLLABORATION_HEADER + '\n' +
                            existing_developers)

        with mock.patch(
                'builtins.open',
                new_callable=mock.mock_open,
                read_data=expected_written) as mock_open:
            developers_for_assertion = assertions._update_developers(
                developers_from_assertion)

        written = ''
        for call in mock_open().write.call_args_list:
            written += str(call.call_list()[0][0][0])
        self.assertThat(written, Equals(expected_written))
        self.assertThat(
            developers_for_assertion, Equals(developers_from_assertion))
Ejemplo n.º 5
0
    def test_edit_developers_must_write_header_and_developers(self):
        developers_from_assertion = [
            {
                "developer-id": "test-dev-id1",
                "since": "2017-02-10T08:35:00.000000Z",
                "until": "2018-02-10T08:35:00.000000Z",
            },
            {
                "developer-id": "test-dev-id2",
                "since": "2016-02-10T08:35:00.000000Z",
                "until": "2019-02-10T08:35:00.000000Z",
            },
        ]

        existing_developers = (
            "developers:\n"
            "- developer-id: test-dev-id1\n"
            "  since: '2017-02-10 08:35:00'\n"
            "  until: '2018-02-10 08:35:00'\n"
            "- developer-id: test-dev-id2\n"
            "  since: '2016-02-10 08:35:00'\n"
            "  until: '2019-02-10 08:35:00'\n"
        )
        expected_written = assertions._COLLABORATION_HEADER + "\n" + existing_developers

        with mock.patch(
            "builtins.open", new_callable=mock.mock_open, read_data=expected_written
        ) as mock_open:
            developers_for_assertion = assertions._update_developers(
                developers_from_assertion
            )

        written = ""
        for call in mock_open().write.call_args_list:
            written += str(call.call_list()[0][0][0])
        self.assertThat(written, Equals(expected_written))
        self.assertThat(developers_for_assertion, Equals(developers_from_assertion))