diff --git a/delete_multiple_resource_types_with_csv/main_test.py b/delete_multiple_resource_types_with_csv/main_test.py new file mode 100644 index 0000000..8398072 --- /dev/null +++ b/delete_multiple_resource_types_with_csv/main_test.py @@ -0,0 +1,61 @@ +import unittest +import requests +import sys +import csv +from unittest.mock import patch +sys.path.append('..') +import delete_features_with_csv + +class test_stuff(): + def __init__(self): + self.subdomain = "test_subdomain" + +class DeleteResourceTest(unittest.TestCase): + + def setUp(self): + delete_features_with_csv.options = { + 'subdomain': 'test_subdomain' + + } + + def test_construct_dictionary(self): + dictionary_should_be = { + "services": [ "P5G0L4E", "P26CKSR", "P9SOLH4"], + "escalation_policies":[ "P9M61GH", "P0REPRD", "PZ4YTZJ", "P7AQQGT"], + "schedules":[ "PZLRDOC", "PSCFBJM", "P0CTUZ1", "PWP3CZP"], + "teams":[ "P8O2THQ", "PDHGVLE"], + "users":[ "PW3C4JE", "POI33V1"] + } + + + + def test_get_name(self): + resource = "escalation_policies" + # the schema of an esclation policy is much longer than this, but this will do for testing purposes + subscript = { + "escalation_policy":{"id":"PAEILY8","type":"escalation_policy", + "summary":"SN:CAB Approval","self":"https://api.pagerduty.com/escalation_policies/PAEILY8", + "html_url":"https://pdt-isabella.pagerduty.com/escalation_policies/PAEILY8","name":"SN:CAB Approval", + } + } + + self.assertEqual(delete_features_with_csv.get_name(resource, subscript), "SN:CAB Approval") + + def test_make_plural(self): + self.assertEqual(delete_features_with_csv.make_plural("escalation_policy"), "escalation_policies") + self.assertEqual(delete_features_with_csv.make_plural("service"), "services") + + + + + def test_delete_resources_and_dependencies(self): + delete_features_with_csv.options.update({ + 'delete_dependencies': True + }) + + + + + +if __name__ == '__main__': + unittest.main() \ No newline at end of file diff --git a/import_users/import_users.rb b/import_users/import_users.rb index 9c20af7..6c8f464 100755 --- a/import_users/import_users.rb +++ b/import_users/import_users.rb @@ -97,11 +97,12 @@ def add_contact(user_id, type, address, country_code, label) :contact_method => { :type => type, :address => address, + :country_code => country_code, :label => label } } - request_body[:contact_method][:country_code] = country_code if ["sms_contact_method", "phone_contact_method"].include?(type) - post("/users/#{user_id}/contact_methods", request_body) + #request_body[:contact_method][:country_code] = country_code if ["sms_contact_method", "phone_contact_method"].include?(type) + #post("/users/#{user_id}/contact_methods", request_body) end def add_notification_rule(user_id, contact_method_id, contact_method_type, delay_in_minutes) @@ -268,8 +269,8 @@ def team_roles(record,team_index) #role must be one of the following manager,observer,responder in the csv file as per our API user_role = record.role - #return observer as fixed role if base role is one of the ready_only - return 'observer' if user_role.include?('read_only') + #return observer as fixed role if base role is observer or stakeholder + return 'observer' if user_role == 'read_only_limited_user' || user_role == 'restricted_access' || user_role == 'read_only_user' default_role = DEFAULT_TEAM_ROLES["#{user_role}".to_sym]