Esempio n. 1
0
    def test_api_update_multiple_fields(self):
        service, group = self.testdata_helper.create_default_gate()

        message = "total_original_test_message"

        original = self.api_helper.get_gate(group, service)
        self.api_helper.update_gate(
            group, service, {
                "environments": {
                    "develop": {
                        "state": "closed"
                    },
                    "live": {
                        "message": message
                    }
                }
            })
        updated = self.api_helper.get_gate(group, service)

        self.assertEqual(
            get_by_list(updated, ["environments", "live", "message"]), message)
        self.assertEqual(
            get_by_list(updated, ["environments", "develop", "state"]),
            "closed")
        original["environments"]["live"]["message"] = ""
        original["environments"]["live"]["message_timestamp"] = ""
        original["environments"]["develop"]["state"] = ""
        original["environments"]["develop"]["state_timestamp"] = ""
        updated["environments"]["live"]["message"] = ""
        updated["environments"]["live"]["message_timestamp"] = ""
        updated["environments"]["develop"]["state"] = ""
        updated["environments"]["develop"]["state_timestamp"] = ""
        self.assertDictEqual(original, updated)
Esempio n. 2
0
    def test_api_switch_and_check_gate(self):
        service, group = self.testdata_helper.create_default_gate()

        response = self.api_helper.open_gate(group, service, 'develop')
        self.assertEqual(get_by_list(response, self.keys_develop_state), 'open')

        response = self.api_helper.get_gate(group, service)
        self.assertEqual(get_by_list(response, self.keys_develop_state), 'open')
        self.assertNotEqual('', get_by_list(response, ['environments', 'develop', 'state_timestamp']))

        response = self.api_helper.close_gate(group, service, 'develop')
        self.assertEqual(get_by_list(response, self.keys_develop_state), 'closed')

        response = self.api_helper.get_gate(group, service)
        self.assertEqual(get_by_list(response, self.keys_develop_state), 'closed')
Esempio n. 3
0
    def test_api_switch_and_check_gate(self):
        service, group = self.testdata_helper.create_default_gate()

        response = self.api_helper.open_gate(group, service, 'develop')
        self.assertEqual(get_by_list(response, self.keys_develop_state), 'open')

        response = self.api_helper.get_gate(group, service)
        self.assertEqual(get_by_list(response, self.keys_develop_state), 'open')
        self.assertNotEqual('', get_by_list(response, ['environments', 'develop', 'state_timestamp']))

        response = self.api_helper.close_gate(group, service, 'develop')
        self.assertEqual(get_by_list(response, self.keys_develop_state), 'closed')

        response = self.api_helper.get_gate(group, service)
        self.assertEqual(get_by_list(response, self.keys_develop_state), 'closed')
Esempio n. 4
0
    def test_api_test_and_set_gate_multiple_one_closed(self):
        service, group = self.testdata_helper.create_default_gate()
        another_service, another_group = self.testdata_helper.create_default_gate()

        response = self.api_helper.close_gate(another_group, another_service, 'live')
        self.assertEqual(get_by_list(response, ['environments', 'live', 'state']), 'closed')

        set_data = {
            "gates": {
                group: {
                    service: ['develop']
                },
                another_group: {
                    another_service: 'live'
                }
            }
        }
        response = self.api_helper.set_gate(set_data)
        self.assertEqual(response['status'], "denied", response)

        response = self.api_helper.get_gate(group, service)
        self.assertEqual(response['environments']['develop']['state'], 'open')
        self.assertEqual(response['environments']['live']['state'], 'open')

        response = self.api_helper.get_gate(another_group, another_service)
        self.assertEqual(response['environments']['develop']['state'], 'open')
        self.assertEqual(response['environments']['live']['state'], 'closed')
Esempio n. 5
0
    def test_api_test_and_set_gate_multiple_one_closed(self):
        service, group = self.testdata_helper.create_default_gate()
        another_service, another_group = self.testdata_helper.create_default_gate(
        )

        response = self.api_helper.close_gate(another_group, another_service,
                                              'live')
        self.assertEqual(
            get_by_list(response, ['environments', 'live', 'state']), 'closed')

        set_data = {
            "gates": {
                group: {
                    service: ['develop']
                },
                another_group: {
                    another_service: 'live'
                }
            }
        }
        response = self.api_helper.set_gate(set_data)
        self.assertEqual(response['status'], "denied", response)

        response = self.api_helper.get_gate(group, service)
        self.assertEqual(response['environments']['develop']['state'], 'open')
        self.assertEqual(response['environments']['live']['state'], 'open')

        response = self.api_helper.get_gate(another_group, another_service)
        self.assertEqual(response['environments']['develop']['state'], 'open')
        self.assertEqual(response['environments']['live']['state'], 'closed')
Esempio n. 6
0
    def test_legacy_api_test_and_set_gate_closed(self):
        service, group, set_data = self.testdata_helper.prepare_legacy_test_and_set_data()

        response = self.api_helper.close_gate(group, service, 'develop')
        self.assertEqual(get_by_list(response, ['environments', 'develop', 'state']), 'closed')

        response = self.api_helper.legacy_set_gate(set_data)
        self.assertEqual(response['status'], "denied", response)
Esempio n. 7
0
    def test_api_test_and_set_gate_closed(self):
        service, group, set_data = self.testdata_helper.prepare_test_and_set_data()

        response = self.api_helper.close_gate(group, service, 'develop')
        self.assertEqual(get_by_list(response, ['environments', 'develop', 'state']), 'closed')

        response = self.api_helper.set_gate(set_data)
        self.assertEqual(response['status'], "denied")
Esempio n. 8
0
    def test_api_update_multiple_fields(self):
        service, group = self.testdata_helper.create_default_gate()

        message = "total_original_test_message"

        original = self.api_helper.get_gate(group, service)
        self.api_helper.update_gate(group, service,
                                    {"environments": {"develop": {"state": "closed"}, "live": {"message": message}}})
        updated = self.api_helper.get_gate(group, service)

        self.assertEqual(get_by_list(updated, ["environments", "live", "message"]), message)
        self.assertEqual(get_by_list(updated, ["environments", "develop", "state"]), "closed")
        original["environments"]["live"]["message"] = ""
        original["environments"]["live"]["message_timestamp"] = ""
        original["environments"]["develop"]["state"] = ""
        updated["environments"]["live"]["message"] = ""
        updated["environments"]["live"]["message_timestamp"] = ""
        updated["environments"]["develop"]["state"] = ""
        self.assertDictEqual(original, updated)